Introduce polarssl_zeroize() instead of memset() for zeroization
diff --git a/library/md_wrap.c b/library/md_wrap.c
index f276db5..92d04f9 100644
--- a/library/md_wrap.c
+++ b/library/md_wrap.c
@@ -59,6 +59,11 @@
 
 #include <stdlib.h>
 
+/* Implementation that should never be optimized out by the compiler */
+static void polarssl_zeroize( void *v, size_t n ) {
+    volatile unsigned char *p = v; while( n-- ) *p++ = 0;
+}
+
 #if defined(POLARSSL_MD2_C)
 
 static void md2_starts_wrap( void *ctx )
@@ -114,6 +119,7 @@
 
 static void md2_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( md2_context ) );
     free( ctx );
 }
 
@@ -192,6 +198,7 @@
 
 void md4_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( md4_context ) );
     free( ctx );
 }
 
@@ -270,6 +277,7 @@
 
 static void md5_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( md5_context ) );
     free( ctx );
 }
 
@@ -348,6 +356,7 @@
 
 void sha1_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( sha1_context ) );
     free( ctx );
 }
 
@@ -442,6 +451,7 @@
 
 void sha224_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( sha2_context ) );
     free( ctx );
 }
 
@@ -529,6 +539,7 @@
 
 void sha256_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( sha2_context ) );
     free( ctx );
 }
 
@@ -620,6 +631,7 @@
 
 void sha384_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( sha4_context ) );
     free( ctx );
 }
 
@@ -707,6 +719,7 @@
 
 void sha512_ctx_free( void *ctx )
 {
+    polarssl_zeroize( ctx, sizeof( sha4_context ) );
     free( ctx );
 }