Extract MPI_CORE(add) from the prototype
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
parent
383b0bbea0
commit
c98871339d
2 changed files with 38 additions and 3 deletions
|
@ -316,8 +316,6 @@ int mbedtls_mpi_core_write_be( const mbedtls_mpi_uint *X,
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void mbedtls_mpi_core_shift_r( mbedtls_mpi_uint *X, size_t limbs,
|
||||
size_t count )
|
||||
{
|
||||
|
@ -360,7 +358,21 @@ void mbedtls_mpi_core_shift_r( mbedtls_mpi_uint *X, size_t limbs,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
mbedtls_mpi_uint MPI_CORE(add)( mbedtls_mpi_uint *d,
|
||||
const mbedtls_mpi_uint *l,
|
||||
const mbedtls_mpi_uint *r,
|
||||
size_t n )
|
||||
{
|
||||
mbedtls_mpi_uint c = 0, t;
|
||||
for( size_t i = 0; i < n; i++ )
|
||||
{
|
||||
t = c;
|
||||
t += l[i]; c = ( t < l[i] );
|
||||
t += r[i]; c += ( t < r[i] );
|
||||
d[i] = t;
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
|
||||
mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *X,
|
||||
const mbedtls_mpi_uint *A,
|
||||
|
|
|
@ -277,6 +277,29 @@ int mbedtls_mpi_core_write_be( const mbedtls_mpi_uint *A,
|
|||
void mbedtls_mpi_core_shift_r( mbedtls_mpi_uint *X, size_t limbs,
|
||||
size_t count );
|
||||
|
||||
#define MPI_CORE(func) mbedtls_mpi_core_ ## func ## _minimal
|
||||
|
||||
/**
|
||||
* \brief Add two known-size large unsigned integers, returning the carry.
|
||||
*
|
||||
* Calculate l + r where l and r have the same size.
|
||||
* This function operates modulo (2^ciL)^n and returns the carry
|
||||
* (1 if there was a wraparound, and 0 otherwise).
|
||||
*
|
||||
* d may be aliased to l or r.
|
||||
*
|
||||
* \param[out] d The result of the addition.
|
||||
* \param[in] l The left operand.
|
||||
* \param[in] r The right operand.
|
||||
* \param n Number of limbs of \p d, \p l and \p r.
|
||||
*
|
||||
* \return 1 if `l + r >= (2^{ciL})^n`, 0 otherwise.
|
||||
*/
|
||||
mbedtls_mpi_uint MPI_CORE(add)( mbedtls_mpi_uint *d,
|
||||
const mbedtls_mpi_uint *l,
|
||||
const mbedtls_mpi_uint *r,
|
||||
size_t n );
|
||||
|
||||
/**
|
||||
* \brief Conditional addition of two fixed-size large unsigned integers,
|
||||
* returning the carry.
|
||||
|
|
Loading…
Reference in a new issue