bignum_mod_raw: Added conversion methods for internal/public data representation

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
Hanno Becker 2022-08-09 14:45:53 +01:00 committed by Minos Galanakis
parent 9f1ecadc40
commit 5ad4a93596
2 changed files with 39 additions and 0 deletions

View File

@ -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 */

View File

@ -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 */