Zeroize internal buffers and variables in PKCS and SHA

Zeroising of local buffers and variables which are used for calculations in
mbedtls_pkcs5_pbkdf2_hmac() and mbedtls_internal_sha*_process() functions
to erase sensitive data from memory.
Checked all function for possible missing zeroisation in PKCS and SHA.

Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
gabor-mezei-arm 2020-07-30 16:41:25 +02:00
parent fa3b3e0d88
commit d5253bba32
No known key found for this signature in database
GPG key ID: 106F5A41ECC305BD
5 changed files with 37 additions and 0 deletions

View file

@ -312,6 +312,19 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
ctx->state[6] += G;
ctx->state[7] += H;
/* Zeroise buffers and variables to clear sensitive data from memory. */
mbedtls_platform_zeroize( &A, sizeof( A ) );
mbedtls_platform_zeroize( &B, sizeof( B ) );
mbedtls_platform_zeroize( &C, sizeof( C ) );
mbedtls_platform_zeroize( &D, sizeof( D ) );
mbedtls_platform_zeroize( &E, sizeof( E ) );
mbedtls_platform_zeroize( &F, sizeof( F ) );
mbedtls_platform_zeroize( &G, sizeof( G ) );
mbedtls_platform_zeroize( &H, sizeof( H ) );
mbedtls_platform_zeroize( &W, sizeof( W ) );
mbedtls_platform_zeroize( &temp1, sizeof( temp1 ) );
mbedtls_platform_zeroize( &temp2, sizeof( temp2 ) );
return( 0 );
}