mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 21:35:35 +00:00
Bignum Mod Tests: improve readabilty and style
Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
339b439906
commit
6ef582f2b8
@ -160,7 +160,7 @@ void mpi_mod_io_neg( char * input_N, data_t * buf, int ret )
|
|||||||
TEST_EQUAL( ret, mbedtls_mpi_mod_read( &r, &m, buf->x, buf->len, endian ) );
|
TEST_EQUAL( ret, mbedtls_mpi_mod_read( &r, &m, buf->x, buf->len, endian ) );
|
||||||
|
|
||||||
/* Test write overflow only when the representation is large and read is successful */
|
/* Test write overflow only when the representation is large and read is successful */
|
||||||
if (r.limbs > 1 && ret == 0)
|
if ( r.limbs > 1 && ret == 0 )
|
||||||
TEST_EQUAL( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL,
|
TEST_EQUAL( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL,
|
||||||
mbedtls_mpi_mod_write( &r, &m, buf->x, 1, endian ) );
|
mbedtls_mpi_mod_write( &r, &m, buf->x, 1, endian ) );
|
||||||
exit:
|
exit:
|
||||||
@ -185,14 +185,14 @@ void mpi_mod_io( char * input_N, data_t * input_A, int endian )
|
|||||||
/* Read inputs */
|
/* Read inputs */
|
||||||
TEST_EQUAL( 0, mbedtls_test_read_mpi_core( &N, &n_limbs, input_N ) );
|
TEST_EQUAL( 0, mbedtls_test_read_mpi_core( &N, &n_limbs, input_N ) );
|
||||||
n_bytes = n_limbs * sizeof( mbedtls_mpi_uint );
|
n_bytes = n_limbs * sizeof( mbedtls_mpi_uint );
|
||||||
a_bytes = input_A->len * sizeof( char );
|
a_bytes = input_A->len;
|
||||||
|
|
||||||
/* Allocate the memory for intermediate data structures */
|
/* Allocate the memory for intermediate data structures */
|
||||||
ASSERT_ALLOC( R, n_bytes );
|
ASSERT_ALLOC( R, n_bytes );
|
||||||
ASSERT_ALLOC( r_buff, a_bytes );
|
ASSERT_ALLOC( r_buff, a_bytes );
|
||||||
|
|
||||||
/* Test that input's size is not greater to modulo's */
|
/* Test that input's size is not greater to modulo's */
|
||||||
TEST_LE_U(a_bytes, n_bytes );
|
TEST_LE_U( a_bytes, n_bytes );
|
||||||
|
|
||||||
/* Init Structures */
|
/* Init Structures */
|
||||||
TEST_EQUAL( 0, mbedtls_mpi_mod_modulus_setup( &m, N, n_limbs,
|
TEST_EQUAL( 0, mbedtls_mpi_mod_modulus_setup( &m, N, n_limbs,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user