tests: Add mbedtls_test_ prefix to hexcmp()

Add mbedtls_test_ prefix to hexcmp() test helper
function.

Command to change *.function files:
find . -name "*.function" -exec awk -i inplace \
    '{sub(/hexcmp\>/,"mbedtls_test_&")}1' {} \;

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2020-06-10 11:03:08 +02:00
parent f73ab008d2
commit de70b165a4
19 changed files with 82 additions and 80 deletions

View file

@ -79,6 +79,7 @@ unsigned char *mbedtls_test_zero_alloc( size_t len );
*/
unsigned char *mbedtls_test_unhexify_alloc( const char *ibuf, size_t *olen );
int hexcmp( uint8_t * a, uint8_t * b, uint32_t a_len, uint32_t b_len );
int mbedtls_test_hexcmp( uint8_t * a, uint8_t * b,
uint32_t a_len, uint32_t b_len );
#endif /* TEST_HELPERS_H */

View file

@ -130,7 +130,8 @@ unsigned char *mbedtls_test_unhexify_alloc( const char *ibuf, size_t *olen )
return( obuf );
}
int hexcmp( uint8_t * a, uint8_t * b, uint32_t a_len, uint32_t b_len )
int mbedtls_test_hexcmp( uint8_t * a, uint8_t * b,
uint32_t a_len, uint32_t b_len )
{
int ret = 0;
uint32_t i = 0;

View file

@ -23,7 +23,7 @@ void aes_encrypt_ecb( data_t * key_str, data_t * src_str,
{
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_ENCRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
}
exit:
@ -47,7 +47,7 @@ void aes_decrypt_ecb( data_t * key_str, data_t * src_str,
{
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_DECRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
}
exit:
@ -72,7 +72,7 @@ void aes_encrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -96,7 +96,7 @@ void aes_decrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0)
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -243,7 +243,7 @@ void aes_encrypt_cfb128( data_t * key_str, data_t * iv_str,
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
exit:
mbedtls_aes_free( &ctx );
@ -265,7 +265,7 @@ void aes_decrypt_cfb128( data_t * key_str, data_t * iv_str,
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
exit:
mbedtls_aes_free( &ctx );
@ -286,7 +286,7 @@ void aes_encrypt_cfb8( data_t * key_str, data_t * iv_str,
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
exit:
mbedtls_aes_free( &ctx );
@ -307,7 +307,7 @@ void aes_decrypt_cfb8( data_t * key_str, data_t * iv_str,
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
exit:
mbedtls_aes_free( &ctx );

View file

@ -21,7 +21,7 @@ void mbedtls_arc4_crypt( data_t * src_str, data_t * key_str,
mbedtls_arc4_setup(&ctx, key_str->x, key_str->len);
TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_str->len, src_str->x, dst_str ) == 0 );
TEST_ASSERT( hexcmp( dst_str, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( dst_str, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
exit:
mbedtls_arc4_free( &ctx );

View file

@ -181,7 +181,7 @@ void blowfish_encrypt_ecb( data_t * key_str, data_t * src_str,
{
TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
}
exit:
@ -205,7 +205,7 @@ void blowfish_decrypt_ecb( data_t * key_str, data_t * src_str,
{
TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
}
exit:
@ -231,7 +231,7 @@ void blowfish_encrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -256,7 +256,7 @@ void blowfish_decrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0)
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -280,7 +280,7 @@ void blowfish_encrypt_cfb64( data_t * key_str, data_t * iv_str,
mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str->len, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
exit:
mbedtls_blowfish_free( &ctx );
@ -303,7 +303,7 @@ void blowfish_decrypt_cfb64( data_t * key_str, data_t * iv_str,
mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str->len, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
exit:
mbedtls_blowfish_free( &ctx );
@ -327,7 +327,7 @@ void blowfish_encrypt_ctr( data_t * key_str, data_t * iv_str,
mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_blowfish_crypt_ctr( &ctx, src_str->len, &iv_offset, iv_str->x, stream_str, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
exit:
mbedtls_blowfish_free( &ctx );

View file

@ -189,7 +189,7 @@ void camellia_encrypt_ecb( data_t * key_str, data_t * src_str,
{
TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
}
exit:
@ -213,7 +213,7 @@ void camellia_decrypt_ecb( data_t * key_str, data_t * src_str,
{
TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_DECRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
}
exit:
@ -238,7 +238,7 @@ void camellia_encrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -263,7 +263,7 @@ void camellia_decrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -287,7 +287,7 @@ void camellia_encrypt_cfb128( data_t * key_str, data_t * iv_str,
mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
exit:
mbedtls_camellia_free( &ctx );
@ -310,7 +310,7 @@ void camellia_decrypt_cfb128( data_t * key_str, data_t * iv_str,
mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
exit:
mbedtls_camellia_free( &ctx );

View file

@ -28,7 +28,7 @@ void des_encrypt_ecb( data_t * key_str, data_t * src_str,
mbedtls_des_setkey_enc( &ctx, key_str->x );
TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
exit:
mbedtls_des_free( &ctx );
@ -49,7 +49,7 @@ void des_decrypt_ecb( data_t * key_str, data_t * src_str,
mbedtls_des_setkey_dec( &ctx, key_str->x );
TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
exit:
mbedtls_des_free( &ctx );
@ -73,7 +73,7 @@ void des_encrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -98,7 +98,7 @@ void des_decrypt_cbc( data_t * key_str, data_t * iv_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -126,7 +126,7 @@ void des3_encrypt_ecb( int key_count, data_t * key_str,
TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
exit:
mbedtls_des3_free( &ctx );
@ -153,7 +153,7 @@ void des3_decrypt_ecb( int key_count, data_t * key_str,
TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
exit:
mbedtls_des3_free( &ctx );
@ -184,7 +184,7 @@ void des3_encrypt_cbc( int key_count, data_t * key_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:
@ -216,7 +216,7 @@ void des3_decrypt_cbc( int key_count, data_t * key_str,
if( cbc_result == 0 )
{
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
exit:

View file

@ -806,7 +806,7 @@ void ecp_write_binary( int id, char * x, char * y, char * z, int format,
if( ret == 0 )
{
TEST_ASSERT( hexcmp( buf, out->x, olen, out->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( buf, out->x, olen, out->len ) == 0 );
}
exit:

View file

@ -55,8 +55,8 @@ void gcm_encrypt_and_tag( int cipher_id, data_t * key_str,
{
TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT, src_str->len, iv_str->x, iv_str->len, add_str->x, add_str->len, src_str->x, output, tag_len, tag_output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( hexcmp( tag_output, hex_tag_string->x, tag_len, hex_tag_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( tag_output, hex_tag_string->x, tag_len, hex_tag_string->len ) == 0 );
}
exit:
@ -94,7 +94,7 @@ void gcm_decrypt_and_verify( int cipher_id, data_t * key_str,
{
TEST_ASSERT( ret == 0 );
TEST_ASSERT( hexcmp( output, pt_result->x, src_str->len, pt_result->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, pt_result->x, src_str->len, pt_result->len ) == 0 );
}
}

View file

@ -145,7 +145,7 @@ void md_text( char * text_md_name, char * text_src_string,
TEST_ASSERT ( 0 == mbedtls_md( md_info, src_str, strlen( (char *) src_str ), output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -167,7 +167,7 @@ void md_hex( char * text_md_name, data_t * src_str,
TEST_ASSERT ( 0 == mbedtls_md( md_info, src_str->x, src_str->len, output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x,
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -208,7 +208,7 @@ void md_text_multi( char * text_md_name, char * text_src_string,
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str + halfway, len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x,
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
mbedtls_md_get_size( md_info ), hex_hash_string->len) == 0 );
/* Test clone */
@ -216,7 +216,7 @@ void md_text_multi( char * text_md_name, char * text_src_string,
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str + halfway, len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx_copy, output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
exit:
mbedtls_md_free( &ctx );
@ -255,14 +255,14 @@ void md_hex_multi( char * text_md_name, data_t * src_str,
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str->x + halfway, src_str->len - halfway) );
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
/* Test clone */
memset( output, 0x00, 100 );
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str->x + halfway, src_str->len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx_copy, output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
exit:
mbedtls_md_free( &ctx );
@ -289,7 +289,7 @@ void mbedtls_md_hmac( char * text_md_name, int trunc_size,
TEST_ASSERT ( mbedtls_md_hmac( md_info, key_str->x, key_str->len, src_str->x, src_str->len, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -321,7 +321,7 @@ void md_hmac_multi( char * text_md_name, int trunc_size, data_t * key_str,
TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x + halfway, src_str->len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
/* Test again, for reset() */
memset( output, 0x00, 100 );
@ -331,7 +331,7 @@ void md_hmac_multi( char * text_md_name, int trunc_size, data_t * key_str,
TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x + halfway, src_str->len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
exit:
mbedtls_md_free( &ctx );
@ -355,6 +355,6 @@ void mbedtls_md_file( char * text_md_name, char * filename,
TEST_ASSERT( mbedtls_md_file( md_info, filename, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
}
/* END_CASE */

View file

@ -20,7 +20,7 @@ void md2_text( char * text_src_string, data_t * hex_hash_string )
ret = mbedtls_md2_ret( src_str, strlen( (char *) src_str ), output );
TEST_ASSERT( ret == 0 ) ;
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -39,7 +39,7 @@ void md4_text( char * text_src_string, data_t * hex_hash_string )
ret = mbedtls_md4_ret( src_str, strlen( (char *) src_str ), output );
TEST_ASSERT( ret == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -58,7 +58,7 @@ void md5_text( char * text_src_string, data_t * hex_hash_string )
ret = mbedtls_md5_ret( src_str, strlen( (char *) src_str ), output );
TEST_ASSERT( ret == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -77,7 +77,7 @@ void ripemd160_text( char * text_src_string, data_t * hex_hash_string )
ret = mbedtls_ripemd160_ret( src_str, strlen( (char *) src_str ), output );
TEST_ASSERT( ret == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
}
/* END_CASE */

View file

@ -373,7 +373,7 @@ void mbedtls_mpi_write_binary( int radix_X, char * input_X,
if( result == 0)
{
TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
}
exit:
@ -404,7 +404,7 @@ void mbedtls_mpi_write_binary_le( int radix_X, char * input_X,
if( result == 0)
{
TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
}
exit:
@ -438,7 +438,7 @@ void mbedtls_mpi_read_file( int radix_X, char * input_file,
TEST_ASSERT( mbedtls_mpi_write_binary( &X, buf, buflen ) == 0 );
TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
}
exit:

View file

@ -37,7 +37,7 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N,
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result );
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:
@ -87,7 +87,7 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P,
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, output, 1000 ) == result );
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, output_len, result_hex_str->len) == 0 );
}
}
@ -287,7 +287,7 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:

View file

@ -37,7 +37,7 @@ void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char * input_N,
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result );
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:
@ -93,7 +93,7 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P,
sizeof( output ) ) == result );
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, output_len, result_hex_str->len ) == 0 );
}
}
@ -146,7 +146,7 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char * input_P, int radix_Q,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:

View file

@ -24,7 +24,7 @@ void pbkdf2_hmac( int hash, data_t * pw_str, data_t * salt_str,
TEST_ASSERT( mbedtls_pkcs5_pbkdf2_hmac( &ctx, pw_str->x, pw_str->len, salt_str->x, salt_str->len,
it_cnt, key_len, key ) == 0 );
TEST_ASSERT( hexcmp( key, result_key_string->x, key_len, result_key_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( key, result_key_string->x, key_len, result_key_string->len ) == 0 );
exit:
mbedtls_md_free( &ctx );

View file

@ -506,7 +506,7 @@ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:
@ -586,7 +586,7 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
output ) == 0 );
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
#if defined(MBEDTLS_PKCS1_V15)
/* For PKCS#1 v1.5, there is an alternative way to generate signatures */
@ -608,7 +608,7 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
if( res == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
}
#endif /* MBEDTLS_PKCS1_V15 */
@ -714,7 +714,7 @@ void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:
@ -752,7 +752,7 @@ void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:
@ -800,7 +800,7 @@ void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, output_len, result_hex_str->len ) == 0 );
}
exit:
@ -837,7 +837,7 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
/* And now with the copy */
@ -852,7 +852,7 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
exit:
@ -902,7 +902,7 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
}
}
@ -919,7 +919,7 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
if( result == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx2.len, result_hex_str->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, ctx2.len, result_hex_str->len ) == 0 );
}
exit:

View file

@ -61,7 +61,7 @@ void mbedtls_sha1( data_t * src_str, data_t * hex_hash_string )
TEST_ASSERT( mbedtls_sha1_ret( src_str->x, src_str->len, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 20, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, 20, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -131,7 +131,7 @@ void sha224( data_t * src_str, data_t * hex_hash_string )
TEST_ASSERT( mbedtls_sha256_ret( src_str->x, src_str->len, output, 1 ) == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 28, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, 28, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -145,7 +145,7 @@ void mbedtls_sha256( data_t * src_str, data_t * hex_hash_string )
TEST_ASSERT( mbedtls_sha256_ret( src_str->x, src_str->len, output, 0 ) == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 32, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, 32, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -215,7 +215,7 @@ void sha384( data_t * src_str, data_t * hex_hash_string )
TEST_ASSERT( mbedtls_sha512_ret( src_str->x, src_str->len, output, 1 ) == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 48, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, 48, hex_hash_string->len ) == 0 );
}
/* END_CASE */
@ -229,7 +229,7 @@ void mbedtls_sha512( data_t * src_str, data_t * hex_hash_string )
TEST_ASSERT( mbedtls_sha512_ret( src_str->x, src_str->len, output, 0 ) == 0 );
TEST_ASSERT( hexcmp( output, hex_hash_string->x, 64, hex_hash_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, 64, hex_hash_string->len ) == 0 );
}
/* END_CASE */

View file

@ -3424,7 +3424,7 @@ void ssl_tls_prf( int type, data_t * secret, data_t * random,
if( exp_ret == 0 )
{
TEST_ASSERT( hexcmp( output, result_hex_str->x,
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
result_hex_str->len, result_hex_str->len ) == 0 );
}
exit:

View file

@ -20,7 +20,7 @@ void xtea_encrypt_ecb( data_t * key_str, data_t * src_str,
mbedtls_xtea_setup( &ctx, key_str->x );
TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
}
/* END_CASE */
@ -37,7 +37,7 @@ void xtea_decrypt_ecb( data_t * key_str, data_t * src_str,
mbedtls_xtea_setup( &ctx, key_str->x );
TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_DECRYPT, src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
}
/* END_CASE */
@ -55,7 +55,7 @@ void xtea_encrypt_cbc( data_t * key_str, data_t * iv_str,
TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str->len, iv_str->x,
src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
/* END_CASE */
@ -73,7 +73,7 @@ void xtea_decrypt_cbc( data_t * key_str, data_t * iv_str,
TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_DECRYPT, src_str->len, iv_str->x,
src_str->x, output ) == 0 );
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
}
/* END_CASE */