bignum_mod: Added a typedef for OPT_RED function pointer.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
diff --git a/library/bignum_mod.c b/library/bignum_mod.c
index 60a3c30..84f3896 100644
--- a/library/bignum_mod.c
+++ b/library/bignum_mod.c
@@ -166,8 +166,7 @@
int mbedtls_mpi_mod_optred_modulus_setup(mbedtls_mpi_mod_modulus *N,
const mbedtls_mpi_uint *p,
size_t p_limbs,
- int (*modp)(mbedtls_mpi_uint *X,
- size_t X_limbs))
+ mbedtls_mpi_modp_fn modp)
{
standard_modulus_setup(N, p, p_limbs, MBEDTLS_MPI_MOD_REP_OPT_RED);
N->rep.ored.modp = modp;
diff --git a/library/bignum_mod.h b/library/bignum_mod.h
index 87ee015..39e8fd2 100644
--- a/library/bignum_mod.h
+++ b/library/bignum_mod.h
@@ -99,10 +99,10 @@
/** Montgomery representation. */
MBEDTLS_MPI_MOD_REP_MONTGOMERY = 2,
/* Optimised reduction available. This indicates a coordinate modulus (P)
- * and one of the following available:
- * - MBEDTLS_ECP_NIST_OPTIM
- * - Kobliz Curve.
- * - Fast Reduction Curve CURVE25519 or CURVE448. */
+ * and one or more of the following have been configured:
+ * - A nist curve (MBEDTLS_ECP_DP_SECPXXXR1_ENABLED) & MBEDTLS_ECP_NIST_OPTIM.
+ * - A Kobliz Curve.
+ * - A Fast Reduction Curve CURVE25519 or CURVE448. */
MBEDTLS_MPI_MOD_REP_OPT_RED,
} mbedtls_mpi_mod_rep_selector;
@@ -124,9 +124,10 @@
mbedtls_mpi_uint mm; /* Montgomery const for -N^{-1} mod 2^{ciL} */
} mbedtls_mpi_mont_struct;
+typedef int (*mbedtls_mpi_modp_fn)(mbedtls_mpi_uint *X, size_t X_limbs);
+
typedef struct {
- int (*modp)(mbedtls_mpi_uint *X,
- size_t X_limbs); /* The optimised reduction function pointer */
+ mbedtls_mpi_modp_fn modp; /* The optimised reduction function pointer */
} mbedtls_mpi_opt_red_struct;
typedef struct {
@@ -223,8 +224,7 @@
int mbedtls_mpi_mod_optred_modulus_setup(mbedtls_mpi_mod_modulus *N,
const mbedtls_mpi_uint *p,
size_t p_limbs,
- int (*modp)(mbedtls_mpi_uint *X,
- size_t X_limbs));
+ mbedtls_mpi_modp_fn modp);
/** Free elements of a modulus structure.
*
diff --git a/library/ecp_curves.c b/library/ecp_curves.c
index cb94196..e161fd4 100644
--- a/library/ecp_curves.c
+++ b/library/ecp_curves.c
@@ -5833,7 +5833,7 @@
const mbedtls_ecp_group_id id,
const mbedtls_ecp_modulus_type ctype)
{
- int (*modp)(mbedtls_mpi_uint *X, size_t X_limbs) = NULL;
+ mbedtls_mpi_modp_fn modp = NULL;
mbedtls_mpi_uint *p = NULL;
size_t p_limbs;