mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-14 01:26:49 +00:00
Bignum Mod: move init before any goto
Test macros have goto instructions to the end where everything is freed. We need to call init before that happens to make calling free functions safe. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
ee530cc644
commit
799eaeefdb
@ -130,15 +130,15 @@ void mpi_mod_io_neg( )
|
||||
|
||||
const size_t buff_bytes = 1024;
|
||||
|
||||
mbedtls_mpi_mod_modulus_init( &m );
|
||||
mbedtls_mpi_mod_modulus_init( &m2 );
|
||||
|
||||
/* Allocate the memory for intermediate data structures */
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi_core( &N, &n_limbs, hex_modulus_single ) );
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi_core( &R, &r_limbs, hex_residue_single ) );
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi_core( &N2, &n2_limbs, hex_modulus_multi ) );
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi_core( &R2, &r2_limbs, hex_residue_multi ) );
|
||||
|
||||
mbedtls_mpi_mod_modulus_init( &m );
|
||||
mbedtls_mpi_mod_modulus_init( &m2 );
|
||||
|
||||
/* Allocate more than required space on buffer so we can test for input_r > mpi */
|
||||
ASSERT_ALLOC( r_buff, buff_bytes );
|
||||
memset( r_buff, 0x1, 1 );
|
||||
@ -218,6 +218,8 @@ void mpi_mod_io( char * input_N, data_t * input_A, int endian )
|
||||
mbedtls_mpi_mod_residue r;
|
||||
size_t n_limbs, n_bytes, a_bytes;
|
||||
|
||||
mbedtls_mpi_mod_modulus_init( &m );
|
||||
|
||||
/* Read inputs */
|
||||
TEST_EQUAL( 0, mbedtls_test_read_mpi_core( &N, &n_limbs, input_N ) );
|
||||
n_bytes = n_limbs * sizeof( mbedtls_mpi_uint );
|
||||
@ -231,7 +233,6 @@ void mpi_mod_io( char * input_N, data_t * input_A, int endian )
|
||||
TEST_LE_U(a_bytes, n_bytes );
|
||||
|
||||
/* Init Structures */
|
||||
mbedtls_mpi_mod_modulus_init( &m );
|
||||
TEST_EQUAL( 0, mbedtls_mpi_mod_modulus_setup( &m, N, n_limbs,
|
||||
MBEDTLS_MPI_MOD_REP_MONTGOMERY ) );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user