Path: blob/master/thirdparty/mbedtls/library/bignum_internal.h
9898 views
/**1* \file bignum_internal.h2*3* \brief Internal-only bignum public-key cryptosystem API.4*5* This file declares bignum-related functions that are to be used6* only from within the Mbed TLS library itself.7*8*/9/*10* Copyright The Mbed TLS Contributors11* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later12*/13#ifndef MBEDTLS_BIGNUM_INTERNAL_H14#define MBEDTLS_BIGNUM_INTERNAL_H1516/**17* \brief Perform a modular exponentiation: X = A^E mod N18*19* \warning This function is not constant time with respect to \p E (the exponent).20*21* \param X The destination MPI. This must point to an initialized MPI.22* This must not alias E or N.23* \param A The base of the exponentiation.24* This must point to an initialized MPI.25* \param E The exponent MPI. This must point to an initialized MPI.26* \param N The base for the modular reduction. This must point to an27* initialized MPI.28* \param prec_RR A helper MPI depending solely on \p N which can be used to29* speed-up multiple modular exponentiations for the same value30* of \p N. This may be \c NULL. If it is not \c NULL, it must31* point to an initialized MPI. If it hasn't been used after32* the call to mbedtls_mpi_init(), this function will compute33* the helper value and store it in \p prec_RR for reuse on34* subsequent calls to this function. Otherwise, the function35* will assume that \p prec_RR holds the helper value set by a36* previous call to mbedtls_mpi_exp_mod(), and reuse it.37*38* \return \c 0 if successful.39* \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.40* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \c N is negative or41* even, or if \c E is negative.42* \return Another negative error code on different kinds of failures.43*44*/45int mbedtls_mpi_exp_mod_unsafe(mbedtls_mpi *X, const mbedtls_mpi *A,46const mbedtls_mpi *E, const mbedtls_mpi *N,47mbedtls_mpi *prec_RR);4849#endif /* bignum_internal.h */505152