Introduce polarssl_zeroize() instead of memset() for zeroization
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index a4bf1ab..cd207c5 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -52,6 +52,11 @@
#endif
#if defined(POLARSSL_SSL_SESSION_TICKETS)
+/* 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;
+}
+
/*
* Serialize a session in the following format:
* 0 . n-1 session structure, n = sizeof(ssl_session)
@@ -337,7 +342,7 @@
ssl_session_free( ssl->session_negotiate );
memcpy( ssl->session_negotiate, &session, sizeof( ssl_session ) );
- memset( &session, 0, sizeof( ssl_session ) );
+ polarssl_zeroize( &session, sizeof( ssl_session ) );
return( 0 );
}