diff --git a/library/bignum_mod.c b/library/bignum_mod.c index 70bb584b00..54d38bd681 100644 --- a/library/bignum_mod.c +++ b/library/bignum_mod.c @@ -88,7 +88,7 @@ void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *N) N->rep.mont.mm = 0; break; case MBEDTLS_MPI_MOD_REP_OPT_RED: - mbedtls_free(N->rep.ored); + N->rep.ored.modp = NULL; break; case MBEDTLS_MPI_MOD_REP_INVALID: break; @@ -166,10 +166,10 @@ int mbedtls_mpi_mod_modulus_setup(mbedtls_mpi_mod_modulus *N, int mbedtls_mpi_mod_optred_modulus_setup(mbedtls_mpi_mod_modulus *N, const mbedtls_mpi_uint *p, size_t p_limbs, - mbedtls_mpi_opt_red_struct *ored) + int (*modp)(mbedtls_mpi *)) { standard_modulus_setup(N, p, p_limbs, MBEDTLS_MPI_MOD_REP_OPT_RED); - N->rep.ored = ored; + N->rep.ored.modp = modp; return 0; } diff --git a/library/bignum_mod.h b/library/bignum_mod.h index a3512eb17c..c4b763f32a 100644 --- a/library/bignum_mod.h +++ b/library/bignum_mod.h @@ -214,14 +214,14 @@ int mbedtls_mpi_mod_modulus_setup(mbedtls_mpi_mod_modulus *N, * not be modified in any way until after * mbedtls_mpi_mod_modulus_free() is called. * \param p_limbs The number of limbs of \p p. - * \param ored The optimized reduction structure to use. \p p. + * \param modp A pointer to the optimised reduction function to use. \p p. * * \return \c 0 if successful. */ int mbedtls_mpi_mod_optred_modulus_setup(mbedtls_mpi_mod_modulus *N, const mbedtls_mpi_uint *p, size_t p_limbs, - mbedtls_mpi_opt_red_struct *ored); + int (*modp)(mbedtls_mpi *)); /** Free elements of a modulus structure. *