From 87b0ac49f8a07bb887cac0e6189232bcfe7f6fe8 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 21 Aug 2018 14:55:49 +0200 Subject: [PATCH] Fix possible buffer overread in psa_mac_finish_internal (CMAC) --- 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 0aa19cf9d..410f64821 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1738,7 +1738,7 @@ static psa_status_t psa_mac_finish_internal( psa_mac_operation_t *operation, uint8_t tmp[PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE]; int ret = mbedtls_cipher_cmac_finish( &operation->ctx.cmac, tmp ); if( ret == 0 ) - memcpy( mac, tmp, mac_size ); + memcpy( mac, tmp, operation->mac_size ); mbedtls_zeroize( tmp, sizeof( tmp ) ); return( mbedtls_to_psa_error( ret ) ); }