Extract MPI_CORE(add_mod) from the prototype
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
parent
4cf77e99ab
commit
a45b6fee91
2 changed files with 26 additions and 2 deletions
|
@ -119,7 +119,18 @@ 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,
|
||||||
|
mbedtls_mpi_uint const *A,
|
||||||
|
mbedtls_mpi_uint const *B,
|
||||||
|
const mbedtls_mpi_uint *N,
|
||||||
|
size_t n )
|
||||||
|
{
|
||||||
|
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 );
|
||||||
|
}
|
||||||
/* END MERGE SLOT 5 */
|
/* END MERGE SLOT 5 */
|
||||||
|
|
||||||
/* BEGIN MERGE SLOT 6 */
|
/* BEGIN MERGE SLOT 6 */
|
||||||
|
|
|
@ -155,7 +155,20 @@ 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 */
|
||||||
|
/**
|
||||||
|
* \brief Perform a known-size modular addition.
|
||||||
|
*
|
||||||
|
* Calculate A + B mod N.
|
||||||
|
*
|
||||||
|
* \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.
|
||||||
|
*/
|
||||||
|
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 );
|
||||||
/* END MERGE SLOT 5 */
|
/* END MERGE SLOT 5 */
|
||||||
|
|
||||||
/* BEGIN MERGE SLOT 6 */
|
/* BEGIN MERGE SLOT 6 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue