From 0eea827cbda3a10ca6515e21901b23942b43aa5a Mon Sep 17 00:00:00 2001 From: Werner Lewis Date: Tue, 1 Nov 2022 13:27:29 +0000 Subject: [PATCH] Rename MPI_CORE(add_mod) to mbedtls_mpi_mod_raw_add Signed-off-by: Werner Lewis --- library/bignum_mod_raw.c | 19 +++++++++---------- library/bignum_mod_raw.h | 22 +++++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/library/bignum_mod_raw.c b/library/bignum_mod_raw.c index 7c17e5602..2460329df 100644 --- a/library/bignum_mod_raw.c +++ b/library/bignum_mod_raw.c @@ -119,17 +119,16 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A, /* END MERGE SLOT 4 */ /* BEGIN MERGE SLOT 5 */ -void MPI_CORE(add_mod)( mbedtls_mpi_uint *X, - mbedtls_mpi_uint const *A, - mbedtls_mpi_uint const *B, - const mbedtls_mpi_uint *N, - size_t n ) +void mbedtls_mpi_mod_raw_add( mbedtls_mpi_uint *X, + mbedtls_mpi_uint const *A, + mbedtls_mpi_uint const *B, + const mbedtls_mpi_uint *N, + size_t limbs ) { - size_t carry, borrow = 0, fixup; - carry = mbedtls_mpi_core_add( X, A, B, n ); - borrow = mbedtls_mpi_core_sub( X, X, N, n); - fixup = ( carry < borrow ); - (void) mbedtls_mpi_core_add_if( X, N, n, fixup ); + size_t carry, borrow = 0; + carry = mbedtls_mpi_core_add( X, A, B, limbs ); + borrow = mbedtls_mpi_core_sub( X, X, N, limbs); + (void) mbedtls_mpi_core_add_if( X, N, limbs, ( carry < borrow ) ); } /* END MERGE SLOT 5 */ diff --git a/library/bignum_mod_raw.h b/library/bignum_mod_raw.h index c57372c94..7b82c0639 100644 --- a/library/bignum_mod_raw.h +++ b/library/bignum_mod_raw.h @@ -158,17 +158,21 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A, /** * \brief Perform a known-size modular addition. * - * Calculate A + B mod N. + * Calculate `A + B modulo N` where \p A, \p B, and \p N have the same size. * - * \param[out] X The result of the modular addition. - * \param[in] A The left operand. This must be smaller than \p N. - * \param[in] B The right operand. This must be smaller than \p N. - * \param[in] N The modulus. - * \param n Number of limbs of \p X, \p A, \p B and \p N. + * \param[out] X The result of the modular addition. + * \param[in] A Little-endian presentation of the left operand. This + * must be smaller than \p N. + * \param[in] B Little-endian presentation of the right operand. This + * must be smaller than \p N. + * \param[in] N Little-endian presentation of the modulus. + * \param limbs Number of limbs of \p X, \p A, \p B and \p N. */ -void MPI_CORE(add_mod)( mbedtls_mpi_uint *X, mbedtls_mpi_uint const *A, - mbedtls_mpi_uint const *B, const mbedtls_mpi_uint *N, - size_t n ); +void mbedtls_mpi_mod_raw_add( mbedtls_mpi_uint *X, + mbedtls_mpi_uint const *A, + mbedtls_mpi_uint const *B, + const mbedtls_mpi_uint *N, + size_t limbs ); /* END MERGE SLOT 5 */ /* BEGIN MERGE SLOT 6 */