mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-05 19:35:48 +03:00
Functions to convert raw residues to/from the modulus representation
Test cases will be generated automatically by a subsequent commit. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@@ -176,6 +176,36 @@ void mbedtls_mpi_mod_raw_add( mbedtls_mpi_uint *X,
|
||||
|
||||
/* BEGIN MERGE SLOT 6 */
|
||||
|
||||
int mbedtls_mpi_mod_raw_canonical_to_modulus_rep(
|
||||
mbedtls_mpi_uint *X,
|
||||
const mbedtls_mpi_mod_modulus *N )
|
||||
{
|
||||
switch( N->int_rep )
|
||||
{
|
||||
case MBEDTLS_MPI_MOD_REP_MONTGOMERY:
|
||||
return( mbedtls_mpi_mod_raw_to_mont_rep( X, N ) );
|
||||
case MBEDTLS_MPI_MOD_REP_OPT_RED:
|
||||
return( 0 );
|
||||
default:
|
||||
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
|
||||
}
|
||||
}
|
||||
|
||||
int mbedtls_mpi_mod_raw_modulus_to_canonical_rep(
|
||||
mbedtls_mpi_uint *X,
|
||||
const mbedtls_mpi_mod_modulus *N )
|
||||
{
|
||||
switch( N->int_rep )
|
||||
{
|
||||
case MBEDTLS_MPI_MOD_REP_MONTGOMERY:
|
||||
return( mbedtls_mpi_mod_raw_from_mont_rep( X, N ) );
|
||||
case MBEDTLS_MPI_MOD_REP_OPT_RED:
|
||||
return( 0 );
|
||||
default:
|
||||
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
|
||||
}
|
||||
}
|
||||
|
||||
int mbedtls_mpi_mod_raw_random( mbedtls_mpi_uint *X,
|
||||
mbedtls_mpi_uint min,
|
||||
const mbedtls_mpi_mod_modulus *N,
|
||||
|
Reference in New Issue
Block a user