From 9fa91ebcb906ad93218d92bbf816bdad17f9f198 Mon Sep 17 00:00:00 2001 From: Werner Lewis Date: Tue, 1 Nov 2022 13:36:51 +0000 Subject: [PATCH] Use modulus structure in mbedtls_mpi_mod_raw_add Signed-off-by: Werner Lewis --- library/bignum_mod_raw.c | 9 ++++----- library/bignum_mod_raw.h | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/library/bignum_mod_raw.c b/library/bignum_mod_raw.c index 2460329df6..01f5a4423f 100644 --- a/library/bignum_mod_raw.c +++ b/library/bignum_mod_raw.c @@ -122,13 +122,12 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A, 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 ) + const mbedtls_mpi_mod_modulus *N ) { 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 ) ); + carry = mbedtls_mpi_core_add( X, A, B, N->limbs ); + borrow = mbedtls_mpi_core_sub( X, X, N->p, N->limbs ); + (void) mbedtls_mpi_core_add_if( X, N->p, N->limbs, ( carry < borrow ) ); } /* END MERGE SLOT 5 */ diff --git a/library/bignum_mod_raw.h b/library/bignum_mod_raw.h index 7b82c0639e..d6522381bb 100644 --- a/library/bignum_mod_raw.h +++ b/library/bignum_mod_raw.h @@ -162,17 +162,17 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A, * * \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. + * must be smaller than \p N, and have the same number of + * limbs. * \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. + * must be smaller than \p N, and have the same number of + * limbs. + * \param[in] N The address of the modulus. */ 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 ); + const mbedtls_mpi_mod_modulus *N ); /* END MERGE SLOT 5 */ /* BEGIN MERGE SLOT 6 */