mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 21:05:37 +01:00
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>
This commit is contained in:
parent
afbe3ee87c
commit
b2eb38d391
@ -315,13 +315,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;
|
||||
@ -331,14 +331,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 );
|
||||
@ -352,12 +353,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 )
|
||||
|
Loading…
Reference in New Issue
Block a user