Converted .function file to c-like format and adapted generator code
diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function
index ce1cb7d..747abf1 100644
--- a/tests/suites/test_suite_aes.function
+++ b/tests/suites/test_suite_aes.function
@@ -1,13 +1,15 @@
-BEGIN_HEADER
+/* BEGIN_HEADER */
#include <polarssl/aes.h>
-END_HEADER
+/* END_HEADER */
-BEGIN_DEPENDENCIES
-depends_on:POLARSSL_AES_C
-END_DEPENDENCIES
+/* BEGIN_DEPENDENCIES
+ * depends_on:POLARSSL_AES_C
+ * END_DEPENDENCIES
+ */
-BEGIN_CASE
-aes_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:#setkey_result
+/* BEGIN_CASE */
+void aes_encrypt_ecb( char *hex_key_string, char *hex_src_string,
+ char *hex_dst_string, int setkey_result )
{
unsigned char key_str[100];
unsigned char src_str[100];
@@ -21,22 +23,23 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- key_len = unhexify( key_str, {hex_key_string} );
- unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, hex_key_string );
+ unhexify( src_str, hex_src_string );
- TEST_ASSERT( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == {setkey_result} );
- if( {setkey_result} == 0 )
+ TEST_ASSERT( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == setkey_result );
+ if( setkey_result == 0 )
{
TEST_ASSERT( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
hexify( dst_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-aes_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string:#setkey_result
+/* BEGIN_CASE */
+void aes_decrypt_ecb( char *hex_key_string, char *hex_src_string,
+ char *hex_dst_string, int setkey_result )
{
unsigned char key_str[100];
unsigned char src_str[100];
@@ -50,22 +53,24 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- key_len = unhexify( key_str, {hex_key_string} );
- unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, hex_key_string );
+ unhexify( src_str, hex_src_string );
- TEST_ASSERT( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == {setkey_result} );
- if( {setkey_result} == 0 )
+ TEST_ASSERT( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == setkey_result );
+ if( setkey_result == 0 )
{
TEST_ASSERT( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
hexify( dst_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-aes_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:#cbc_result
+/* BEGIN_CASE */
+void aes_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
+ char *hex_src_string, char *hex_dst_string,
+ int cbc_result )
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -81,23 +86,25 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- key_len = unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- data_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ data_len = unhexify( src_str, hex_src_string );
aes_setkey_enc( &ctx, key_str, key_len * 8 );
- TEST_ASSERT( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == {cbc_result} );
- if( {cbc_result} == 0 )
+ TEST_ASSERT( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == cbc_result );
+ if( cbc_result == 0 )
{
hexify( dst_str, output, data_len );
- TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-aes_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:#cbc_result
+/* BEGIN_CASE */
+void aes_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
+ char *hex_src_string, char *hex_dst_string,
+ int cbc_result )
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -113,23 +120,24 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- key_len = unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- data_len = unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ data_len = unhexify( src_str, hex_src_string );
aes_setkey_dec( &ctx, key_str, key_len * 8 );
- TEST_ASSERT( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == {cbc_result} );
- if( {cbc_result} == 0)
+ TEST_ASSERT( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == cbc_result );
+ if( cbc_result == 0)
{
hexify( dst_str, output, data_len );
- TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-aes_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
+/* BEGIN_CASE */
+void aes_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
+ char *hex_src_string, char *hex_dst_string )
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -146,20 +154,21 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- key_len = unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ unhexify( src_str, hex_src_string );
aes_setkey_enc( &ctx, key_str, key_len * 8 );
TEST_ASSERT( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
hexify( dst_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-aes_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
+/* BEGIN_CASE */
+void aes_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
+ char *hex_src_string, char *hex_dst_string )
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -176,21 +185,21 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- key_len = unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- unhexify( src_str, {hex_src_string} );
+ key_len = unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ unhexify( src_str, hex_src_string );
aes_setkey_enc( &ctx, key_str, key_len * 8 );
TEST_ASSERT( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
hexify( dst_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-aes_selftest:
+/* BEGIN_CASE */
+void aes_selftest()
{
TEST_ASSERT( aes_self_test( 0 ) == 0 );
}
-END_CASE
+/* END_CASE */