- Fixed cipher interface for encrypt/decrypt functions
diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function
index 839fa97..59458b8 100644
--- a/tests/suites/test_suite_des.function
+++ b/tests/suites/test_suite_des.function
@@ -20,7 +20,7 @@
unhexify( src_str, {hex_src_string} );
des_setkey_enc( &ctx, key_str );
- des_crypt_ecb( &ctx, src_str, output );
+ 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 );
@@ -45,7 +45,7 @@
unhexify( src_str, {hex_src_string} );
des_setkey_dec( &ctx, key_str );
- des_crypt_ecb( &ctx, src_str, output );
+ 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 );
@@ -53,7 +53,7 @@
END_CASE
BEGIN_CASE
-des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
+des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -74,15 +74,18 @@
src_len = unhexify( src_str, {hex_src_string} );
des_setkey_enc( &ctx, key_str );
- des_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output );
- hexify( dst_str, output, src_len );
+ 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
BEGIN_CASE
-des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
+des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -103,10 +106,13 @@
src_len = unhexify( src_str, {hex_src_string} );
des_setkey_dec( &ctx, key_str );
- des_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output );
- hexify( dst_str, output, src_len );
+ 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
@@ -134,7 +140,7 @@
else
TEST_ASSERT( 0 );
- des3_crypt_ecb( &ctx, src_str, output );
+ 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 );
@@ -165,7 +171,7 @@
else
TEST_ASSERT( 0 );
- des3_crypt_ecb( &ctx, src_str, output );
+ 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 );
@@ -173,7 +179,7 @@
END_CASE
BEGIN_CASE
-des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
+des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -200,15 +206,18 @@
else
TEST_ASSERT( 0 );
- des3_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output );
- hexify( dst_str, output, src_len );
+ TEST_ASSERT( des3_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
BEGIN_CASE
-des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
+des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string:cbc_result
{
unsigned char key_str[100];
unsigned char iv_str[100];
@@ -235,10 +244,13 @@
else
TEST_ASSERT( 0 );
- des3_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output );
- hexify( dst_str, output, src_len );
+ TEST_ASSERT( des3_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