Move the quasi reduction fixing function to bignum_mod_raw

Rename the function to 'fix_quasi_reduction' to better suite its functionality.
Also changed the name prefix to suite for the new module.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei 2023-01-23 16:13:43 +01:00
parent 7e14c66c4d
commit aaa1d2a276
No known key found for this signature in database
GPG key ID: F072ACA227ACD71D
14 changed files with 149 additions and 296 deletions

View file

@ -128,6 +128,21 @@ void mbedtls_mpi_mod_raw_mul(mbedtls_mpi_uint *X,
N->rep.mont.mm, T);
}
MBEDTLS_STATIC_TESTABLE
int mbedtls_mpi_mod_raw_fix_quasi_reduction(mbedtls_mpi_uint *X,
const mbedtls_mpi_mod_modulus *N)
{
if (N->limbs == 0) {
return MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
}
mbedtls_mpi_uint c = mbedtls_mpi_core_sub(X, X, N->p, N->limbs);
(void) mbedtls_mpi_core_add_if(X, N->p, N->limbs, (unsigned) c);
return 0;
}
/* END MERGE SLOT 2 */
/* BEGIN MERGE SLOT 3 */