Adapted programs / test suites to _init() and _free()
diff --git a/programs/aes/aescrypt2.c b/programs/aes/aescrypt2.c
index db7ed32..40b7fec 100644
--- a/programs/aes/aescrypt2.c
+++ b/programs/aes/aescrypt2.c
@@ -94,6 +94,7 @@
#endif
aes_init( &aes_ctx );
+ sha256_init( &sha_ctx );
/*
* Parse the command-line arguments.
@@ -429,7 +430,7 @@
memset( digest, 0, sizeof( digest ) );
aes_free( &aes_ctx );
- memset( &sha_ctx, 0, sizeof( sha256_context ) );
+ sha256_free( &sha_ctx );
return( ret );
}
diff --git a/tests/suites/test_suite_hmac_shax.function b/tests/suites/test_suite_hmac_shax.function
index d65437b..10b376f 100644
--- a/tests/suites/test_suite_hmac_shax.function
+++ b/tests/suites/test_suite_hmac_shax.function
@@ -17,6 +17,7 @@
memset(src_str, 0x00, sizeof src_str);
memset(key_str, 0x00, sizeof key_str);
+ sha1_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -56,6 +57,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ sha1_free( &ctx );
}
/* END_CASE */
@@ -72,6 +75,7 @@
memset(src_str, 0x00, sizeof src_str);
memset(key_str, 0x00, sizeof key_str);
+ sha256_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -111,6 +115,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ sha256_free( &ctx );
}
/* END_CASE */
@@ -127,6 +133,7 @@
memset(src_str, 0x00, sizeof src_str);
memset(key_str, 0x00, sizeof key_str);
+ sha256_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -166,6 +173,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ sha256_free( &ctx );
}
/* END_CASE */
@@ -182,6 +191,7 @@
memset(src_str, 0x00, sizeof src_str);
memset(key_str, 0x00, sizeof key_str);
+ sha512_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -221,6 +231,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ sha512_free( &ctx );
}
/* END_CASE */
@@ -237,6 +249,7 @@
memset(src_str, 0x00, sizeof src_str);
memset(key_str, 0x00, sizeof key_str);
+ sha512_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -276,5 +289,7 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ sha512_free( &ctx );
}
/* END_CASE */
diff --git a/tests/suites/test_suite_mdx.function b/tests/suites/test_suite_mdx.function
index 24fb328..12a5e1b 100644
--- a/tests/suites/test_suite_mdx.function
+++ b/tests/suites/test_suite_mdx.function
@@ -98,6 +98,7 @@
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
+ md2_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -137,6 +138,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ md2_free( &ctx );
}
/* END_CASE */
@@ -153,6 +156,7 @@
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
+ md4_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -192,6 +196,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ md4_free( &ctx );
}
/* END_CASE */
@@ -208,6 +214,7 @@
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
+ md5_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -247,6 +254,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ md5_free( &ctx );
}
/* END_CASE */
@@ -263,6 +272,7 @@
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
+ ripemd160_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
@@ -302,6 +312,8 @@
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
+
+ ripemd160_free( &ctx );
}
/* END_CASE */