From aea41df25410f2c6eaab53239c9ad90f401ae949 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 26 Jun 2020 14:33:03 +0200 Subject: [PATCH] tests: suites: Remove `hex` in name of variables of type data_t Remove `hex` in name of variables of type data_t to reserve it for variables of type char* that are the hexadecimal representation of a data buffer. Signed-off-by: Ronald Cron --- tests/suites/test_suite_aes.function | 48 ++++++++----------- tests/suites/test_suite_arc4.function | 11 ++--- tests/suites/test_suite_blowfish.function | 47 ++++++++---------- tests/suites/test_suite_camellia.function | 36 ++++++-------- tests/suites/test_suite_ccm.function | 4 +- tests/suites/test_suite_des.function | 51 ++++++++------------ tests/suites/test_suite_gcm.function | 13 +++-- tests/suites/test_suite_md.function | 56 +++++++++++----------- tests/suites/test_suite_mdx.function | 28 +++++------ tests/suites/test_suite_pkcs1_v15.function | 19 ++++---- tests/suites/test_suite_pkcs1_v21.function | 18 +++---- tests/suites/test_suite_rsa.function | 54 ++++++++++----------- tests/suites/test_suite_shax.function | 25 ++++------ tests/suites/test_suite_x509parse.function | 14 +++--- tests/suites/test_suite_xtea.function | 25 ++++------ 15 files changed, 197 insertions(+), 252 deletions(-) diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function index 14babf4d0..c71959654 100644 --- a/tests/suites/test_suite_aes.function +++ b/tests/suites/test_suite_aes.function @@ -9,7 +9,7 @@ /* BEGIN_CASE */ void aes_encrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string, int setkey_result ) + data_t * dst, int setkey_result ) { unsigned char output[100]; mbedtls_aes_context ctx; @@ -23,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); } exit: @@ -34,7 +33,7 @@ exit: /* BEGIN_CASE */ void aes_decrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string, int setkey_result ) + data_t * dst, int setkey_result ) { unsigned char output[100]; mbedtls_aes_context ctx; @@ -48,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); } exit: @@ -59,7 +57,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void aes_encrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; @@ -74,9 +72,8 @@ void aes_encrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); } exit: @@ -86,7 +83,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void aes_decrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; @@ -100,9 +97,8 @@ void aes_decrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); } exit: @@ -234,7 +230,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void aes_encrypt_cfb128( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_aes_context ctx; @@ -247,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); exit: mbedtls_aes_free( &ctx ); @@ -257,7 +252,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void aes_decrypt_cfb128( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_aes_context ctx; @@ -270,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); exit: mbedtls_aes_free( &ctx ); @@ -280,7 +274,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void aes_encrypt_cfb8( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_aes_context ctx; @@ -292,9 +286,8 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); exit: mbedtls_aes_free( &ctx ); @@ -303,7 +296,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void aes_decrypt_cfb8( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_aes_context ctx; @@ -315,9 +308,8 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); exit: mbedtls_aes_free( &ctx ); diff --git a/tests/suites/test_suite_arc4.function b/tests/suites/test_suite_arc4.function index 9aa491382..c1e238665 100644 --- a/tests/suites/test_suite_arc4.function +++ b/tests/suites/test_suite_arc4.function @@ -8,8 +8,7 @@ */ /* BEGIN_CASE */ -void mbedtls_arc4_crypt( data_t * src_str, data_t * key_str, - data_t * hex_dst_string ) +void mbedtls_arc4_crypt( data_t * src_str, data_t * key_str, data_t * dst ) { unsigned char dst_str[1000]; mbedtls_arc4_context ctx; @@ -19,11 +18,11 @@ 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( mbedtls_arc4_crypt(&ctx, src_str->len, + src_str->x, dst_str ) == 0 ); - TEST_ASSERT( mbedtls_test_hexcmp( dst_str, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( dst_str, dst->x, + src_str->len, dst->len ) == 0 ); exit: mbedtls_arc4_free( &ctx ); diff --git a/tests/suites/test_suite_blowfish.function b/tests/suites/test_suite_blowfish.function index eb6891cad..f89353ce9 100644 --- a/tests/suites/test_suite_blowfish.function +++ b/tests/suites/test_suite_blowfish.function @@ -167,7 +167,7 @@ exit: /* BEGIN_CASE */ void blowfish_encrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string, int setkey_result ) + data_t * dst, int setkey_result ) { unsigned char output[100]; mbedtls_blowfish_context ctx; @@ -181,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); } exit: @@ -192,7 +191,7 @@ exit: /* BEGIN_CASE */ void blowfish_decrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string, int setkey_result ) + data_t * dst, int setkey_result ) { unsigned char output[100]; mbedtls_blowfish_context ctx; @@ -206,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); } exit: @@ -217,7 +215,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void blowfish_encrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; @@ -233,9 +231,8 @@ void blowfish_encrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); } exit: @@ -245,7 +242,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void blowfish_decrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; @@ -260,9 +257,8 @@ void blowfish_decrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); } exit: @@ -272,8 +268,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void blowfish_encrypt_cfb64( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string - ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_blowfish_context ctx; @@ -286,9 +281,8 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); exit: mbedtls_blowfish_free( &ctx ); @@ -297,8 +291,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void blowfish_decrypt_cfb64( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string - ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_blowfish_context ctx; @@ -311,9 +304,8 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); exit: mbedtls_blowfish_free( &ctx ); @@ -322,7 +314,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CTR */ void blowfish_encrypt_ctr( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char stream_str[100]; unsigned char output[100]; @@ -337,9 +329,8 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); exit: mbedtls_blowfish_free( &ctx ); diff --git a/tests/suites/test_suite_camellia.function b/tests/suites/test_suite_camellia.function index 4949feb88..312495c9a 100644 --- a/tests/suites/test_suite_camellia.function +++ b/tests/suites/test_suite_camellia.function @@ -175,7 +175,7 @@ exit: /* BEGIN_CASE */ void camellia_encrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string, int setkey_result ) + data_t * dst, int setkey_result ) { unsigned char output[100]; mbedtls_camellia_context ctx; @@ -189,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); } exit: @@ -200,7 +199,7 @@ exit: /* BEGIN_CASE */ void camellia_decrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string, int setkey_result ) + data_t * dst, int setkey_result ) { unsigned char output[100]; mbedtls_camellia_context ctx; @@ -214,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); } exit: @@ -225,8 +223,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void camellia_encrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, - int cbc_result ) + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; mbedtls_camellia_context ctx; @@ -240,9 +237,8 @@ void camellia_encrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); } exit: @@ -252,7 +248,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void camellia_decrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; @@ -267,9 +263,8 @@ void camellia_decrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); } exit: @@ -279,8 +274,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void camellia_encrypt_cfb128( data_t * key_str, data_t * iv_str, - data_t * src_str, - data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_camellia_context ctx; @@ -293,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); exit: mbedtls_camellia_free( &ctx ); @@ -304,7 +297,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ void camellia_decrypt_cfb128( data_t * key_str, data_t * iv_str, data_t * src_str, - data_t * hex_dst_string ) + data_t * dst ) { unsigned char output[100]; mbedtls_camellia_context ctx; @@ -317,8 +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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 16, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); exit: mbedtls_camellia_free( &ctx ); diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index a04583b7e..1bba53195 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -152,7 +152,7 @@ exit: void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, data_t * msg, data_t * iv, data_t * add, int tag_len, int result, - data_t * hex_msg ) + data_t * expected_msg ) { unsigned char tag[16]; mbedtls_ccm_context ctx; @@ -172,7 +172,7 @@ void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, if( result == 0 ) { - TEST_ASSERT( memcmp( msg->x, hex_msg->x, hex_msg->len ) == 0 ); + TEST_ASSERT( memcmp( msg->x, expected_msg->x, expected_msg->len ) == 0 ); } else { diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function index 625c87ab1..5b249355b 100644 --- a/tests/suites/test_suite_des.function +++ b/tests/suites/test_suite_des.function @@ -15,8 +15,7 @@ void des_check_weak( data_t * key, int ret ) /* END_CASE */ /* BEGIN_CASE */ -void des_encrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string ) +void des_encrypt_ecb( data_t * key_str, data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_des_context ctx; @@ -28,8 +27,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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); exit: mbedtls_des_free( &ctx ); @@ -37,8 +35,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void des_decrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string ) +void des_decrypt_ecb( data_t * key_str, data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_des_context ctx; @@ -50,8 +47,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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); exit: mbedtls_des_free( &ctx ); @@ -60,8 +56,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void des_encrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, - int cbc_result ) + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; mbedtls_des_context ctx; @@ -75,9 +70,8 @@ void des_encrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); } exit: @@ -87,7 +81,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void des_decrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string, + data_t * src_str, data_t * dst, int cbc_result ) { unsigned char output[100]; @@ -102,9 +96,8 @@ void des_decrypt_cbc( data_t * key_str, data_t * iv_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); } exit: @@ -114,7 +107,7 @@ exit: /* BEGIN_CASE */ void des3_encrypt_ecb( int key_count, data_t * key_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_des3_context ctx; @@ -132,8 +125,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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); exit: mbedtls_des3_free( &ctx ); @@ -142,7 +134,7 @@ exit: /* BEGIN_CASE */ void des3_decrypt_ecb( int key_count, data_t * key_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_des3_context ctx; @@ -160,8 +152,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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); exit: mbedtls_des3_free( &ctx ); @@ -171,7 +162,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void des3_encrypt_cbc( int key_count, data_t * key_str, data_t * iv_str, data_t * src_str, - data_t * hex_dst_string, int cbc_result ) + data_t * dst, int cbc_result ) { unsigned char output[100]; mbedtls_des3_context ctx; @@ -192,9 +183,8 @@ void des3_encrypt_cbc( int key_count, data_t * key_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); } exit: @@ -205,7 +195,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void des3_decrypt_cbc( int key_count, data_t * key_str, data_t * iv_str, data_t * src_str, - data_t * hex_dst_string, int cbc_result ) + data_t * dst, int cbc_result ) { unsigned char output[100]; mbedtls_des3_context ctx; @@ -226,9 +216,8 @@ void des3_decrypt_cbc( int key_count, data_t * key_str, if( cbc_result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, src_str->len, + dst->len ) == 0 ); } exit: diff --git a/tests/suites/test_suite_gcm.function b/tests/suites/test_suite_gcm.function index b28d918ba..9b7b0ee14 100644 --- a/tests/suites/test_suite_gcm.function +++ b/tests/suites/test_suite_gcm.function @@ -35,8 +35,8 @@ exit: /* BEGIN_CASE */ void gcm_encrypt_and_tag( int cipher_id, data_t * key_str, data_t * src_str, data_t * iv_str, - data_t * add_str, data_t * hex_dst_string, - int tag_len_bits, data_t * hex_tag_string, + data_t * add_str, data_t * dst, + int tag_len_bits, data_t * tag, int init_result ) { unsigned char output[128]; @@ -55,11 +55,10 @@ 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( 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 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( tag_output, tag->x, + tag_len, tag->len ) == 0 ); } exit: diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function index be5782902..d918ce3b9 100644 --- a/tests/suites/test_suite_md.function +++ b/tests/suites/test_suite_md.function @@ -127,7 +127,7 @@ void md_info( int md_type, char * md_name, int md_size ) /* BEGIN_CASE */ void md_text( char * text_md_name, char * text_src_string, - data_t * hex_hash_string ) + data_t * hash ) { char md_name[100]; unsigned char src_str[1000]; @@ -145,15 +145,14 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, mbedtls_md_get_size( md_info ), - hex_hash_string->len ) == 0 ); + hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ -void md_hex( char * text_md_name, data_t * src_str, - data_t * hex_hash_string ) +void md_hex( char * text_md_name, data_t * src_str, data_t * hash ) { char md_name[100]; unsigned char output[100]; @@ -169,15 +168,15 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, mbedtls_md_get_size( md_info ), - hex_hash_string->len ) == 0 ); + hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ void md_text_multi( char * text_md_name, char * text_src_string, - data_t * hex_hash_string ) + data_t * hash ) { char md_name[100]; unsigned char src_str[1000]; @@ -211,18 +210,18 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, mbedtls_md_get_size( md_info ), - hex_hash_string->len) == 0 ); + hash->len) == 0 ); /* Test clone */ memset( output, 0x00, 100 ); TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str + halfway, len - halfway ) ); TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx_copy, output ) ); - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, mbedtls_md_get_size( md_info ), - hex_hash_string->len ) == 0 ); + hash->len ) == 0 ); exit: mbedtls_md_free( &ctx ); @@ -231,8 +230,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void md_hex_multi( char * text_md_name, data_t * src_str, - data_t * hex_hash_string ) +void md_hex_multi( char * text_md_name, data_t * src_str, data_t * hash ) { char md_name[100]; unsigned char output[100]; @@ -261,18 +259,18 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, mbedtls_md_get_size( md_info ), - hex_hash_string->len ) == 0 ); + hash->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( mbedtls_test_hexcmp( output, hex_hash_string->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, mbedtls_md_get_size( md_info ), - hex_hash_string->len ) == 0 ); + hash->len ) == 0 ); exit: mbedtls_md_free( &ctx ); @@ -283,7 +281,7 @@ exit: /* BEGIN_CASE */ void mbedtls_md_hmac( char * text_md_name, int trunc_size, data_t * key_str, data_t * src_str, - data_t * hex_hash_string ) + data_t * hash ) { char md_name[100]; unsigned char output[100]; @@ -299,14 +297,14 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - trunc_size, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, + trunc_size, hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ void md_hmac_multi( char * text_md_name, int trunc_size, data_t * key_str, - data_t * src_str, data_t * hex_hash_string ) + data_t * src_str, data_t * hash ) { char md_name[100]; unsigned char output[100]; @@ -332,8 +330,8 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - trunc_size, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, + trunc_size, hash->len ) == 0 ); /* Test again, for reset() */ memset( output, 0x00, 100 ); @@ -343,8 +341,8 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - trunc_size, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, + trunc_size, hash->len ) == 0 ); exit: mbedtls_md_free( &ctx ); @@ -353,7 +351,7 @@ exit: /* BEGIN_CASE depends_on:MBEDTLS_FS_IO */ void mbedtls_md_file( char * text_md_name, char * filename, - data_t * hex_hash_string ) + data_t * hash ) { char md_name[100]; unsigned char output[100]; @@ -368,8 +366,8 @@ void mbedtls_md_file( char * text_md_name, char * filename, TEST_ASSERT( mbedtls_md_file( md_info, filename, output ) == 0 ); - TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, mbedtls_md_get_size( md_info ), - hex_hash_string->len ) == 0 ); + hash->len ) == 0 ); } /* END_CASE */ diff --git a/tests/suites/test_suite_mdx.function b/tests/suites/test_suite_mdx.function index ed2ae58b4..aa35c583e 100644 --- a/tests/suites/test_suite_mdx.function +++ b/tests/suites/test_suite_mdx.function @@ -6,7 +6,7 @@ /* END_HEADER */ /* BEGIN_CASE depends_on:MBEDTLS_MD2_C */ -void md2_text( char * text_src_string, data_t * hex_hash_string ) +void md2_text( char * text_src_string, data_t * hash ) { int ret; unsigned char src_str[100]; @@ -20,14 +20,13 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - sizeof output, - hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, + sizeof output, hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MD4_C */ -void md4_text( char * text_src_string, data_t * hex_hash_string ) +void md4_text( char * text_src_string, data_t * hash ) { int ret; unsigned char src_str[100]; @@ -41,14 +40,13 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - sizeof output, - hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, + sizeof output, hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MD5_C */ -void md5_text( char * text_src_string, data_t * hex_hash_string ) +void md5_text( char * text_src_string, data_t * hash ) { int ret; unsigned char src_str[100]; @@ -62,14 +60,13 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - sizeof output, - hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, + sizeof output, hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */ -void ripemd160_text( char * text_src_string, data_t * hex_hash_string ) +void ripemd160_text( char * text_src_string, data_t * hash ) { int ret; unsigned char src_str[100]; @@ -83,9 +80,8 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - sizeof output, - hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, + sizeof output, hash->len ) == 0 ); } /* END_CASE */ diff --git a/tests/suites/test_suite_pkcs1_v15.function b/tests/suites/test_suite_pkcs1_v15.function index 759d3a6a3..a1e11f7b4 100644 --- a/tests/suites/test_suite_pkcs1_v15.function +++ b/tests/suites/test_suite_pkcs1_v15.function @@ -12,7 +12,7 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N, int radix_E, char * input_E, int hash, data_t * message_str, data_t * rnd_buf, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char output[128]; mbedtls_rsa_context ctx; @@ -36,8 +36,8 @@ 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( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: @@ -50,7 +50,7 @@ exit: void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, char * input_E, - int hash, data_t * result_hex_str, + int hash, data_t * result_str, char * seed, data_t * message_str, int result ) { @@ -78,13 +78,12 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P, TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - 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( mbedtls_test_hexcmp( output, result_hex_str->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, output_len, - result_hex_str->len) == 0 ); + result_str->len) == 0 ); } exit: @@ -247,7 +246,7 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, char * input_E, int digest, int hash, data_t * message_str, data_t * rnd_buf, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char hash_result[MBEDTLS_MD_MAX_SIZE]; unsigned char output[128]; @@ -283,8 +282,8 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: diff --git a/tests/suites/test_suite_pkcs1_v21.function b/tests/suites/test_suite_pkcs1_v21.function index 4c0016d04..a4119a208 100644 --- a/tests/suites/test_suite_pkcs1_v21.function +++ b/tests/suites/test_suite_pkcs1_v21.function @@ -12,7 +12,7 @@ void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char * input_N, int radix_E, char * input_E, int hash, data_t * message_str, data_t * rnd_buf, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char output[256]; mbedtls_rsa_context ctx; @@ -36,8 +36,8 @@ 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( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: @@ -50,7 +50,7 @@ exit: void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, char * input_E, - int hash, data_t * result_hex_str, + int hash, data_t * result_str, char * seed, data_t * message_str, int result ) { @@ -85,9 +85,9 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P, sizeof( output ) ) == result ); if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, output_len, - result_hex_str->len ) == 0 ); + result_str->len ) == 0 ); } exit: @@ -102,7 +102,7 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, char * input_E, int digest, int hash, data_t * message_str, data_t * rnd_buf, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char hash_result[MBEDTLS_MD_MAX_SIZE]; unsigned char output[256]; @@ -139,8 +139,8 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char * input_P, int radix_Q, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function index 59d688dd7..f8a2dad0d 100644 --- a/tests/suites/test_suite_rsa.function +++ b/tests/suites/test_suite_rsa.function @@ -470,7 +470,7 @@ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode, int digest, int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, char * input_E, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char hash_result[MBEDTLS_MD_MAX_SIZE]; unsigned char output[256]; @@ -506,8 +506,8 @@ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: @@ -556,7 +556,7 @@ void rsa_pkcs1_sign_raw( data_t * hash_result, int padding_mode, int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, - char * input_E, data_t * result_hex_str ) + char * input_E, data_t * result_str ) { unsigned char output[256]; mbedtls_rsa_context ctx; @@ -587,8 +587,8 @@ void rsa_pkcs1_sign_raw( data_t * hash_result, output ) == 0 ); - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); #if defined(MBEDTLS_PKCS1_V15) /* For PKCS#1 v1.5, there is an alternative way to generate signatures */ @@ -610,9 +610,9 @@ void rsa_pkcs1_sign_raw( data_t * hash_result, if( res == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, ctx.len, - result_hex_str->len ) == 0 ); + result_str->len ) == 0 ); } } #endif /* MBEDTLS_PKCS1_V15 */ @@ -690,7 +690,7 @@ exit: void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode, int mod, int radix_N, char * input_N, int radix_E, char * input_E, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char output[256]; mbedtls_rsa_context ctx; @@ -718,8 +718,8 @@ void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: @@ -732,7 +732,7 @@ exit: void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode, int mod, int radix_N, char * input_N, int radix_E, char * input_E, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char output[256]; mbedtls_rsa_context ctx; @@ -757,8 +757,8 @@ void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: @@ -772,7 +772,7 @@ void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode, int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, char * input_E, - int max_output, data_t * result_hex_str, + int max_output, data_t * result_str, int result ) { unsigned char output[32]; @@ -806,9 +806,9 @@ void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, output_len, - result_hex_str->len ) == 0 ); + result_str->len ) == 0 ); } exit: @@ -821,7 +821,7 @@ exit: /* BEGIN_CASE */ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N, char * input_N, int radix_E, char * input_E, - data_t * result_hex_str, int result ) + data_t * result_str, int result ) { unsigned char output[256]; mbedtls_rsa_context ctx, ctx2; /* Also test mbedtls_rsa_copy() while at it */ @@ -845,8 +845,8 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } /* And now with the copy */ @@ -861,8 +861,8 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, - ctx.len, result_hex_str->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, + ctx.len, result_str->len ) == 0 ); } exit: @@ -876,7 +876,7 @@ exit: void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, - char * input_E, data_t * result_hex_str, + char * input_E, data_t * result_str, int result ) { unsigned char output[256]; @@ -912,9 +912,9 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, ctx.len, - result_hex_str->len ) == 0 ); + result_str->len ) == 0 ); } } @@ -931,9 +931,9 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P, if( result == 0 ) { - TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x, + TEST_ASSERT( mbedtls_test_hexcmp( output, result_str->x, ctx2.len, - result_hex_str->len ) == 0 ); + result_str->len ) == 0 ); } exit: diff --git a/tests/suites/test_suite_shax.function b/tests/suites/test_suite_shax.function index 64280098c..f3477ec78 100644 --- a/tests/suites/test_suite_shax.function +++ b/tests/suites/test_suite_shax.function @@ -52,7 +52,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */ -void mbedtls_sha1( data_t * src_str, data_t * hex_hash_string ) +void mbedtls_sha1( data_t * src_str, data_t * hash ) { unsigned char output[41]; @@ -61,8 +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( mbedtls_test_hexcmp( output, hex_hash_string->x, - 20, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, 20, hash->len ) == 0 ); } /* END_CASE */ @@ -123,7 +122,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */ -void sha224( data_t * src_str, data_t * hex_hash_string ) +void sha224( data_t * src_str, data_t * hash ) { unsigned char output[57]; @@ -132,13 +131,12 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - 28, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, 28, hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */ -void mbedtls_sha256( data_t * src_str, data_t * hex_hash_string ) +void mbedtls_sha256( data_t * src_str, data_t * hash ) { unsigned char output[65]; @@ -147,8 +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( mbedtls_test_hexcmp( output, hex_hash_string->x, - 32, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, 32, hash->len ) == 0 ); } /* END_CASE */ @@ -209,7 +206,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */ -void sha384( data_t * src_str, data_t * hex_hash_string ) +void sha384( data_t * src_str, data_t * hash ) { unsigned char output[97]; @@ -218,13 +215,12 @@ 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( mbedtls_test_hexcmp( output, hex_hash_string->x, - 48, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, 48, hash->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */ -void mbedtls_sha512( data_t * src_str, data_t * hex_hash_string ) +void mbedtls_sha512( data_t * src_str, data_t * hash ) { unsigned char output[129]; @@ -233,8 +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( mbedtls_test_hexcmp( output, hex_hash_string->x, - 64, hex_hash_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, 64, hash->len ) == 0 ); } /* END_CASE */ diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function index e6b1b4783..664aac7db 100644 --- a/tests/suites/test_suite_x509parse.function +++ b/tests/suites/test_suite_x509parse.function @@ -804,21 +804,21 @@ void x509_get_time( int tag, char * time_str, int ret, int year, int mon, /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT */ -void x509_parse_rsassa_pss_params( data_t * hex_params, int params_tag, +void x509_parse_rsassa_pss_params( data_t * params, int params_tag, int ref_msg_md, int ref_mgf_md, int ref_salt_len, int ref_ret ) { int my_ret; - mbedtls_x509_buf params; + mbedtls_x509_buf buf; mbedtls_md_type_t my_msg_md, my_mgf_md; int my_salt_len; - params.p = hex_params->x; - params.len = hex_params->len; - params.tag = params_tag; + buf.p = params->x; + buf.len = params->len; + buf.tag = params_tag; - my_ret = mbedtls_x509_get_rsassa_pss_params( ¶ms, &my_msg_md, &my_mgf_md, - &my_salt_len ); + my_ret = mbedtls_x509_get_rsassa_pss_params( &buf, &my_msg_md, &my_mgf_md, + &my_salt_len ); TEST_ASSERT( my_ret == ref_ret ); diff --git a/tests/suites/test_suite_xtea.function b/tests/suites/test_suite_xtea.function index f286e6735..1d5b29b8a 100644 --- a/tests/suites/test_suite_xtea.function +++ b/tests/suites/test_suite_xtea.function @@ -9,7 +9,7 @@ /* BEGIN_CASE */ void xtea_encrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string ) + data_t * dst ) { unsigned char output[100]; mbedtls_xtea_context ctx; @@ -20,14 +20,12 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ -void xtea_decrypt_ecb( data_t * key_str, data_t * src_str, - data_t * hex_dst_string ) +void xtea_decrypt_ecb( data_t * key_str, data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_xtea_context ctx; @@ -38,14 +36,13 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - 8, hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void xtea_encrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_xtea_context ctx; @@ -57,15 +54,14 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ void xtea_decrypt_cbc( data_t * key_str, data_t * iv_str, - data_t * src_str, data_t * hex_dst_string ) + data_t * src_str, data_t * dst ) { unsigned char output[100]; mbedtls_xtea_context ctx; @@ -77,9 +73,8 @@ 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( mbedtls_test_hexcmp( output, hex_dst_string->x, - src_str->len, - hex_dst_string->len ) == 0 ); + TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, + src_str->len, dst->len ) == 0 ); } /* END_CASE */