bignum_tests: Added test for mbedtls_mpi_mod_raw_from_mont_rep()
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
parent
631b491cbf
commit
df070d660d
1 changed files with 38 additions and 0 deletions
|
@ -324,6 +324,44 @@ void mpi_mod_raw_to_mont_rep( char * input_N, char * input_A, char * input_X )
|
|||
/* Output is +ve (or zero) */
|
||||
TEST_EQUAL( 1, A.s );
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_mod_modulus_free( &m );
|
||||
mbedtls_mpi_free( &N );
|
||||
mbedtls_mpi_free( &A );
|
||||
mbedtls_mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mpi_mod_raw_from_mont_rep( char * input_N, char * input_A, char * input_X )
|
||||
{
|
||||
mbedtls_mpi N, A, X;
|
||||
mbedtls_mpi_mod_modulus m;
|
||||
|
||||
mbedtls_mpi_init( &N );
|
||||
mbedtls_mpi_init( &A );
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
/* Read inputs */
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi( &N, input_N ) );
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi( &A, input_A ) );
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi( &X, input_X ) );
|
||||
|
||||
/* All of the inputs are +ve (or zero) */
|
||||
TEST_EQUAL( 1, X.s );
|
||||
TEST_EQUAL( 1, A.s );
|
||||
|
||||
mbedtls_mpi_mod_modulus_init( &m );
|
||||
TEST_EQUAL( 0, mbedtls_mpi_mod_modulus_setup( &m, N.p, N.n, MBEDTLS_MPI_MOD_EXT_REP_BE, MBEDTLS_MPI_MOD_REP_MONTGOMERY ) );
|
||||
|
||||
TEST_EQUAL(0, mbedtls_mpi_mod_raw_from_mont_rep( A.p ,&m ) );
|
||||
|
||||
/* Calculated matches expected value */
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &A, &X ) == 0 );
|
||||
|
||||
/* Output is +ve (or zero) */
|
||||
TEST_EQUAL( 1, A.s );
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_mod_modulus_free( &m );
|
||||
mbedtls_mpi_free( &N );
|
||||
|
|
Loading…
Reference in a new issue