Converted .function file to c-like format and adapted generator code
diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function
index 7e1a993..865a467 100644
--- a/tests/suites/test_suite_des.function
+++ b/tests/suites/test_suite_des.function
@@ -1,13 +1,15 @@
-BEGIN_HEADER
+/* BEGIN_HEADER */
#include <polarssl/des.h>
-END_HEADER
+/* END_HEADER */
-BEGIN_DEPENDENCIES
-depends_on:POLARSSL_DES_C
-END_DEPENDENCIES
+/* BEGIN_DEPENDENCIES
+ * depends_on:POLARSSL_DES_C
+ * END_DEPENDENCIES
+ */
-BEGIN_CASE
-des_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
+/* BEGIN_CASE */
+void des_encrypt_ecb( char *hex_key_string, char *hex_src_string,
+ char *hex_dst_string )
{
unsigned char key_str[100];
unsigned char src_str[100];
@@ -20,19 +22,20 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( src_str, hex_src_string );
des_setkey_enc( &ctx, key_str );
TEST_ASSERT( des_crypt_ecb( &ctx, src_str, output ) == 0 );
hexify( dst_str, output, 8 );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
+/* BEGIN_CASE */
+void des_decrypt_ecb( char *hex_key_string, char *hex_src_string,
+ char *hex_dst_string )
{
unsigned char key_str[100];
unsigned char src_str[100];
@@ -45,19 +48,20 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( src_str, hex_src_string );
des_setkey_dec( &ctx, key_str );
TEST_ASSERT( des_crypt_ecb( &ctx, src_str, output ) == 0 );
hexify( dst_str, output, 8 );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:#cbc_result
+/* BEGIN_CASE */
+void des_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];
@@ -73,23 +77,24 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- src_len = unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ src_len = unhexify( src_str, hex_src_string );
des_setkey_enc( &ctx, key_str );
- TEST_ASSERT( des_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ) == {cbc_result} );
- if( {cbc_result} == 0 )
+ TEST_ASSERT( des_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ) == cbc_result );
+ if( cbc_result == 0 )
{
hexify( dst_str, output, src_len );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:#cbc_result
+/* BEGIN_CASE */
+void des_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];
@@ -105,23 +110,24 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- src_len = unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ src_len = unhexify( src_str, hex_src_string );
des_setkey_dec( &ctx, key_str );
- TEST_ASSERT( des_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ) == {cbc_result} );
- if( {cbc_result} == 0 )
+ TEST_ASSERT( des_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ) == cbc_result );
+ if( cbc_result == 0 )
{
hexify( dst_str, output, src_len );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des3_encrypt_ecb:#key_count:hex_key_string:hex_src_string:hex_dst_string
+/* BEGIN_CASE */
+void des3_encrypt_ecb( int key_count, char *hex_key_string,
+ char *hex_src_string, char *hex_dst_string )
{
unsigned char key_str[100];
unsigned char src_str[100];
@@ -134,12 +140,12 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( src_str, hex_src_string );
- if( {key_count} == 2 )
+ if( key_count == 2 )
des3_set2key_enc( &ctx, key_str );
- else if( {key_count} == 3 )
+ else if( key_count == 3 )
des3_set3key_enc( &ctx, key_str );
else
TEST_ASSERT( 0 );
@@ -147,12 +153,13 @@
TEST_ASSERT( des3_crypt_ecb( &ctx, src_str, output ) == 0 );
hexify( dst_str, output, 8 );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des3_decrypt_ecb:#key_count:hex_key_string:hex_src_string:hex_dst_string
+/* BEGIN_CASE */
+void des3_decrypt_ecb( int key_count, char *hex_key_string,
+ char *hex_src_string, char *hex_dst_string )
{
unsigned char key_str[100];
unsigned char src_str[100];
@@ -165,12 +172,12 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( src_str, hex_src_string );
- if( {key_count} == 2 )
+ if( key_count == 2 )
des3_set2key_dec( &ctx, key_str );
- else if( {key_count} == 3 )
+ else if( key_count == 3 )
des3_set3key_dec( &ctx, key_str );
else
TEST_ASSERT( 0 );
@@ -178,12 +185,14 @@
TEST_ASSERT( des3_crypt_ecb( &ctx, src_str, output ) == 0 );
hexify( dst_str, output, 8 );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des3_encrypt_cbc:#key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:#cbc_result
+/* BEGIN_CASE */
+void des3_encrypt_cbc( int key_count, 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];
@@ -199,30 +208,32 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- src_len = unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ src_len = unhexify( src_str, hex_src_string );
- if( {key_count} == 2 )
+ if( key_count == 2 )
des3_set2key_enc( &ctx, key_str );
- else if( {key_count} == 3 )
+ else if( key_count == 3 )
des3_set3key_enc( &ctx, key_str );
else
TEST_ASSERT( 0 );
- TEST_ASSERT( des3_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ) == {cbc_result} );
+ TEST_ASSERT( des3_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output ) == cbc_result );
- if( {cbc_result} == 0 )
+ if( cbc_result == 0 )
{
hexify( dst_str, output, src_len );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des3_decrypt_cbc:#key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:#cbc_result
+/* BEGIN_CASE */
+void des3_decrypt_cbc( int key_count, 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];
@@ -238,30 +249,30 @@
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
- unhexify( key_str, {hex_key_string} );
- unhexify( iv_str, {hex_iv_string} );
- src_len = unhexify( src_str, {hex_src_string} );
+ unhexify( key_str, hex_key_string );
+ unhexify( iv_str, hex_iv_string );
+ src_len = unhexify( src_str, hex_src_string );
- if( {key_count} == 2 )
+ if( key_count == 2 )
des3_set2key_dec( &ctx, key_str );
- else if( {key_count} == 3 )
+ else if( key_count == 3 )
des3_set3key_dec( &ctx, key_str );
else
TEST_ASSERT( 0 );
- TEST_ASSERT( des3_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ) == {cbc_result} );
+ TEST_ASSERT( des3_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output ) == cbc_result );
- if( {cbc_result} == 0 )
+ if( cbc_result == 0 )
{
hexify( dst_str, output, src_len );
- TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
+ TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des_key_parity_run:
+/* BEGIN_CASE */
+void des_key_parity_run()
{
int i, j, cnt;
unsigned char key[DES_KEY_SIZE];
@@ -301,11 +312,11 @@
TEST_ASSERT( des_key_check_key_parity( key ) == 0 );
}
}
-END_CASE
+/* END_CASE */
-BEGIN_CASE
-des_selftest:
+/* BEGIN_CASE */
+void des_selftest()
{
TEST_ASSERT( des_self_test( 0 ) == 0 );
}
-END_CASE
+/* END_CASE */