diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function index f1be3cec2..d5eb1ef10 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 )