From 8c0eb9744ce3a8bc9cf7bb5c0fec21ccfc6d8cc3 Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Thu, 17 Nov 2022 08:48:12 +0000 Subject: [PATCH] Must call mbedtls_mpi_mod_modulus_init() before anything else in tests Signed-off-by: Tom Cosgrove --- tests/suites/test_suite_bignum_mod_raw.function | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/suites/test_suite_bignum_mod_raw.function b/tests/suites/test_suite_bignum_mod_raw.function index ff766b9dca..4adccce25b 100644 --- a/tests/suites/test_suite_bignum_mod_raw.function +++ b/tests/suites/test_suite_bignum_mod_raw.function @@ -117,10 +117,12 @@ void mpi_mod_raw_cond_assign( char * input_X, mbedtls_mpi_uint *X = NULL; mbedtls_mpi_uint *Y = NULL; mbedtls_mpi_uint *buff_m = NULL; - mbedtls_mpi_mod_modulus m; size_t limbs_X; size_t limbs_Y; + mbedtls_mpi_mod_modulus m; + mbedtls_mpi_mod_modulus_init( &m ); + TEST_EQUAL( mbedtls_test_read_mpi_core( &X, &limbs_X, input_X ), 0 ); TEST_EQUAL( mbedtls_test_read_mpi_core( &Y, &limbs_Y, input_Y ), 0 ); @@ -129,8 +131,6 @@ void mpi_mod_raw_cond_assign( char * input_X, size_t bytes = limbs * sizeof( mbedtls_mpi_uint ); size_t copy_bytes = copy_limbs * sizeof( mbedtls_mpi_uint ); - mbedtls_mpi_mod_modulus_init( &m ); - TEST_EQUAL( limbs_X, limbs_Y ); TEST_ASSERT( copy_limbs <= limbs ); @@ -190,10 +190,12 @@ void mpi_mod_raw_cond_swap( char * input_X, mbedtls_mpi_uint *X = NULL; mbedtls_mpi_uint *Y = NULL; mbedtls_mpi_uint *buff_m = NULL; - mbedtls_mpi_mod_modulus m; size_t limbs_X; size_t limbs_Y; + mbedtls_mpi_mod_modulus m; + mbedtls_mpi_mod_modulus_init( &m ); + TEST_EQUAL( mbedtls_test_read_mpi_core( &tmp_X, &limbs_X, input_X ), 0 ); TEST_EQUAL( mbedtls_test_read_mpi_core( &tmp_Y, &limbs_Y, input_Y ), 0 ); @@ -202,8 +204,6 @@ void mpi_mod_raw_cond_swap( char * input_X, size_t bytes = limbs * sizeof( mbedtls_mpi_uint ); size_t copy_bytes = copy_limbs * sizeof( mbedtls_mpi_uint ); - mbedtls_mpi_mod_modulus_init( &m ); - TEST_EQUAL( limbs_X, limbs_Y ); TEST_ASSERT( copy_limbs <= limbs );