diff options
author | Ronald Cron <ronald.cron@arm.com> | 2020-06-25 13:57:05 +0200 |
---|---|---|
committer | Ronald Cron <ronald.cron@arm.com> | 2020-06-26 10:45:16 +0200 |
commit | df02eb00e00527179ce82471b973f3e2dae640e2 (patch) | |
tree | 91beea0291b6f8719a140a6a109363c0018bd954 /tests/suites/test_suite_aes.function | |
parent | 7370185ae357fbf0654725a6f63023614d35d3db (diff) | |
download | mbedtls-df02eb00e00527179ce82471b973f3e2dae640e2.zip mbedtls-df02eb00e00527179ce82471b973f3e2dae640e2.tar.gz mbedtls-df02eb00e00527179ce82471b973f3e2dae640e2.tar.bz2 |
tests: aes.ofb: Prepare to char* to data_t* type change
In preparation of changing the type of some parameters
of aes_encrypt_ofb() from `char *` to `data_t` to get rid
of the calls to mbedtls_test_unhexify():
- Change the name of parameters and local variables to
clarify which ones are related to the outputs of the
library functions under test and which ones are
related to the expected values of those outputs.
- Add assertion on fragment_size parameter
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Diffstat (limited to 'tests/suites/test_suite_aes.function')
-rw-r--r-- | tests/suites/test_suite_aes.function | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function index f1be3ce..d5eb1ef 100644 --- a/tests/suites/test_suite_aes.function +++ b/tests/suites/test_suite_aes.function @@ -329,13 +329,13 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_OFB */ void aes_encrypt_ofb( int fragment_size, char *hex_key_string, char *hex_iv_string, char *hex_src_string, - char *hex_dst_string ) + char *hex_expected_output_string ) { unsigned char key_str[32]; unsigned char iv_str[16]; unsigned char src_str[64]; - unsigned char dst_str[64]; unsigned char output[32]; + unsigned char output_string[65]; mbedtls_aes_context ctx; size_t iv_offset = 0; int in_buffer_len; @@ -345,14 +345,15 @@ void aes_encrypt_ofb( int fragment_size, char *hex_key_string, memset( key_str, 0x00, sizeof( key_str ) ); memset( iv_str, 0x00, sizeof( iv_str ) ); memset( src_str, 0x00, sizeof( src_str ) ); - memset( dst_str, 0x00, sizeof( dst_str ) ); memset( output, 0x00, sizeof( output ) ); + memset( output_string, 0x00, sizeof( output_string ) ); mbedtls_aes_init( &ctx ); + TEST_ASSERT( (size_t)fragment_size < sizeof( output ) ); TEST_ASSERT( strlen( hex_key_string ) <= ( 32 * 2 ) ); TEST_ASSERT( strlen( hex_iv_string ) <= ( 16 * 2 ) ); TEST_ASSERT( strlen( hex_src_string ) <= ( 64 * 2 ) ); - TEST_ASSERT( strlen( hex_dst_string ) <= ( 64 * 2 ) ); + TEST_ASSERT( strlen( hex_expected_output_string ) <= ( 64 * 2 ) ); key_len = mbedtls_test_unhexify( key_str, hex_key_string ); mbedtls_test_unhexify( iv_str, hex_iv_string ); @@ -366,12 +367,12 @@ void aes_encrypt_ofb( int fragment_size, char *hex_key_string, TEST_ASSERT( mbedtls_aes_crypt_ofb( &ctx, fragment_size, &iv_offset, iv_str, src_str_next, output ) == 0 ); - mbedtls_test_hexify( dst_str, output, fragment_size ); - TEST_ASSERT( strncmp( (char *) dst_str, hex_dst_string, + mbedtls_test_hexify( output_string, output, fragment_size ); + TEST_ASSERT( strncmp( (char *) output_string, hex_expected_output_string, ( 2 * fragment_size ) ) == 0 ); in_buffer_len -= fragment_size; - hex_dst_string += ( fragment_size * 2 ); + hex_expected_output_string += ( fragment_size * 2 ); src_str_next += fragment_size; if( in_buffer_len < fragment_size ) |