Rename MPI_CORE(add_mod) to mbedtls_mpi_mod_raw_add

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
This commit is contained in:
Werner Lewis 2022-11-01 13:27:29 +00:00 committed by Tom Cosgrove
parent a45b6fee91
commit 0eea827cbd
2 changed files with 22 additions and 19 deletions

View file

@ -119,17 +119,16 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A,
/* END MERGE SLOT 4 */ /* END MERGE SLOT 4 */
/* BEGIN MERGE SLOT 5 */ /* BEGIN MERGE SLOT 5 */
void MPI_CORE(add_mod)( mbedtls_mpi_uint *X, void mbedtls_mpi_mod_raw_add( mbedtls_mpi_uint *X,
mbedtls_mpi_uint const *A, mbedtls_mpi_uint const *A,
mbedtls_mpi_uint const *B, mbedtls_mpi_uint const *B,
const mbedtls_mpi_uint *N, const mbedtls_mpi_uint *N,
size_t n ) size_t limbs )
{ {
size_t carry, borrow = 0, fixup; size_t carry, borrow = 0;
carry = mbedtls_mpi_core_add( X, A, B, n ); carry = mbedtls_mpi_core_add( X, A, B, limbs );
borrow = mbedtls_mpi_core_sub( X, X, N, n); borrow = mbedtls_mpi_core_sub( X, X, N, limbs);
fixup = ( carry < borrow ); (void) mbedtls_mpi_core_add_if( X, N, limbs, ( carry < borrow ) );
(void) mbedtls_mpi_core_add_if( X, N, n, fixup );
} }
/* END MERGE SLOT 5 */ /* END MERGE SLOT 5 */

View file

@ -158,17 +158,21 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A,
/** /**
* \brief Perform a known-size modular addition. * \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[out] X The result of the modular addition.
* \param[in] A The left operand. This must be smaller than \p N. * \param[in] A Little-endian presentation of the left operand. This
* \param[in] B The right operand. This must be smaller than \p N. * must be smaller than \p N.
* \param[in] N The modulus. * \param[in] B Little-endian presentation of the right operand. This
* \param n Number of limbs of \p X, \p A, \p B and \p N. * 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, void mbedtls_mpi_mod_raw_add( mbedtls_mpi_uint *X,
mbedtls_mpi_uint const *B, const mbedtls_mpi_uint *N, mbedtls_mpi_uint const *A,
size_t n ); mbedtls_mpi_uint const *B,
const mbedtls_mpi_uint *N,
size_t limbs );
/* END MERGE SLOT 5 */ /* END MERGE SLOT 5 */
/* BEGIN MERGE SLOT 6 */ /* BEGIN MERGE SLOT 6 */