Minor improvements to bignum module

This commit is contained in:
Hanno Becker 2018-12-19 16:18:52 +00:00
parent 59274d43cb
commit 8ce11a323e
2 changed files with 10 additions and 10 deletions

View File

@ -196,7 +196,7 @@ mbedtls_mpi;
void mbedtls_mpi_init( mbedtls_mpi *X ); void mbedtls_mpi_init( mbedtls_mpi *X );
/** /**
* \brief This function frees the components an MPI context. * \brief This function frees the components of an MPI context.
* *
* \param X The MPI context to be cleared. This may be \c NULL, * \param X The MPI context to be cleared. This may be \c NULL,
* in which case this function is a no-op. If it is * in which case this function is a no-op. If it is
@ -693,7 +693,7 @@ int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A,
* \param R The destination MPI for the remainder value. * \param R The destination MPI for the remainder value.
* This may be \c NULL if the value of the * This may be \c NULL if the value of the
* remainder is not needed. * remainder is not needed.
* \param A The divident. This must point to an initialized MPi. * \param A The dividend. This must point to an initialized MPi.
* \param B The divisor. This must point to an initialized MPI. * \param B The divisor. This must point to an initialized MPI.
* *
* \return \c 0 if successful. * \return \c 0 if successful.
@ -714,7 +714,7 @@ int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A,
* \param R The destination MPI for the remainder value. * \param R The destination MPI for the remainder value.
* This may be \c NULL if the value of the * This may be \c NULL if the value of the
* remainder is not needed. * remainder is not needed.
* \param A The divident. This must point to an initialized MPi. * \param A The dividend. This must point to an initialized MPi.
* \param b The divisor. * \param b The divisor.
* *
* \return \c 0 if successful. * \return \c 0 if successful.
@ -776,7 +776,7 @@ int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A,
* \param _RR A helper MPI depending solely on \p N which can be used to * \param _RR A helper MPI depending solely on \p N which can be used to
* speed-up multiple modular exponentiations for the same value * speed-up multiple modular exponentiations for the same value
* of \p N. This may be \c NULL. If it is not \c NULL, it must * of \p N. This may be \c NULL. If it is not \c NULL, it must
* point an initialized MPI. If it hasn't been used after * point to an initialized MPI. If it hasn't been used after
* the call to mbedtls_mpi_init(), this function will compute * the call to mbedtls_mpi_init(), this function will compute
* the helper value and store it in \p _RR for reuse on * the helper value and store it in \p _RR for reuse on
* subsequent calls to this function. Otherwise, the function * subsequent calls to this function. Otherwise, the function

View File

@ -724,7 +724,7 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t bu
size_t i, j; size_t i, j;
size_t const limbs = CHARS_TO_LIMBS( buflen ); size_t const limbs = CHARS_TO_LIMBS( buflen );
MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( X != NULL );
MPI_VALIDATE_RET( buflen == 0 || buf != NULL ); MPI_VALIDATE_RET( buflen == 0 || buf != NULL );
/* Ensure that target MPI has exactly the necessary number of limbs */ /* Ensure that target MPI has exactly the necessary number of limbs */
@ -2009,7 +2009,7 @@ int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size,
{ {
int ret; int ret;
unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( X != NULL );
MPI_VALIDATE_RET( f_rng != NULL ); MPI_VALIDATE_RET( f_rng != NULL );
if( size > MBEDTLS_MPI_MAX_SIZE ) if( size > MBEDTLS_MPI_MAX_SIZE )
@ -2192,7 +2192,7 @@ static int mpi_miller_rabin( const mbedtls_mpi *X, size_t rounds,
size_t i, j, k, s; size_t i, j, k, s;
mbedtls_mpi W, R, T, A, RR; mbedtls_mpi W, R, T, A, RR;
MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( X != NULL );
MPI_VALIDATE_RET( f_rng != NULL ); MPI_VALIDATE_RET( f_rng != NULL );
mbedtls_mpi_init( &W ); mbedtls_mpi_init( &R ); mbedtls_mpi_init( &W ); mbedtls_mpi_init( &R );
@ -2284,7 +2284,7 @@ int mbedtls_mpi_is_prime_ext( const mbedtls_mpi *X, int rounds,
{ {
int ret; int ret;
mbedtls_mpi XX; mbedtls_mpi XX;
MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( X != NULL );
MPI_VALIDATE_RET( f_rng != NULL ); MPI_VALIDATE_RET( f_rng != NULL );
XX.s = 1; XX.s = 1;
@ -2317,7 +2317,7 @@ int mbedtls_mpi_is_prime( const mbedtls_mpi *X,
int (*f_rng)(void *, unsigned char *, size_t), int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng ) void *p_rng )
{ {
MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( X != NULL );
MPI_VALIDATE_RET( f_rng != NULL ); MPI_VALIDATE_RET( f_rng != NULL );
/* /*
@ -2353,7 +2353,7 @@ int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int flags,
mbedtls_mpi_uint r; mbedtls_mpi_uint r;
mbedtls_mpi Y; mbedtls_mpi Y;
MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( X != NULL );
MPI_VALIDATE_RET( f_rng != NULL ); MPI_VALIDATE_RET( f_rng != NULL );
if( nbits < 3 || nbits > MBEDTLS_MPI_MAX_BITS ) if( nbits < 3 || nbits > MBEDTLS_MPI_MAX_BITS )