mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
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:
@@ -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 */
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* \file ecp_internal.h
|
||||
* \file bignum_mod_raw_invasive.h
|
||||
*
|
||||
* \brief Function declarations for internal functions of elliptic curve
|
||||
* point arithmetic.
|
||||
* \brief Function declarations for invasive functions of Low-level
|
||||
* modular bignum.
|
||||
*/
|
||||
/**
|
||||
* Copyright The Mbed TLS Contributors
|
||||
@@ -21,8 +21,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MBEDTLS_ECP_INTERNAL_H
|
||||
#define MBEDTLS_ECP_INTERNAL_H
|
||||
#ifndef MBEDTLS_BIGNUM_MOD_RAW_INVASIVE_H
|
||||
#define MBEDTLS_BIGNUM_MOD_RAW_INVASIVE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "mbedtls/bignum.h"
|
||||
@@ -40,7 +40,8 @@
|
||||
* \return \c 0 if successful.
|
||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p N is invalid.
|
||||
*/
|
||||
int mbedtls_ecp_quasi_reduction(mbedtls_mpi_uint *X,
|
||||
const mbedtls_mpi_mod_modulus *N);
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_mpi_mod_raw_fix_quasi_reduction(mbedtls_mpi_uint *X,
|
||||
const mbedtls_mpi_mod_modulus *N);
|
||||
|
||||
#endif /* MBEDTLS_ECP_INTERNAL_H */
|
||||
#endif /* MBEDTLS_BIGNUM_MOD_RAW_INVASIVE_H */
|
@@ -79,7 +79,6 @@
|
||||
|
||||
#include "bn_mul.h"
|
||||
#include "ecp_invasive.h"
|
||||
#include "ecp_internal.h"
|
||||
#include "bignum_core.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -1031,20 +1030,6 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mbedtls_ecp_quasi_reduction(mbedtls_mpi_uint *X,
|
||||
const mbedtls_mpi_mod_modulus *N)
|
||||
{
|
||||
if (N->limbs == 0) {
|
||||
return MBEDTLS_ERR_ECP_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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fast mod-p functions expect their argument to be in the 0..p^2 range.
|
||||
*
|
||||
|
Reference in New Issue
Block a user