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

@ -46,6 +46,11 @@
#include "polarssl/pem.h"
#endif /* POLARSSL_PEM_WRITE_C */
/* 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;
}
void x509write_crt_init( x509write_cert *ctx )
{
memset( ctx, 0, sizeof(x509write_cert) );
@ -62,7 +67,7 @@ void x509write_crt_free( x509write_cert *ctx )
asn1_free_named_data_list( &ctx->issuer );
asn1_free_named_data_list( &ctx->extensions );
memset( ctx, 0, sizeof(x509write_cert) );
polarssl_zeroize( ctx, sizeof(x509write_cert) );
}
void x509write_crt_set_version( x509write_cert *ctx, int version )