From 296eca6e76d986989bf2274a59e243fd0c59c661 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Tue, 10 Sep 2019 15:21:37 +0300 Subject: [PATCH] Fix a buffer overflow in hmac_setup_internal At the end of `psa_hmac_setup_internal()`, the ipad is cleared. However, the size that was given to clear was `key_len` which is larger than the size of `ipad`. --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index a80f13de3f..98239c32e4 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2735,7 +2735,7 @@ static psa_status_t psa_hmac_setup_internal( psa_hmac_internal_data *hmac, status = psa_hash_update( &hmac->hash_ctx, ipad, block_size ); cleanup: - mbedtls_platform_zeroize( ipad, key_length ); + mbedtls_platform_zeroize( ipad, sizeof(ipad) ); return( status ); }