Rename variables to have unambiguous names
Use bytes instead of len in the variable names. Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
4086de667d
commit
ffb4aa0ddc
1 changed files with 82 additions and 82 deletions
|
@ -766,16 +766,16 @@ exit:
|
|||
/* BEGIN_CASE */
|
||||
void mpi_core_cond_assign( data_t * input_X,
|
||||
data_t * input_Y,
|
||||
int input_len )
|
||||
int input_bytes )
|
||||
{
|
||||
mbedtls_mpi_uint *X = NULL;
|
||||
mbedtls_mpi_uint *Y = NULL;
|
||||
size_t limbs_X = CHARS_TO_LIMBS( input_X->len );
|
||||
size_t limbs_Y = CHARS_TO_LIMBS( input_Y->len );
|
||||
size_t limbs = limbs_X;
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_len );
|
||||
size_t len = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_len = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_bytes );
|
||||
size_t bytes = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_bytes = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
|
||||
TEST_EQUAL( limbs_X, limbs_Y );
|
||||
TEST_ASSERT( copy_limbs <= limbs );
|
||||
|
@ -790,34 +790,34 @@ void mpi_core_cond_assign( data_t * input_X,
|
|||
== 0 );
|
||||
|
||||
/* condition is false */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_core_cond_assign( X, Y, copy_limbs, 0 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
TEST_ASSERT( memcmp( X, Y, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( X, Y, bytes ) != 0 );
|
||||
|
||||
/* condition is true */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_core_cond_assign( X, Y, copy_limbs, 1 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
/* Check if the given length is copied even it is smaller
|
||||
than the length of the given MPIs. */
|
||||
than the bytesgth of the given MPIs. */
|
||||
if( copy_limbs != limbs )
|
||||
{
|
||||
ASSERT_COMPARE( X, copy_len, Y, copy_len );
|
||||
TEST_ASSERT( memcmp( X, Y, len ) != 0 );
|
||||
ASSERT_COMPARE( X, copy_bytes, Y, copy_bytes );
|
||||
TEST_ASSERT( memcmp( X, Y, bytes ) != 0 );
|
||||
}
|
||||
else
|
||||
ASSERT_COMPARE( X, len, Y, len );
|
||||
ASSERT_COMPARE( X, bytes, Y, bytes );
|
||||
|
||||
exit:
|
||||
mbedtls_free( X );
|
||||
|
@ -828,7 +828,7 @@ exit:
|
|||
/* BEGIN_CASE */
|
||||
void mpi_core_cond_swap( data_t * input_X,
|
||||
data_t * input_Y,
|
||||
int input_len )
|
||||
int input_bytes )
|
||||
{
|
||||
mbedtls_mpi_uint *tmp_X = NULL;
|
||||
mbedtls_mpi_uint *tmp_Y = NULL;
|
||||
|
@ -837,9 +837,9 @@ void mpi_core_cond_swap( data_t * input_X,
|
|||
size_t limbs_X = CHARS_TO_LIMBS( input_X->len );
|
||||
size_t limbs_Y = CHARS_TO_LIMBS( input_Y->len );
|
||||
size_t limbs = limbs_X;
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_len );
|
||||
size_t len = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_len = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_bytes );
|
||||
size_t bytes = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_bytes = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
|
||||
TEST_EQUAL( limbs_X, limbs_Y );
|
||||
TEST_ASSERT( copy_limbs <= limbs );
|
||||
|
@ -851,50 +851,50 @@ void mpi_core_cond_swap( data_t * input_X,
|
|||
input_X->x, input_X->len )
|
||||
== 0 );
|
||||
ASSERT_ALLOC( X, limbs );
|
||||
memcpy( X, tmp_X, len );
|
||||
memcpy( X, tmp_X, bytes );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_core_read_be( tmp_Y, limbs,
|
||||
input_Y->x, input_Y->len )
|
||||
== 0 );
|
||||
ASSERT_ALLOC( Y, limbs );
|
||||
memcpy( Y, tmp_Y, len );
|
||||
memcpy( Y, tmp_Y, bytes );
|
||||
|
||||
/* condition is false */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_core_cond_swap( X, Y, copy_limbs, 0 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
ASSERT_COMPARE( X, len, tmp_X, len );
|
||||
ASSERT_COMPARE( Y, len, tmp_Y, len );
|
||||
ASSERT_COMPARE( X, bytes, tmp_X, bytes );
|
||||
ASSERT_COMPARE( Y, bytes, tmp_Y, bytes );
|
||||
|
||||
/* condition is true */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_core_cond_swap( X, Y, copy_limbs, 1 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
/* Check if the given length is copied even it is smaller
|
||||
than the length of the given MPIs. */
|
||||
if( copy_limbs != limbs )
|
||||
{
|
||||
ASSERT_COMPARE( X, copy_len, tmp_Y, copy_len );
|
||||
ASSERT_COMPARE( Y, copy_len, tmp_X, copy_len );
|
||||
TEST_ASSERT( memcmp( X, tmp_X, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( X, tmp_Y, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_X, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_Y, len ) != 0 );
|
||||
ASSERT_COMPARE( X, copy_bytes, tmp_Y, copy_bytes );
|
||||
ASSERT_COMPARE( Y, copy_bytes, tmp_X, copy_bytes );
|
||||
TEST_ASSERT( memcmp( X, tmp_X, bytes ) != 0 );
|
||||
TEST_ASSERT( memcmp( X, tmp_Y, bytes ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_X, bytes ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_Y, bytes ) != 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT_COMPARE( X, len, tmp_Y, len );
|
||||
ASSERT_COMPARE( Y, len, tmp_X, len );
|
||||
ASSERT_COMPARE( X, bytes, tmp_Y, bytes );
|
||||
ASSERT_COMPARE( Y, bytes, tmp_X, bytes );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -908,7 +908,7 @@ exit:
|
|||
/* BEGIN_CASE */
|
||||
void mpi_mod_raw_cond_assign( data_t * input_X,
|
||||
data_t * input_Y,
|
||||
int input_len )
|
||||
int input_bytes )
|
||||
{
|
||||
mbedtls_mpi_uint *X = NULL;
|
||||
mbedtls_mpi_uint *Y = NULL;
|
||||
|
@ -917,9 +917,9 @@ void mpi_mod_raw_cond_assign( data_t * input_X,
|
|||
size_t limbs_X = CHARS_TO_LIMBS( input_X->len );
|
||||
size_t limbs_Y = CHARS_TO_LIMBS( input_Y->len );
|
||||
size_t limbs = limbs_X;
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_len );
|
||||
size_t len = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_len = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_bytes );
|
||||
size_t bytes = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_bytes = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
|
||||
TEST_EQUAL( limbs_X, limbs_Y );
|
||||
TEST_ASSERT( copy_limbs <= limbs );
|
||||
|
@ -944,34 +944,34 @@ void mpi_mod_raw_cond_assign( data_t * input_X,
|
|||
== 0 );
|
||||
|
||||
/* condition is false */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_mod_raw_cond_assign( X, Y, &m, 0 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
TEST_ASSERT( memcmp( X, Y, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( X, Y, bytes ) != 0 );
|
||||
|
||||
/* condition is true */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_mod_raw_cond_assign( X, Y, &m, 1 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
/* Check if the given length is copied even it is smaller
|
||||
than the length of the given MPIs. */
|
||||
if( copy_limbs != limbs )
|
||||
{
|
||||
ASSERT_COMPARE( X, copy_len, Y, copy_len );
|
||||
TEST_ASSERT( memcmp( X, Y, len ) != 0 );
|
||||
ASSERT_COMPARE( X, copy_bytes, Y, copy_bytes );
|
||||
TEST_ASSERT( memcmp( X, Y, bytes ) != 0 );
|
||||
}
|
||||
else
|
||||
ASSERT_COMPARE( X, len, Y, len );
|
||||
ASSERT_COMPARE( X, bytes, Y, bytes );
|
||||
|
||||
exit:
|
||||
mbedtls_free( X );
|
||||
|
@ -985,7 +985,7 @@ exit:
|
|||
/* BEGIN_CASE */
|
||||
void mpi_mod_raw_cond_swap( data_t * input_X,
|
||||
data_t * input_Y,
|
||||
int input_len )
|
||||
int input_bytes )
|
||||
{
|
||||
mbedtls_mpi_uint *tmp_X = NULL;
|
||||
mbedtls_mpi_uint *tmp_Y = NULL;
|
||||
|
@ -996,9 +996,9 @@ void mpi_mod_raw_cond_swap( data_t * input_X,
|
|||
size_t limbs_X = CHARS_TO_LIMBS( input_X->len );
|
||||
size_t limbs_Y = CHARS_TO_LIMBS( input_Y->len );
|
||||
size_t limbs = limbs_X;
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_len );
|
||||
size_t len = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_len = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_limbs = CHARS_TO_LIMBS( input_bytes );
|
||||
size_t bytes = limbs * sizeof( mbedtls_mpi_uint );
|
||||
size_t copy_bytes = copy_limbs * sizeof( mbedtls_mpi_uint );
|
||||
|
||||
TEST_EQUAL( limbs_X, limbs_Y );
|
||||
TEST_ASSERT( copy_limbs <= limbs );
|
||||
|
@ -1017,49 +1017,49 @@ void mpi_mod_raw_cond_swap( data_t * input_X,
|
|||
TEST_ASSERT( mbedtls_mpi_core_read_be( tmp_X, limbs, input_X->x, input_X->len )
|
||||
== 0 );
|
||||
ASSERT_ALLOC( X, limbs );
|
||||
memcpy( X, tmp_X, len );
|
||||
memcpy( X, tmp_X, bytes );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_core_read_be( tmp_Y, limbs, input_Y->x, input_Y->len )
|
||||
== 0 );
|
||||
ASSERT_ALLOC( Y, len );
|
||||
memcpy( Y, tmp_Y, len );
|
||||
ASSERT_ALLOC( Y, bytes );
|
||||
memcpy( Y, tmp_Y, bytes );
|
||||
|
||||
/* condition is false */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_mod_raw_cond_swap( X, Y, &m, 0 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
ASSERT_COMPARE( X, len, tmp_X, len );
|
||||
ASSERT_COMPARE( Y, len, tmp_Y, len );
|
||||
ASSERT_COMPARE( X, bytes, tmp_X, bytes );
|
||||
ASSERT_COMPARE( Y, bytes, tmp_Y, bytes );
|
||||
|
||||
/* condition is true */
|
||||
TEST_CF_SECRET( X, len );
|
||||
TEST_CF_SECRET( Y, len );
|
||||
TEST_CF_SECRET( X, bytes );
|
||||
TEST_CF_SECRET( Y, bytes );
|
||||
|
||||
mbedtls_mpi_mod_raw_cond_swap( X, Y, &m, 1 );
|
||||
|
||||
TEST_CF_PUBLIC( X, len );
|
||||
TEST_CF_PUBLIC( Y, len );
|
||||
TEST_CF_PUBLIC( X, bytes );
|
||||
TEST_CF_PUBLIC( Y, bytes );
|
||||
|
||||
/* Check if the given length is copied even it is smaller
|
||||
than the length of the given MPIs. */
|
||||
if( copy_limbs != limbs )
|
||||
{
|
||||
ASSERT_COMPARE( X, copy_len, tmp_Y, copy_len );
|
||||
ASSERT_COMPARE( Y, copy_len, tmp_X, copy_len );
|
||||
TEST_ASSERT( memcmp( X, tmp_X, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( X, tmp_Y, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_X, len ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_Y, len ) != 0 );
|
||||
ASSERT_COMPARE( X, copy_bytes, tmp_Y, copy_bytes );
|
||||
ASSERT_COMPARE( Y, copy_bytes, tmp_X, copy_bytes );
|
||||
TEST_ASSERT( memcmp( X, tmp_X, bytes ) != 0 );
|
||||
TEST_ASSERT( memcmp( X, tmp_Y, bytes ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_X, bytes ) != 0 );
|
||||
TEST_ASSERT( memcmp( Y, tmp_Y, bytes ) != 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT_COMPARE( X, len, tmp_Y, len );
|
||||
ASSERT_COMPARE( Y, len, tmp_X, len );
|
||||
ASSERT_COMPARE( X, bytes, tmp_Y, bytes );
|
||||
ASSERT_COMPARE( Y, bytes, tmp_X, bytes );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
|
Loading…
Reference in a new issue