Adapt programs / test suites to _init() and _free()
diff --git a/programs/aes/aescrypt2.c b/programs/aes/aescrypt2.c
index 28f74d1..db7ed32 100644
--- a/programs/aes/aescrypt2.c
+++ b/programs/aes/aescrypt2.c
@@ -93,6 +93,8 @@
       off_t filesize, offset;
 #endif
 
+    aes_init( &aes_ctx );
+
     /*
      * Parse the command-line arguments.
      */
@@ -357,7 +359,7 @@
         }
 
         memset( key, 0, sizeof( key ) );
-          aes_setkey_dec( &aes_ctx, digest, 256 );
+        aes_setkey_dec( &aes_ctx, digest, 256 );
         sha256_hmac_starts( &sha_ctx, digest, 32, 0 );
 
         /*
@@ -426,7 +428,7 @@
     memset( buffer, 0, sizeof( buffer ) );
     memset( digest, 0, sizeof( digest ) );
 
-    memset( &aes_ctx, 0, sizeof(  aes_context ) );
+    aes_free( &aes_ctx );
     memset( &sha_ctx, 0, sizeof( sha256_context ) );
 
     return( ret );
diff --git a/programs/pkey/dh_client.c b/programs/pkey/dh_client.c
index 154f5e3..92c5bca 100644
--- a/programs/pkey/dh_client.c
+++ b/programs/pkey/dh_client.c
@@ -84,6 +84,8 @@
     memset( &rsa, 0, sizeof( rsa ) );
     memset( &dhm, 0, sizeof( dhm ) );
 
+    aes_init( &aes );
+
     /*
      * 1. Setup the RNG
      */
@@ -279,6 +281,7 @@
     if( server_fd != -1 )
         net_close( server_fd );
 
+    aes_free( &aes );
     rsa_free( &rsa );
     dhm_free( &dhm );
     entropy_free( &entropy );
diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c
index c2fdbbf..8bb184f 100644
--- a/programs/pkey/dh_server.c
+++ b/programs/pkey/dh_server.c
@@ -84,6 +84,7 @@
 
     memset( &rsa, 0, sizeof( rsa ) );
     memset( &dhm, 0, sizeof( dhm ) );
+    aes_init( &aes );
 
     /*
      * 1. Setup the RNG
@@ -280,6 +281,7 @@
     if( client_fd != -1 )
         net_close( client_fd );
 
+    aes_free( &aes );
     rsa_free( &rsa );
     dhm_free( &dhm );
     entropy_free( &entropy );
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index b978f01c..a17d690 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -273,8 +273,10 @@
     if( todo.arc4 )
     {
         arc4_context arc4;
+        arc4_init( &arc4 );
         arc4_setup( &arc4, tmp, 32 );
         TIME_AND_TSC( "ARC4", arc4_crypt( &arc4, BUFSIZE, buf, buf ) );
+        arc4_free( &arc4 );
     }
 #endif
 
@@ -282,17 +284,21 @@
     if( todo.des3 )
     {
         des3_context des3;
+        des3_init( &des3 );
         des3_set3key_enc( &des3, tmp );
         TIME_AND_TSC( "3DES",
                 des3_crypt_cbc( &des3, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
+        des3_free( &des3 );
     }
 
     if( todo.des )
     {
         des_context des;
+        des_init( &des );
         des_setkey_enc( &des, tmp );
         TIME_AND_TSC( "DES",
                 des_crypt_cbc( &des, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
+        des_free( &des );
     }
 #endif
 
@@ -301,6 +307,7 @@
     if( todo.aes_cbc )
     {
         aes_context aes;
+        aes_init( &aes );
         for( keysize = 128; keysize <= 256; keysize += 64 )
         {
             snprintf( title, sizeof( title ), "AES-CBC-%d", keysize );
@@ -312,6 +319,7 @@
             TIME_AND_TSC( title,
                 aes_crypt_cbc( &aes, AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) );
         }
+        aes_free( &aes );
     }
 #endif
 #if defined(POLARSSL_GCM_C)
@@ -360,6 +368,7 @@
     if( todo.camellia )
     {
         camellia_context camellia;
+        camellia_init( &camellia );
         for( keysize = 128; keysize <= 256; keysize += 64 )
         {
             snprintf( title, sizeof( title ), "CAMELLIA-CBC-%d", keysize );
@@ -372,6 +381,7 @@
                     camellia_crypt_cbc( &camellia, CAMELLIA_ENCRYPT,
                         BUFSIZE, tmp, buf, buf ) );
         }
+        camellia_free( &camellia );
     }
 #endif
 
@@ -379,6 +389,8 @@
     if( todo.blowfish )
     {
         blowfish_context blowfish;
+        blowfish_init( &blowfish );
+
         for( keysize = 128; keysize <= 256; keysize += 64 )
         {
             snprintf( title, sizeof( title ), "BLOWFISH-CBC-%d", keysize );
@@ -391,6 +403,8 @@
                     blowfish_crypt_cbc( &blowfish, BLOWFISH_ENCRYPT, BUFSIZE,
                         tmp, buf, buf ) );
         }
+
+        blowfish_free( &blowfish );
     }
 #endif
 
diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function
index b92e80d..20f5889 100644
--- a/tests/suites/test_suite_aes.function
+++ b/tests/suites/test_suite_aes.function
@@ -22,6 +22,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -34,6 +35,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
@@ -52,6 +55,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -64,6 +68,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
@@ -85,6 +91,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -98,6 +105,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
@@ -119,6 +128,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -132,6 +142,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
@@ -153,6 +165,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -163,6 +176,8 @@
     hexify( dst_str, output, 16 );
 
     TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
@@ -184,6 +199,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -194,6 +210,8 @@
     hexify( dst_str, output, 16 );
 
     TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
@@ -214,6 +232,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -224,6 +243,8 @@
     hexify( dst_str, output, src_len );
 
     TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
@@ -244,6 +265,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    aes_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -254,6 +276,8 @@
     hexify( dst_str, output, src_len );
 
     TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    aes_free( &ctx );
 }
 /* END_CASE */
 
