Introduce polarssl_zeroize() instead of memset() for zeroization

This commit is contained in:
Paul Bakker 2014-06-13 17:20:13 +02:00
parent bbcb1ce703
commit 3461772559
36 changed files with 325 additions and 129 deletions

View file

@ -55,6 +55,13 @@ typedef UINT32 uint32_t;
#include <time.h>
#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;
}
#endif
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
static void ssl_write_hostname_ext( ssl_context *ssl,
unsigned char *buf,
@ -2466,6 +2473,8 @@ static int ssl_parse_new_session_ticket( ssl_context *ssl )
if( ticket_len == 0)
return( 0 );
polarssl_zeroize( ssl->session_negotiate->ticket,
ssl->session_negotiate->ticket_len );
polarssl_free( ssl->session_negotiate->ticket );
ssl->session_negotiate->ticket = NULL;
ssl->session_negotiate->ticket_len = 0;