From 2a18f56b4ef20d763d4e0468186e9a832d53301a Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Fri, 7 May 2021 15:44:46 +0200 Subject: [PATCH] Remove superfluous checking from MAC driver The PSA core checks the key type and algorithm combination before calling the driver, so the driver doesn't have to do this once more. The PSA core will also not start an operation with a requested length which is larger than the full MAC output size, so the output length check in the driver isn't needed as long as the driver returns an error on mac_setup if it doesn't support the underlying hash algorithm. Signed-off-by: Steven Cooreman --- library/psa_crypto_mac.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/library/psa_crypto_mac.c b/library/psa_crypto_mac.c index 6753dedf54..32ab88535d 100644 --- a/library/psa_crypto_mac.c +++ b/library/psa_crypto_mac.c @@ -329,20 +329,6 @@ static psa_status_t mac_setup( mbedtls_psa_mac_operation_t *operation, #if defined(BUILTIN_ALG_HMAC) if( PSA_ALG_IS_HMAC( alg ) ) { - /* Sanity check. This shouldn't fail on a valid configuration. */ - if( PSA_MAC_LENGTH( psa_get_key_type( attributes ), 0, alg ) > - sizeof( operation->ctx.hmac.opad ) ) - { - status = PSA_ERROR_NOT_SUPPORTED; - goto exit; - } - - if( psa_get_key_type( attributes ) != PSA_KEY_TYPE_HMAC ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } - status = psa_hmac_setup_internal( &operation->ctx.hmac, key_buffer, key_buffer_size,