diff --git a/library/bignum_mod_raw.c b/library/bignum_mod_raw.c index a329e86dfb..97f7731c4c 100644 --- a/library/bignum_mod_raw.c +++ b/library/bignum_mod_raw.c @@ -127,7 +127,28 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A, /* END MERGE SLOT 6 */ /* BEGIN MERGE SLOT 7 */ +int mbedtls_mpi_mod_raw_conv_inv( mbedtls_mpi_uint *X, + const mbedtls_mpi_mod_modulus *modulus ) +{ + mbedtls_mpi_uint one = 1; + mbedtls_mpi T; + mbedtls_mpi_init( &T ); + mbedtls_mpi_core_montmul( X, X, &one, 1, m->p, m->limbs, + m->rep.mont.mm, T.p ); + mbedtls_mpi_free( &T ); + return( 0 ); +} +int mbedtls_mpi_mod_raw_conv_fwd( mbedtls_mpi_uint *X, + const mbedtls_mpi_mod_modulus *modulus ) +{ + mbedtls_mpi T; + mbedtls_mpi_init( &T ); + mbedtls_mpi_core_montmul( X, X, m->rep.mont.rr, 1, m->p, m->limbs, + m->rep.mont.mm, T.p ); + mbedtls_mpi_free( &T ); + return( 0 ); +} /* END MERGE SLOT 7 */ /* BEGIN MERGE SLOT 8 */ diff --git a/library/bignum_mod_raw.h b/library/bignum_mod_raw.h index 30648d3cc4..38415f415f 100644 --- a/library/bignum_mod_raw.h +++ b/library/bignum_mod_raw.h @@ -163,7 +163,25 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A, /* END MERGE SLOT 6 */ /* BEGIN MERGE SLOT 7 */ +/** Convert from internal to public (little endian) data presentation + * + * \param X The address of the MPI. + * \param m The address of a modulus. + * + * \return \c 0 if successful. + */ +int mbedtls_mpi_mod_raw_conv_inv( mbedtls_mpi_uint *X, + const mbedtls_mpi_mod_modulus *modulus ); +/** Convert from public (little endian) to internal data presentation. + * + * \param X The address of the MPI. + * \param m The address of a modulus. + * + * \return \c 0 if successful. + */ +int mbedtls_mpi_mod_raw_conv_fwd( mbedtls_mpi_uint *X, + const mbedtls_mpi_mod_modulus *modulus ); /* END MERGE SLOT 7 */ /* BEGIN MERGE SLOT 8 */