mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
binum_mod: Added mbedtls_mpi_mod_optred_modulus_setup()
.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
@ -171,6 +171,19 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
N->p = p;
|
||||
N->limbs = p_limbs;
|
||||
N->bits = mbedtls_mpi_core_bitlen(p, p_limbs);
|
||||
N->int_rep = MBEDTLS_MPI_MOD_REP_OPT_RED;
|
||||
N->rep.ored =ored ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mbedtls_mpi_mod_mul(mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_residue *B,
|
||||
|
@ -208,6 +208,23 @@ int mbedtls_mpi_mod_modulus_setup(mbedtls_mpi_mod_modulus *N,
|
||||
size_t p_limbs,
|
||||
mbedtls_mpi_mod_rep_selector int_rep);
|
||||
|
||||
/** Setup an optimised-reduction compatible modulus structure.
|
||||
*
|
||||
* \param[out] N The address of the modulus structure to populate.
|
||||
* \param[in] p The address of the limb array storing the value of \p N.
|
||||
* The memory pointed to by \p p will be used by \p N and must
|
||||
* 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.
|
||||
*
|
||||
* \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);
|
||||
|
||||
/** Free elements of a modulus structure.
|
||||
*
|
||||
* This function frees any memory allocated by mbedtls_mpi_mod_modulus_setup().
|
||||
|
Reference in New Issue
Block a user