mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 02:05:39 +01:00
tests: aria: Prepare to char* to data_t* type change
In preparation of changing the type of some parameters of some test functions from `char *` to `data_t` to get rid of the calls to mbedtls_test_unhexify(): - Align the name of source data length local variable with the name of the local variable containing the source data, respectively src_str and src_str_len. - Change the type of length, index local variables from int to size_t. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
8dc0af2d4b
commit
e85a2c30bd
@ -214,7 +214,7 @@ void aria_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len, i;
|
||||
size_t key_len, src_str_len, i;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
@ -223,18 +223,18 @@ void aria_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 )
|
||||
== setkey_result );
|
||||
if( setkey_result == 0 )
|
||||
{
|
||||
for( i = 0; i < data_len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
for( i = 0; i < src_str_len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i )
|
||||
== 0 );
|
||||
}
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -253,7 +253,7 @@ void aria_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len, i;
|
||||
size_t key_len, src_str_len, i;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
@ -262,18 +262,18 @@ void aria_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 )
|
||||
== setkey_result );
|
||||
if( setkey_result == 0 )
|
||||
{
|
||||
for( i = 0; i < data_len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
for( i = 0; i < src_str_len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i )
|
||||
== 0 );
|
||||
}
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -294,7 +294,7 @@ void aria_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len;
|
||||
size_t key_len, src_str_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
@ -305,15 +305,15 @@ void aria_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
mbedtls_test_unhexify( iv_str, hex_iv_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_ENCRYPT, data_len,
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_ENCRYPT, src_str_len,
|
||||
iv_str, src_str, output )
|
||||
== cbc_result );
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -334,7 +334,7 @@ void aria_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len;
|
||||
size_t key_len, src_str_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
@ -345,15 +345,15 @@ void aria_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
mbedtls_test_unhexify( iv_str, hex_iv_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_DECRYPT, data_len,
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_DECRYPT, src_str_len,
|
||||
iv_str, src_str, output )
|
||||
== cbc_result );
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -375,7 +375,7 @@ void aria_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
size_t key_len, src_str_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
@ -386,14 +386,14 @@ void aria_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
mbedtls_test_unhexify( iv_str, hex_iv_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_ENCRYPT,
|
||||
data_len, &iv_offset, iv_str,
|
||||
src_str_len, &iv_offset, iv_str,
|
||||
src_str, output )
|
||||
== result );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -414,7 +414,7 @@ void aria_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
size_t key_len, src_str_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
@ -425,14 +425,14 @@ void aria_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
mbedtls_test_unhexify( iv_str, hex_iv_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_DECRYPT,
|
||||
data_len, &iv_offset, iv_str,
|
||||
src_str_len, &iv_offset, iv_str,
|
||||
src_str, output )
|
||||
== result );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -454,7 +454,7 @@ void aria_encrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
unsigned char blk[MBEDTLS_ARIA_BLOCKSIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
size_t key_len, src_str_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
@ -465,13 +465,13 @@ void aria_encrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
mbedtls_test_unhexify( iv_str, hex_iv_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str,
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, src_str_len, &iv_offset, iv_str,
|
||||
blk, src_str, output )
|
||||
== result );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -493,7 +493,7 @@ void aria_decrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
unsigned char blk[MBEDTLS_ARIA_BLOCKSIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
size_t key_len, src_str_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
@ -504,13 +504,13 @@ void aria_decrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
mbedtls_test_unhexify( iv_str, hex_iv_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
src_str_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str,
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, src_str_len, &iv_offset, iv_str,
|
||||
blk, src_str, output )
|
||||
== result );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user