Skip to content

Commit

Permalink
tests: suites: Remove hex in name of variables of type data_t
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ronald-cron-arm committed Jul 1, 2020
1 parent ab500cb commit ac6ae35
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 258 deletions.
48 changes: 20 additions & 28 deletions tests/suites/test_suite_aes.function
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand All @@ -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;
Expand All @@ -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:
Expand All @@ -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];
Expand All @@ -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:
Expand All @@ -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];
Expand All @@ -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:
Expand Down Expand Up @@ -236,7 +232,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;
Expand All @@ -249,8 +245,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 );
Expand All @@ -259,7 +254,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;
Expand All @@ -272,8 +267,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 );
Expand All @@ -282,7 +276,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;
Expand All @@ -294,9 +288,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 );
Expand All @@ -305,7 +298,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;
Expand All @@ -317,9 +310,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 );
Expand Down
11 changes: 5 additions & 6 deletions tests/suites/test_suite_arc4.function
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 );
Expand Down
47 changes: 19 additions & 28 deletions tests/suites/test_suite_blowfish.function
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand All @@ -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;
Expand All @@ -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:
Expand All @@ -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];
Expand All @@ -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:
Expand All @@ -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];
Expand All @@ -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:
Expand All @@ -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;
Expand All @@ -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 );
Expand All @@ -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;
Expand All @@ -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 );
Expand All @@ -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];
Expand All @@ -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 );
Expand Down
Loading

0 comments on commit ac6ae35

Please sign in to comment.