Janos Follath | 4217503 | 2024-01-08 13:45:49 +0000 | [diff] [blame^] | 1 | /** |
| 2 | * Low level bignum functions |
| 3 | * |
| 4 | * Copyright The Mbed TLS Contributors |
| 5 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef MBEDTLS_BIGNUM_INTERNAL_H |
| 9 | #define MBEDTLS_BIGNUM_INTERNAL_H |
| 10 | |
| 11 | #include "mbedtls/bignum.h" |
| 12 | |
| 13 | /** |
| 14 | * \brief Calculate the square of the Montgomery constant. (Needed |
| 15 | * for conversion and operations in Montgomery form.) |
| 16 | * |
| 17 | * \param[out] X A pointer to the result of the calculation of |
| 18 | * the square of the Montgomery constant: |
| 19 | * 2^{2*n*biL} mod N. |
| 20 | * \param[in] N Little-endian presentation of the modulus, which must be odd. |
| 21 | * |
| 22 | * \return 0 if successful. |
| 23 | * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if there is not enough space |
| 24 | * to store the value of Montgomery constant squared. |
| 25 | * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p N modulus is zero. |
| 26 | * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p N modulus is negative. |
| 27 | */ |
| 28 | int mbedtls_mpi_get_mont_r2_unsafe(mbedtls_mpi *X, |
| 29 | const mbedtls_mpi *N); |
| 30 | |
| 31 | #endif /* MBEDTLS_BIGNUM_INTERNAL_H */ |