diff --git a/tests/suites/test_suite_arc4.function b/tests/suites/test_suite_arc4.function
index 73df59e..f55a5e8 100644
--- a/tests/suites/test_suite_arc4.function
+++ b/tests/suites/test_suite_arc4.function
@@ -22,6 +22,7 @@
     memset(key_str, 0x00, 1000);
     memset(dst_str, 0x00, 1000);
     memset(dst_hexstr, 0x00, 2000);
+    arc4_init( &ctx );
 
     src_len = unhexify( src_str, hex_src_string );
     key_len = unhexify( key_str, hex_key_string );
@@ -31,6 +32,8 @@
     hexify( dst_hexstr, dst_str, src_len );
 
     TEST_ASSERT( strcmp( (char *) dst_hexstr, hex_dst_string ) == 0 );
+
+    arc4_free( &ctx );
 }
 /* END_CASE */
 
diff --git a/tests/suites/test_suite_blowfish.function b/tests/suites/test_suite_blowfish.function
index 673b88c..17a5b65 100644
--- a/tests/suites/test_suite_blowfish.function
+++ b/tests/suites/test_suite_blowfish.function
@@ -22,6 +22,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    blowfish_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -34,6 +35,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    blowfish_free( &ctx );
 }
 /* END_CASE */
 
@@ -52,6 +55,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    blowfish_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -64,6 +68,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    blowfish_free( &ctx );
 }
 /* END_CASE */
 
@@ -85,6 +91,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    blowfish_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -99,6 +106,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    blowfish_free( &ctx );
 }
 /* END_CASE */
 
@@ -120,6 +129,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    blowfish_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -133,6 +143,8 @@
 
         TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    blowfish_free( &ctx );
 }
 /* END_CASE */
 
@@ -154,6 +166,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    blowfish_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -164,6 +177,8 @@
     hexify( dst_str, output, src_len );
 
     TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    blowfish_free( &ctx );
 }
 /* END_CASE */
 
@@ -185,6 +200,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    blowfish_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -195,6 +211,8 @@
     hexify( dst_str, output, src_len );
 
     TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    blowfish_free( &ctx );
 }
 /* END_CASE */
 
@@ -218,6 +236,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    blowfish_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -228,5 +247,7 @@
     hexify( dst_str, output, src_len );
 
     TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    blowfish_free( &ctx );
 }
 /* END_CASE */
diff --git a/tests/suites/test_suite_camellia.function b/tests/suites/test_suite_camellia.function
index 8f9e978..c5b66a6 100644
--- a/tests/suites/test_suite_camellia.function
+++ b/tests/suites/test_suite_camellia.function
@@ -22,6 +22,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    camellia_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -34,6 +35,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    camellia_free( &ctx );
 }
 /* END_CASE */
 
@@ -52,6 +55,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    camellia_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -64,6 +68,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    camellia_free( &ctx );
 }
 /* END_CASE */
 
@@ -85,6 +91,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    camellia_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -98,6 +105,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    camellia_free( &ctx );
 }
 /* END_CASE */
 
@@ -119,6 +128,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    camellia_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -132,6 +142,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    camellia_free( &ctx );
 }
 /* END_CASE */
 
@@ -153,6 +165,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    camellia_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -163,6 +176,8 @@
     hexify( dst_str, output, 16 );
 
     TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    camellia_free( &ctx );
 }
 /* END_CASE */
 
@@ -184,6 +199,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    camellia_init( &ctx );
 
     key_len = unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -194,6 +210,8 @@
     hexify( dst_str, output, 16 );
 
     TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    camellia_free( &ctx );
 }
 /* END_CASE */
 
diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function
index d5d0f11..0231757 100644
--- a/tests/suites/test_suite_des.function
+++ b/tests/suites/test_suite_des.function
@@ -34,6 +34,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -43,6 +44,8 @@
     hexify( dst_str, output, 8 );
 
     TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    des_free( &ctx );
 }
 /* END_CASE */
 
@@ -60,6 +63,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -69,6 +73,8 @@
     hexify( dst_str, output, 8 );
 
     TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    des_free( &ctx );
 }
 /* END_CASE */
 
@@ -89,6 +95,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -102,6 +109,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    des_free( &ctx );
 }
 /* END_CASE */
 
@@ -122,6 +131,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -135,6 +145,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    des_free( &ctx );
 }
 /* END_CASE */
 
@@ -152,6 +164,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des3_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -167,6 +180,8 @@
     hexify( dst_str, output, 8 );
 
     TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    des3_free( &ctx );
 }
 /* END_CASE */
 
@@ -184,6 +199,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des3_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( src_str, hex_src_string );
@@ -199,6 +215,8 @@
     hexify( dst_str, output, 8 );
 
     TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
+
+    des3_free( &ctx );
 }
 /* END_CASE */
 
@@ -220,6 +238,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des3_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -240,6 +259,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    des3_free( &ctx );
 }
 /* END_CASE */
 
@@ -261,6 +282,7 @@
     memset(src_str, 0x00, 100);
     memset(dst_str, 0x00, 100);
     memset(output, 0x00, 100);
+    des3_init( &ctx );
 
     unhexify( key_str, hex_key_string );
     unhexify( iv_str, hex_iv_string );
@@ -281,6 +303,8 @@
 
         TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
     }
+
+    des3_free( &ctx );
 }
 /* END_CASE */