Commit 34617725 authored by Paul Bakker's avatar Paul Bakker

Introduce polarssl_zeroize() instead of memset() for zeroization

parent bbcb1ce7
......@@ -14,6 +14,8 @@ Features
Changes
* Add LINK_WITH_PTHREAD option in CMake for explicit linking that is
required on some platforms (e.g. OpenBSD)
* Migrate zeroizing of data to polarssl_zeroize() instead of memset()
against unwanted compiler optimizations
Bugfix
* Fix in debug_print_msg()
......
......@@ -53,6 +53,11 @@
#if !defined(POLARSSL_AES_ALT)
/* 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;
}
/*
* 32-bit integer manipulation macros (little endian)
*/
......@@ -633,7 +638,7 @@ int aes_setkey_dec( aes_context *ctx, const unsigned char *key,
#if defined(POLARSSL_AESNI_C) && defined(POLARSSL_HAVE_X86_64)
done:
#endif
memset( &cty, 0, sizeof( aes_context ) );
polarssl_zeroize( &cty, sizeof( aes_context ) );
return( 0 );
}
......
......@@ -51,6 +51,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;
}
#define ciL (sizeof(t_uint)) /* chars in limb */
#define biL (ciL << 3) /* bits in limb */
#define biH (ciL << 2) /* half limb size */
......@@ -84,7 +89,7 @@ void mpi_free( mpi *X )
if( X->p != NULL )
{
memset( X->p, 0, X->n * ciL );
polarssl_zeroize( X->p, X->n * ciL );
polarssl_free( X->p );
}
......@@ -113,7 +118,7 @@ int mpi_grow( mpi *X, size_t nblimbs )
if( X->p != NULL )
{
memcpy( p, X->p, X->n * ciL );
memset( X->p, 0, X->n * ciL );
polarssl_zeroize( X->p, X->n * ciL );
polarssl_free( X->p );
}
......@@ -153,7 +158,7 @@ int mpi_shrink( mpi *X, size_t nblimbs )
if( X->p != NULL )
{
memcpy( p, X->p, i * ciL );
memset( X->p, 0, X->n * ciL );
polarssl_zeroize( X->p, X->n * ciL );
polarssl_free( X->p );
}
......
......@@ -47,6 +47,11 @@
#if !defined(POLARSSL_CAMELLIA_ALT)
/* 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;
}
/*
* 32-bit integer manipulation macros (big endian)
*/
......@@ -463,7 +468,7 @@ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key,
*RK++ = *SK++;
*RK++ = *SK++;
memset( &cty, 0, sizeof( camellia_context ) );
polarssl_zeroize( &cty, sizeof( camellia_context ) );
return( 0 );
}
......
......@@ -42,6 +42,11 @@
#include "polarssl/ccm.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;
}
#define CCM_ENCRYPT 0
#define CCM_DECRYPT 1
......@@ -81,7 +86,7 @@ int ccm_init( ccm_context *ctx, cipher_id_t cipher,
void ccm_free( ccm_context *ctx )
{
(void) cipher_free_ctx( &ctx->cipher_ctx );
memset( ctx, 0, sizeof( ccm_context ) );
polarssl_zeroize( ctx, sizeof( ccm_context ) );
}
/*
......@@ -320,7 +325,7 @@ int ccm_auth_decrypt( ccm_context *ctx, size_t length,
if( diff != 0 )
{
memset( output, 0, length );
polarssl_zeroize( output, length );
return( POLARSSL_ERR_CCM_AUTH_FAILED );
}
......
......@@ -57,6 +57,11 @@
#define strcasecmp _stricmp
#endif
/* 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;
}
static int supported_init = 0;
const int *cipher_list( void )
......@@ -152,6 +157,7 @@ int cipher_free_ctx( cipher_context_t *ctx )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
ctx->cipher_info->base->ctx_free_func( ctx->cipher_ctx );
polarssl_zeroize( ctx, sizeof(cipher_context_t) );
return 0;
}
......
......@@ -74,6 +74,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_GCM_C)
/* shared by all GCM ciphers */
static void *gcm_ctx_alloc( void )
......@@ -187,6 +192,7 @@ static void * aes_ctx_alloc( void )
static void aes_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( aes_context ) );
polarssl_free( ctx );
}
......@@ -540,6 +546,7 @@ static void * camellia_ctx_alloc( void )
static void camellia_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( camellia_context ) );
polarssl_free( ctx );
}
......@@ -948,6 +955,13 @@ static void * des3_ctx_alloc( void )
static void des_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( des_context ) );
polarssl_free( ctx );
}
static void des3_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( des3_context ) );
polarssl_free( ctx );
}
......@@ -998,7 +1012,7 @@ const cipher_base_t des_ede_info = {
des3_set2key_enc_wrap,
des3_set2key_dec_wrap,
des3_ctx_alloc,
des_ctx_free
des3_ctx_free
};
const cipher_info_t des_ede_ecb_info = {
......@@ -1035,7 +1049,7 @@ const cipher_base_t des_ede3_info = {
des3_set3key_enc_wrap,
des3_set3key_dec_wrap,
des3_ctx_alloc,
des_ctx_free
des3_ctx_free
};
const cipher_info_t des_ede3_ecb_info = {
......@@ -1143,6 +1157,7 @@ static void * blowfish_ctx_alloc( void )
static void blowfish_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( blowfish_context ) );
polarssl_free( ctx );
}
......@@ -1236,6 +1251,7 @@ static void * arc4_ctx_alloc( void )
static void arc4_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( arc4_context ) );
polarssl_free( ctx );
}
......
......@@ -47,6 +47,11 @@
#if !defined(POLARSSL_DES_ALT)
/* 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;
}
/*
* 32-bit integer manipulation macros (big endian)
*/
......@@ -519,7 +524,7 @@ int des3_set2key_enc( des3_context *ctx,
uint32_t sk[96];
des3_set2key( ctx->sk, sk, key );
memset( sk, 0, sizeof( sk ) );
polarssl_zeroize( sk, sizeof( sk ) );
return( 0 );
}
......@@ -533,7 +538,7 @@ int des3_set2key_dec( des3_context *ctx,
uint32_t sk[96];
des3_set2key( sk, ctx->sk, key );
memset( sk, 0, sizeof( sk ) );
polarssl_zeroize( sk, sizeof( sk ) );
return( 0 );
}
......@@ -570,7 +575,7 @@ int des3_set3key_enc( des3_context *ctx,
uint32_t sk[96];
des3_set3key( ctx->sk, sk, key );
memset( sk, 0, sizeof( sk ) );
polarssl_zeroize( sk, sizeof( sk ) );
return( 0 );
}
......@@ -584,7 +589,7 @@ int des3_set3key_dec( des3_context *ctx,
uint32_t sk[96];
des3_set3key( sk, ctx->sk, key );
memset( sk, 0, sizeof( sk ) );
polarssl_zeroize( sk, sizeof( sk ) );
return( 0 );
}
......
......@@ -55,6 +55,11 @@
#define polarssl_free free
#endif
/* 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;
}
/*
* helper to validate the mpi size and import it
*/
......@@ -395,7 +400,7 @@ void dhm_free( dhm_context *ctx )
mpi_free( &ctx->GX ); mpi_free( &ctx->X ); mpi_free( &ctx->G );
mpi_free( &ctx->P );
memset( ctx, 0, sizeof( dhm_context ) );
polarssl_zeroize( ctx, sizeof( dhm_context ) );
}
#if defined(POLARSSL_ASN1_PARSE_C)
......@@ -535,7 +540,7 @@ int dhm_parse_dhmfile( dhm_context *dhm, const char *path )
ret = dhm_parse_dhm( dhm, buf, n );
memset( buf, 0, n + 1 );
polarssl_zeroize( buf, n + 1 );
polarssl_free( buf );
return( ret );
......
......@@ -77,6 +77,11 @@
#endif /* __ARMCC_VERSION */
#endif /*_MSC_VER */
/* 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_SELF_TEST)
/*
* Counts of point addition and doubling, and field multiplications.
......@@ -344,7 +349,7 @@ void ecp_group_free( ecp_group *grp )
polarssl_free( grp->T );
}
memset( grp, 0, sizeof( ecp_group ) );
polarssl_zeroize( grp, sizeof( ecp_group ) );
}
/*
......
......@@ -42,6 +42,11 @@
#include "polarssl/havege.h"
#endif
/* 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;
}
#define ENTROPY_MAX_LOOP 256 /**< Maximum amount to loop before error */
void entropy_init( entropy_context *ctx )
......@@ -78,7 +83,7 @@ void entropy_init( entropy_context *ctx )
void entropy_free( entropy_context *ctx )
{
((void) ctx);
polarssl_zeroize( ctx, sizeof( entropy_context ) );
#if defined(POLARSSL_THREADING_C)
polarssl_mutex_free( &ctx->mutex );
#endif
......
......@@ -76,6 +76,11 @@
}
#endif
/* 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;
}
/*
* Precompute small multiples of H, that is set
* HH[i] || HL[i] = H times i,
......@@ -464,7 +469,7 @@ int gcm_auth_decrypt( gcm_context *ctx,
if( diff != 0 )
{
memset( output, 0, length );
polarssl_zeroize( output, length );
return( POLARSSL_ERR_GCM_AUTH_FAILED );
}
......@@ -474,7 +479,7 @@ int gcm_auth_decrypt( gcm_context *ctx,
void gcm_free( gcm_context *ctx )
{
(void) cipher_free_ctx( &ctx->cipher_ctx );
memset( ctx, 0, sizeof( gcm_context ) );
polarssl_zeroize( ctx, sizeof( gcm_context ) );
}
#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
......
......@@ -49,6 +49,11 @@
#define polarssl_printf printf
#endif
/* 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;
}
/*
* HMAC_DRBG update, using optional additional data (10.1.2.2)
*/
......@@ -305,7 +310,7 @@ void hmac_drbg_free( hmac_drbg_context *ctx )
md_free_ctx( &ctx->md_ctx );
memset( ctx, 0, sizeof( hmac_drbg_context ) );
polarssl_zeroize( ctx, sizeof( hmac_drbg_context ) );
}
#if defined(POLARSSL_FS_IO)
......
......@@ -45,6 +45,11 @@
#define strcasecmp _stricmp
#endif
/* 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;
}
static const int supported_digests[] = {
#if defined(POLARSSL_MD2_C)
......@@ -190,7 +195,8 @@ int md_free_ctx( md_context_t *ctx )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
ctx->md_info->ctx_free_func( ctx->md_ctx );
ctx->md_ctx = NULL;
polarssl_zeroize( ctx, sizeof( md_context_t ) );
return 0;
}
......
......@@ -49,6 +49,11 @@
#define polarssl_printf printf
#endif
/* 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_ALT)
static const unsigned char PI_SUBST[256] =
......@@ -188,7 +193,7 @@ void md2( const unsigned char *input, size_t ilen, unsigned char output[16] )
md2_update( &ctx, input, ilen );
md2_finish( &ctx, output );
memset( &ctx, 0, sizeof( md2_context ) );
polarssl_zeroize( &ctx, sizeof( md2_context ) );
}
#if defined(POLARSSL_FS_IO)
......@@ -212,7 +217,7 @@ int md2_file( const char *path, unsigned char output[16] )
md2_finish( &ctx, output );
memset( &ctx, 0, sizeof( md2_context ) );
polarssl_zeroize( &ctx, sizeof( md2_context ) );
if( ferror( f ) != 0 )
{
......@@ -253,7 +258,7 @@ void md2_hmac_starts( md2_context *ctx, const unsigned char *key,
md2_starts( ctx );
md2_update( ctx, ctx->ipad, 16 );
memset( sum, 0, sizeof( sum ) );
polarssl_zeroize( sum, sizeof( sum ) );
}
/*
......@@ -278,7 +283,7 @@ void md2_hmac_finish( md2_context *ctx, unsigned char output[16] )
md2_update( ctx, tmpbuf, 16 );
md2_finish( ctx, output );
memset( tmpbuf, 0, sizeof( tmpbuf ) );
polarssl_zeroize( tmpbuf, sizeof( tmpbuf ) );
}
/*
......@@ -303,7 +308,7 @@ void md2_hmac( const unsigned char *key, size_t keylen,
md2_hmac_update( &ctx, input, ilen );
md2_hmac_finish( &ctx, output );
memset( &ctx, 0, sizeof( md2_context ) );
polarssl_zeroize( &ctx, sizeof( md2_context ) );
}
#if defined(POLARSSL_SELF_TEST)
......
......@@ -49,6 +49,11 @@
#define polarssl_printf printf
#endif
/* 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_MD4_ALT)
/*
......@@ -284,7 +289,7 @@ void md4( const unsigned char *input, size_t ilen, unsigned char output[16] )
md4_update( &ctx, input, ilen );
md4_finish( &ctx, output );
memset( &ctx, 0, sizeof( md4_context ) );
polarssl_zeroize( &ctx, sizeof( md4_context ) );
}
#if defined(POLARSSL_FS_IO)
......@@ -308,7 +313,7 @@ int md4_file( const char *path, unsigned char output[16] )
md4_finish( &ctx, output );
memset( &ctx, 0, sizeof( md4_context ) );
polarssl_zeroize( &ctx, sizeof( md4_context ) );
if( ferror( f ) != 0 )
{
......@@ -349,7 +354,7 @@ void md4_hmac_starts( md4_context *ctx, const unsigned char *key,
md4_starts( ctx );
md4_update( ctx, ctx->ipad, 64 );
memset( sum, 0, sizeof( sum ) );
polarssl_zeroize( sum, sizeof( sum ) );
}
/*
......@@ -374,7 +379,7 @@ void md4_hmac_finish( md4_context *ctx, unsigned char output[16] )
md4_update( ctx, tmpbuf, 16 );
md4_finish( ctx, output );
memset( tmpbuf, 0, sizeof( tmpbuf ) );
polarssl_zeroize( tmpbuf, sizeof( tmpbuf ) );
}
/*
......@@ -399,7 +404,7 @@ void md4_hmac( const unsigned char *key, size_t keylen,
md4_hmac_update( &ctx, input, ilen );
md4_hmac_finish( &ctx, output );
memset( &ctx, 0, sizeof( md4_context ) );
polarssl_zeroize( &ctx, sizeof( md4_context ) );
}
#if defined(POLARSSL_SELF_TEST)
......
......@@ -48,6 +48,11 @@
#define polarssl_printf printf
#endif
/* 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_MD5_ALT)
/*
......@@ -301,7 +306,7 @@ void md5( const unsigned char *input, size_t ilen, unsigned char output[16] )
md5_update( &ctx, input, ilen );
md5_finish( &ctx, output );
memset( &ctx, 0, sizeof( md5_context ) );
polarssl_zeroize( &ctx, sizeof( md5_context ) );
}
#if defined(POLARSSL_FS_IO)
......@@ -325,7 +330,7 @@ int md5_file( const char *path, unsigned char output[16] )
md5_finish( &ctx, output );
memset( &ctx, 0, sizeof( md5_context ) );
polarssl_zeroize( &ctx, sizeof( md5_context ) );
if( ferror( f ) != 0 )
{
......@@ -366,7 +371,7 @@ void md5_hmac_starts( md5_context *ctx, const unsigned char *key,
md5_starts( ctx );
md5_update( ctx, ctx->ipad, 64 );
memset( sum, 0, sizeof( sum ) );
polarssl_zeroize( sum, sizeof( sum ) );
}
/*
......@@ -391,7 +396,7 @@ void md5_hmac_finish( md5_context *ctx, unsigned char output[16] )
md5_update( ctx, tmpbuf, 16 );
md5_finish( ctx, output );
memset( tmpbuf, 0, sizeof( tmpbuf ) );
polarssl_zeroize( tmpbuf, sizeof( tmpbuf ) );
}
/*
......@@ -416,7 +421,7 @@ void md5_hmac( const unsigned char *key, size_t keylen,
md5_hmac_update( &ctx, input, ilen );
md5_hmac_finish( &ctx, output );
memset( &ctx, 0, sizeof( md5_context ) );
polarssl_zeroize( &ctx, sizeof( md5_context ) );
}
#if defined(POLARSSL_SELF_TEST)
......
......@@ -74,6 +74,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 )
......@@ -132,6 +137,7 @@ static void * md2_ctx_alloc( void )
static void md2_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( md2_context ) );
polarssl_free( ctx );
}
......@@ -221,6 +227,7 @@ static void *md4_ctx_alloc( void )
static void md4_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( md4_context ) );
polarssl_free( ctx );
}
......@@ -308,6 +315,7 @@ static void * md5_ctx_alloc( void )
static void md5_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( md5_context ) );
polarssl_free( ctx );
}
......@@ -395,6 +403,7 @@ static void * ripemd160_ctx_alloc( void )
static void ripemd160_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( ripemd160_context ) );
polarssl_free( ctx );
}
......@@ -482,6 +491,7 @@ static void * sha1_ctx_alloc( void )
static void sha1_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( sha1_context ) );
polarssl_free( ctx );
}
......@@ -585,6 +595,7 @@ static void * sha224_ctx_alloc( void )
static void sha224_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( sha256_context ) );
polarssl_free( ctx );
}
......@@ -681,6 +692,7 @@ static void * sha256_ctx_alloc( void )
static void sha256_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( sha256_context ) );
polarssl_free( ctx );
}
......@@ -781,6 +793,7 @@ static void * sha384_ctx_alloc( void )
static void sha384_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( sha512_context ) );
polarssl_free( ctx );
}
......@@ -877,6 +890,7 @@ static void * sha512_ctx_alloc( void )
static void sha512_ctx_free( void *ctx )
{
polarssl_zeroize( ctx, sizeof( sha512_context ) );
polarssl_free( ctx );
}
......
......@@ -52,6 +52,11 @@
#define polarssl_fprintf fprintf
#endif
/* 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;
}
#define MAGIC1 0xFF00AA55
#define MAGIC2 0xEE119966
#define MAX_BT 20
......@@ -578,7 +583,7 @@ void memory_buffer_alloc_free()
#if defined(POLARSSL_THREADING_C)
polarssl_mutex_free( &heap.mutex );
#endif
memset( &heap, 0, sizeof(buffer_alloc_ctx) );
polarssl_zeroize( &heap, sizeof(buffer_alloc_ctx) );
}
#endif /* POLARSSL_MEMORY_BUFFER_ALLOC_C */
......@@ -46,6 +46,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_PEM_PARSE_C)
void pem_init( pem_context *ctx )
{
......@@ -99,8 +104,8 @@ static void pem_pbkdf1( unsigned char *key, size_t keylen,
{
memcpy( key, md5sum, keylen );
memset( &md5_ctx, 0, sizeof( md5_ctx ) );
memset( md5sum, 0, 16 );
polarssl_zeroize( &md5_ctx, sizeof( md5_ctx ) );
polarssl_zeroize( md5sum, 16 );
return;
}
......@@ -121,8 +126,8 @@ static void pem_pbkdf1( unsigned char *key, size_t keylen,
memcpy( key + 16, md5sum, use_len );
memset( &md5_ctx, 0, sizeof( md5_ctx ) );
memset( md5sum, 0, 16 );
polarssl_zeroize( &md5_ctx, sizeof( md5_ctx ) );
polarssl_zeroize( md5sum, 16 );
}
#if defined(POLARSSL_DES_C)
......@@ -142,8 +147,8 @@ static void pem_des_decrypt( unsigned char des_iv[8],
des_crypt_cbc( &des_ctx, DES_DECRYPT, buflen,
des_iv, buf, buf );
memset( &des_ctx, 0, sizeof( des_ctx ) );
memset( des_key, 0, 8 );
polarssl_zeroize( &des_ctx, sizeof( des_ctx ) );
polarssl_zeroize( des_key, 8 );
}
/*
......@@ -162,8 +167,8 @@ static void pem_des3_decrypt( unsigned char des3_iv[8],
des3_crypt_cbc( &des3_ctx, DES_DECRYPT, buflen,
des3_iv, buf, buf );
memset( &des3_ctx, 0, sizeof( des3_ctx ) );
memset( des3_key, 0, 24 );
polarssl_zeroize( &des3_ctx, sizeof( des3_ctx ) );
polarssl_zeroize( des3_key, 24 );
}
#endif /* POLARSSL_DES_C */
......@@ -184,8 +189,8 @@ static void pem_aes_decrypt( unsigned char aes_iv[16], unsigned int keylen,
aes_crypt_cbc( &aes_ctx, AES_DECRYPT, buflen,
aes_iv, buf, buf );
memset( &aes_ctx, 0, sizeof( aes_ctx ) );
memset( aes_key, 0, keylen );
polarssl_zeroize( &aes_ctx, sizeof( aes_ctx ) );
polarssl_zeroize( aes_key, keylen );
}
#endif /* POLARSSL_AES_C */
......@@ -373,7 +378,7 @@ void pem_free( pem_context *ctx )
polarssl_free( ctx->buf );
polarssl_free( ctx->info );
memset( ctx, 0, sizeof( pem_context ) );
polarssl_zeroize( ctx, sizeof( pem_context ) );
}
#endif /* POLARSSL_PEM_PARSE_C */
......
......@@ -44,6 +44,11 @@
#include "polarssl/ecdsa.h"