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>
diff --git a/library/sha1.c b/library/sha1.c
index 83ef9bd..65841ee 100644
--- a/library/sha1.c
+++ b/library/sha1.c
@@ -300,6 +300,15 @@
ctx->state[3] += D;
ctx->state[4] += E;
+ /* Zeroise buffers and variables to clear sensitive data from memory. */
+ mbedtls_zeroize( &A, sizeof( A ) );
+ mbedtls_zeroize( &B, sizeof( B ) );
+ mbedtls_zeroize( &C, sizeof( C ) );
+ mbedtls_zeroize( &D, sizeof( D ) );
+ mbedtls_zeroize( &E, sizeof( E ) );
+ mbedtls_zeroize( &W, sizeof( W ) );
+ mbedtls_zeroize( &temp, sizeof( temp ) );
+
return( 0 );
}