mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 16:14:20 +01:00
tests: Add mbedtls_test_ prefix to *hexify functions
Add mbedtls_test_ prefix to hexify() and unhexify() test helper functions. Command to change *.function files: find . -name "*.function" -exec awk -i inplace \ '{sub(/(un|)hexify\>/,"mbedtls_test_&")}1' {} \; Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
e9c09f1efc
commit
72d628f7f5
@ -53,8 +53,10 @@
|
||||
int mbedtls_test_platform_setup( void );
|
||||
void mbedtls_test_platform_teardown( void );
|
||||
|
||||
int unhexify( unsigned char *obuf, const char *ibuf );
|
||||
void hexify( unsigned char *obuf, const unsigned char *ibuf, int len );
|
||||
int mbedtls_test_unhexify( unsigned char *obuf, const char *ibuf );
|
||||
void mbedtls_test_hexify( unsigned char *obuf,
|
||||
const unsigned char *ibuf,
|
||||
int len );
|
||||
|
||||
/**
|
||||
* Allocate and zeroize a buffer.
|
||||
|
@ -40,7 +40,7 @@ void mbedtls_test_platform_teardown( void )
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
}
|
||||
|
||||
int unhexify( unsigned char *obuf, const char *ibuf )
|
||||
int mbedtls_test_unhexify( unsigned char *obuf, const char *ibuf )
|
||||
{
|
||||
unsigned char c, c2;
|
||||
int len = strlen( ibuf ) / 2;
|
||||
@ -74,7 +74,9 @@ int unhexify( unsigned char *obuf, const char *ibuf )
|
||||
return len;
|
||||
}
|
||||
|
||||
void hexify( unsigned char *obuf, const unsigned char *ibuf, int len )
|
||||
void mbedtls_test_hexify( unsigned char *obuf,
|
||||
const unsigned char *ibuf,
|
||||
int len )
|
||||
{
|
||||
unsigned char l, h;
|
||||
|
||||
@ -123,7 +125,7 @@ unsigned char *unhexify_alloc( const char *ibuf, size_t *olen )
|
||||
obuf = mbedtls_calloc( 1, *olen );
|
||||
TEST_HELPER_ASSERT( obuf != NULL );
|
||||
|
||||
(void) unhexify( obuf, ibuf );
|
||||
(void) mbedtls_test_unhexify( obuf, ibuf );
|
||||
|
||||
return( obuf );
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ static int convert_params( size_t cnt , char ** params , int * int_params_store
|
||||
{
|
||||
if ( verify_string( &val ) == 0 )
|
||||
{
|
||||
*int_params_store = unhexify( (unsigned char *) val, val );
|
||||
*int_params_store = mbedtls_test_unhexify( (unsigned char *) val, val );
|
||||
*out++ = val;
|
||||
*out++ = (char *)(int_params_store++);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ uint8_t receive_byte()
|
||||
c[1] = greentea_getc();
|
||||
c[2] = '\0';
|
||||
|
||||
TEST_HELPER_ASSERT( unhexify( &byte, c ) != 2 );
|
||||
TEST_HELPER_ASSERT( mbedtls_test_unhexify( &byte, c ) != 2 );
|
||||
return( byte );
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ uint32_t receive_uint32()
|
||||
};
|
||||
const uint8_t c[9] = { c_be[6], c_be[7], c_be[4], c_be[5], c_be[2],
|
||||
c_be[3], c_be[0], c_be[1], '\0' };
|
||||
TEST_HELPER_ASSERT( unhexify( (uint8_t*)&value, c ) != 8 );
|
||||
TEST_HELPER_ASSERT( mbedtls_test_unhexify( (uint8_t*)&value, c ) != 8 );
|
||||
return( value );
|
||||
}
|
||||
|
||||
|
@ -340,9 +340,9 @@ void aes_encrypt_ofb( int fragment_size, char *hex_key_string,
|
||||
TEST_ASSERT( strlen( hex_src_string ) <= ( 64 * 2 ) );
|
||||
TEST_ASSERT( strlen( hex_dst_string ) <= ( 64 * 2 ) );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
in_buffer_len = unhexify( src_str, hex_src_string );
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
mbedtls_test_unhexify( iv_str, hex_iv_string );
|
||||
in_buffer_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
|
||||
src_str_next = src_str;
|
||||
@ -352,7 +352,7 @@ 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 );
|
||||
|
||||
hexify( dst_str, output, fragment_size );
|
||||
mbedtls_test_hexify( dst_str, output, fragment_size );
|
||||
TEST_ASSERT( strncmp( (char *) dst_str, hex_dst_string,
|
||||
( 2 * fragment_size ) ) == 0 );
|
||||
|
||||
|
@ -222,8 +222,8 @@ void aria_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 )
|
||||
== setkey_result );
|
||||
@ -234,7 +234,7 @@ void aria_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i )
|
||||
== 0 );
|
||||
}
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -261,8 +261,8 @@ void aria_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
data_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 )
|
||||
== setkey_result );
|
||||
@ -273,7 +273,7 @@ void aria_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i )
|
||||
== 0 );
|
||||
}
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -303,9 +303,9 @@ void aria_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_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 );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_ENCRYPT, data_len,
|
||||
@ -313,7 +313,7 @@ void aria_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
== cbc_result );
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -343,9 +343,9 @@ void aria_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_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 );
|
||||
|
||||
mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_DECRYPT, data_len,
|
||||
@ -353,7 +353,7 @@ void aria_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
== cbc_result );
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -384,16 +384,16 @@ void aria_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_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 );
|
||||
|
||||
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, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -423,16 +423,16 @@ void aria_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_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 );
|
||||
|
||||
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, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -463,15 +463,15 @@ void aria_encrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_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 );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str,
|
||||
blk, src_str, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -502,15 +502,15 @@ void aria_decrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_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 );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str,
|
||||
blk, src_str, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, data_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
|
@ -218,12 +218,12 @@ void mbedtls_ccm_star_encrypt_and_tag( int cipher_id,
|
||||
memset( source_address, 0x00, sizeof( source_address ) );
|
||||
memset( frame_counter, 0x00, sizeof( frame_counter ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
add_len = unhexify( add, add_hex );
|
||||
result_len = unhexify( result, result_hex );
|
||||
source_address_len = unhexify( source_address, source_address_hex );
|
||||
frame_counter_len = unhexify( frame_counter, frame_counter_hex );
|
||||
key_len = mbedtls_test_unhexify( key, key_hex );
|
||||
msg_len = mbedtls_test_unhexify( msg, msg_hex );
|
||||
add_len = mbedtls_test_unhexify( add, add_hex );
|
||||
result_len = mbedtls_test_unhexify( result, result_hex );
|
||||
source_address_len = mbedtls_test_unhexify( source_address, source_address_hex );
|
||||
frame_counter_len = mbedtls_test_unhexify( frame_counter, frame_counter_hex );
|
||||
|
||||
if( sec_level % 4 == 0)
|
||||
tag_len = 0;
|
||||
@ -286,12 +286,12 @@ void mbedtls_ccm_star_auth_decrypt( int cipher_id,
|
||||
memset( frame_counter, 0x00, sizeof( frame_counter ) );
|
||||
memset( tag, 0x00, sizeof( tag ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
add_len = unhexify( add, add_hex );
|
||||
result_len = unhexify( result, result_hex );
|
||||
source_address_len = unhexify( source_address, source_address_hex );
|
||||
frame_counter_len = unhexify( frame_counter, frame_counter_hex );
|
||||
key_len = mbedtls_test_unhexify( key, key_hex );
|
||||
msg_len = mbedtls_test_unhexify( msg, msg_hex );
|
||||
add_len = mbedtls_test_unhexify( add, add_hex );
|
||||
result_len = mbedtls_test_unhexify( result, result_hex );
|
||||
source_address_len = mbedtls_test_unhexify( source_address, source_address_hex );
|
||||
frame_counter_len = mbedtls_test_unhexify( frame_counter, frame_counter_hex );
|
||||
|
||||
if( sec_level % 4 == 0)
|
||||
tag_len = 0;
|
||||
|
@ -31,10 +31,10 @@ void chacha20_crypt( char *hex_key_string,
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
nonce_len = unhexify( nonce_str, hex_nonce_string );
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
dst_len = unhexify( dst_str, hex_dst_string );
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
nonce_len = mbedtls_test_unhexify( nonce_str, hex_nonce_string );
|
||||
src_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
dst_len = mbedtls_test_unhexify( dst_str, hex_dst_string );
|
||||
|
||||
TEST_ASSERT( src_len == dst_len );
|
||||
TEST_ASSERT( key_len == 32U );
|
||||
@ -45,7 +45,7 @@ void chacha20_crypt( char *hex_key_string,
|
||||
*/
|
||||
TEST_ASSERT( mbedtls_chacha20_crypt( key_str, nonce_str, counter, src_len, src_str, output ) == 0 );
|
||||
|
||||
hexify( dst_str, output, src_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_len );
|
||||
TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
/*
|
||||
@ -60,7 +60,7 @@ void chacha20_crypt( char *hex_key_string,
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_len, src_str, output ) == 0 );
|
||||
|
||||
hexify( dst_str, output, src_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_len );
|
||||
TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
/*
|
||||
@ -75,7 +75,7 @@ void chacha20_crypt( char *hex_key_string,
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, 1, src_str, output ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_len - 1, src_str + 1, output + 1 ) == 0 );
|
||||
|
||||
hexify( dst_str, output, src_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_len );
|
||||
TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
mbedtls_chacha20_free( &ctx );
|
||||
|
@ -33,12 +33,12 @@ void mbedtls_chachapoly_enc( char *hex_key_string, char *hex_nonce_string, char
|
||||
memset( output_str, 0x00, sizeof( output_str ) );
|
||||
memset( mac_str, 0x00, sizeof( mac_str ) );
|
||||
|
||||
aad_len = unhexify( aad_str, hex_aad_string );
|
||||
input_len = unhexify( input_str, hex_input_string );
|
||||
output_len = unhexify( output_str, hex_output_string );
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
nonce_len = unhexify( nonce_str, hex_nonce_string );
|
||||
mac_len = unhexify( mac_str, hex_mac_string );
|
||||
aad_len = mbedtls_test_unhexify( aad_str, hex_aad_string );
|
||||
input_len = mbedtls_test_unhexify( input_str, hex_input_string );
|
||||
output_len = mbedtls_test_unhexify( output_str, hex_output_string );
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
nonce_len = mbedtls_test_unhexify( nonce_str, hex_nonce_string );
|
||||
mac_len = mbedtls_test_unhexify( mac_str, hex_mac_string );
|
||||
|
||||
TEST_ASSERT( key_len == 32 );
|
||||
TEST_ASSERT( nonce_len == 12 );
|
||||
@ -87,12 +87,12 @@ void mbedtls_chachapoly_dec( char *hex_key_string, char *hex_nonce_string, char
|
||||
memset( output_str, 0x00, sizeof( output_str ) );
|
||||
memset( mac_str, 0x00, sizeof( mac_str ) );
|
||||
|
||||
aad_len = unhexify( aad_str, hex_aad_string );
|
||||
input_len = unhexify( input_str, hex_input_string );
|
||||
output_len = unhexify( output_str, hex_output_string );
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
nonce_len = unhexify( nonce_str, hex_nonce_string );
|
||||
mac_len = unhexify( mac_str, hex_mac_string );
|
||||
aad_len = mbedtls_test_unhexify( aad_str, hex_aad_string );
|
||||
input_len = mbedtls_test_unhexify( input_str, hex_input_string );
|
||||
output_len = mbedtls_test_unhexify( output_str, hex_output_string );
|
||||
key_len = mbedtls_test_unhexify( key_str, hex_key_string );
|
||||
nonce_len = mbedtls_test_unhexify( nonce_str, hex_nonce_string );
|
||||
mac_len = mbedtls_test_unhexify( mac_str, hex_mac_string );
|
||||
|
||||
TEST_ASSERT( key_len == 32 );
|
||||
TEST_ASSERT( nonce_len == 12 );
|
||||
|
@ -1161,15 +1161,15 @@ void test_vec_crypt( int cipher_id, int operation, char *hex_key,
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx,
|
||||
mbedtls_cipher_info_from_type( cipher_id ) ) );
|
||||
|
||||
key_len = unhexify( key, hex_key );
|
||||
inputlen = unhexify( input, hex_input );
|
||||
resultlen = unhexify( result, hex_result );
|
||||
key_len = mbedtls_test_unhexify( key, hex_key );
|
||||
inputlen = mbedtls_test_unhexify( input, hex_input );
|
||||
resultlen = mbedtls_test_unhexify( result, hex_result );
|
||||
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, operation ) );
|
||||
if( MBEDTLS_MODE_CBC == ctx.cipher_info->mode )
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, MBEDTLS_PADDING_NONE ) );
|
||||
|
||||
iv_len = unhexify( iv, hex_iv );
|
||||
iv_len = mbedtls_test_unhexify( iv, hex_iv );
|
||||
|
||||
TEST_ASSERT( finish_result == mbedtls_cipher_crypt( &ctx, iv_len ? iv : NULL,
|
||||
iv_len, input, inputlen,
|
||||
|
@ -359,13 +359,13 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
mbedtls_ecdh_init( &srv );
|
||||
mbedtls_ecdh_init( &cli );
|
||||
|
||||
z_len = unhexify( z, z_str );
|
||||
z_len = mbedtls_test_unhexify( z, z_str );
|
||||
|
||||
rnd_info_A.buf = rnd_buf_A;
|
||||
rnd_info_A.length = unhexify( rnd_buf_A, dA_str );
|
||||
rnd_info_A.length = mbedtls_test_unhexify( rnd_buf_A, dA_str );
|
||||
|
||||
rnd_info_B.buf = rnd_buf_B;
|
||||
rnd_info_B.length = unhexify( rnd_buf_B, dB_str );
|
||||
rnd_info_B.length = mbedtls_test_unhexify( rnd_buf_B, dB_str );
|
||||
|
||||
/* The ECDH context is not guaranteed ot have an mbedtls_ecp_group structure
|
||||
* in every configuration, therefore we load it separately. */
|
||||
|
@ -420,9 +420,9 @@ void ecdsa_read_restart( int id, char *k_str, char *h_str, char *s_str,
|
||||
mbedtls_ecdsa_init( &ctx );
|
||||
mbedtls_ecdsa_restart_init( &rs_ctx );
|
||||
|
||||
hash_len = unhexify(hash, h_str);
|
||||
sig_len = unhexify(sig, s_str);
|
||||
pk_len = unhexify(pk, k_str);
|
||||
hash_len = mbedtls_test_unhexify(hash, h_str);
|
||||
sig_len = mbedtls_test_unhexify(sig, s_str);
|
||||
pk_len = mbedtls_test_unhexify(pk, k_str);
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &ctx.grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_binary( &ctx.grp, &ctx.Q, pk, pk_len ) == 0 );
|
||||
@ -494,7 +494,7 @@ void ecdsa_write_restart( int id, char *d_str, int md_alg,
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &ctx.grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &ctx.d, 16, d_str ) == 0 );
|
||||
slen_check = unhexify( sig_check, sig_str );
|
||||
slen_check = mbedtls_test_unhexify( sig_check, sig_str );
|
||||
|
||||
md_info = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
|
@ -28,17 +28,17 @@ void test_hkdf( int md_alg, char *hex_ikm_string, char *hex_salt_string,
|
||||
const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md != NULL );
|
||||
|
||||
ikm_len = unhexify( ikm, hex_ikm_string );
|
||||
salt_len = unhexify( salt, hex_salt_string );
|
||||
info_len = unhexify( info, hex_info_string );
|
||||
okm_len = unhexify( expected_okm, hex_okm_string );
|
||||
ikm_len = mbedtls_test_unhexify( ikm, hex_ikm_string );
|
||||
salt_len = mbedtls_test_unhexify( salt, hex_salt_string );
|
||||
info_len = mbedtls_test_unhexify( info, hex_info_string );
|
||||
okm_len = mbedtls_test_unhexify( expected_okm, hex_okm_string );
|
||||
|
||||
ret = mbedtls_hkdf( md, salt, salt_len, ikm, ikm_len, info, info_len, okm,
|
||||
okm_len);
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
// Run hexify on it so that it looks nicer if the assertion fails
|
||||
hexify( okm_hex, okm, okm_len );
|
||||
// Run mbedtls_test_hexify on it so that it looks nicer if the assertion fails
|
||||
mbedtls_test_hexify( okm_hex, okm, okm_len );
|
||||
TEST_ASSERT( !strcmp( (char *)okm_hex, hex_okm_string ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -259,9 +259,9 @@ void mbedtls_nist_kw_wrap( int cipher_id, int mode,
|
||||
memset( msg, 0x00, sizeof( msg ) );
|
||||
memset( result, '+', sizeof( result ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
result_len = unhexify( expected_result, result_hex );
|
||||
key_len = mbedtls_test_unhexify( key, key_hex );
|
||||
msg_len = mbedtls_test_unhexify( msg, msg_hex );
|
||||
result_len = mbedtls_test_unhexify( expected_result, result_hex );
|
||||
output_len = sizeof( result );
|
||||
|
||||
TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id, key, key_len * 8, 1 )
|
||||
@ -306,9 +306,9 @@ void mbedtls_nist_kw_unwrap( int cipher_id, int mode,
|
||||
memset( result, '+', sizeof( result ) );
|
||||
memset( expected_result, 0x00, sizeof( expected_result ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
result_len = unhexify( expected_result, result_hex );
|
||||
key_len = mbedtls_test_unhexify( key, key_hex );
|
||||
msg_len = mbedtls_test_unhexify( msg, msg_hex );
|
||||
result_len = mbedtls_test_unhexify( expected_result, result_hex );
|
||||
output_len = sizeof( result );
|
||||
|
||||
TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id, key, key_len * 8, 0 )
|
||||
|
@ -841,7 +841,7 @@ void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str,
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &mbedtls_pk_ec( pub )->grp, grp_id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_string( &mbedtls_pk_ec( pub )->Q, 16, QX_str, QY_str ) == 0 );
|
||||
|
||||
slen_check = unhexify( sig_check, sig_str );
|
||||
slen_check = mbedtls_test_unhexify( sig_check, sig_str );
|
||||
|
||||
md_info = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
|
@ -23,15 +23,15 @@ void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( mac, 0x00, sizeof( mac ) );
|
||||
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
unhexify( key, hex_key_string );
|
||||
src_len = mbedtls_test_unhexify( src_str, hex_src_string );
|
||||
mbedtls_test_unhexify( key, hex_key_string );
|
||||
|
||||
/*
|
||||
* Test the integrated API
|
||||
*/
|
||||
TEST_ASSERT( mbedtls_poly1305_mac( key, src_str, src_len, mac ) == 0 );
|
||||
|
||||
hexify( mac_str, mac, 16 );
|
||||
mbedtls_test_hexify( mac_str, mac, 16 );
|
||||
TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 );
|
||||
|
||||
/*
|
||||
@ -45,7 +45,7 @@ void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src
|
||||
|
||||
TEST_ASSERT( mbedtls_poly1305_finish( &ctx, mac ) == 0 );
|
||||
|
||||
hexify( mac_str, mac, 16 );
|
||||
mbedtls_test_hexify( mac_str, mac, 16 );
|
||||
TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 );
|
||||
|
||||
/*
|
||||
@ -63,7 +63,7 @@ void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src
|
||||
|
||||
TEST_ASSERT( mbedtls_poly1305_finish( &ctx, mac ) == 0 );
|
||||
|
||||
hexify( mac_str, mac, 16 );
|
||||
mbedtls_test_hexify( mac_str, mac, 16 );
|
||||
TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 );
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src
|
||||
|
||||
TEST_ASSERT( mbedtls_poly1305_finish( &ctx, mac ) == 0 );
|
||||
|
||||
hexify( mac_str, mac, 16 );
|
||||
mbedtls_test_hexify( mac_str, mac, 16 );
|
||||
TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user