From c102e3ce4b6652b76bf0ca6520e04e3095a0cf41 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 11 Jun 2018 17:38:53 +0200 Subject: [PATCH] psa_hmac_start: simplify key_length logic in hash-the-key case --- library/psa_crypto.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 794af37f8..9fb80bb21 100755 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1069,7 +1069,6 @@ static int psa_hmac_start( psa_mac_operation_t *operation, unsigned char ipad[PSA_CRYPTO_MD_BLOCK_SIZE]; unsigned char *opad = operation->ctx.hmac.hmac_ctx; size_t i; - size_t sum_size = MBEDTLS_MD_MAX_SIZE; size_t block_size = PSA_HASH_BLOCK_SIZE( ( PSA_ALG_HMAC_HASH( alg ) ) ); unsigned int digest_size = @@ -1099,11 +1098,9 @@ static int psa_hmac_start( psa_mac_operation_t *operation, if( status != PSA_SUCCESS ) return( status ); status = psa_hash_finish( &operation->ctx.hmac.hash_ctx, - sum, sum_size, &sum_size); + sum, sizeof( sum ), &key_length ); if( status != PSA_SUCCESS ) return( status ); - - key_length = sum_size; key_ptr = sum; }