psa_hmac_start: simplify key_length logic in hash-the-key case

This commit is contained in:
Gilles Peskine 2018-06-11 17:38:53 +02:00 committed by itayzafrir
parent e1bc6800cc
commit c102e3ce4b

View file

@ -1069,7 +1069,6 @@ static int psa_hmac_start( psa_mac_operation_t *operation,
unsigned char ipad[PSA_CRYPTO_MD_BLOCK_SIZE]; unsigned char ipad[PSA_CRYPTO_MD_BLOCK_SIZE];
unsigned char *opad = operation->ctx.hmac.hmac_ctx; unsigned char *opad = operation->ctx.hmac.hmac_ctx;
size_t i; size_t i;
size_t sum_size = MBEDTLS_MD_MAX_SIZE;
size_t block_size = size_t block_size =
PSA_HASH_BLOCK_SIZE( ( PSA_ALG_HMAC_HASH( alg ) ) ); PSA_HASH_BLOCK_SIZE( ( PSA_ALG_HMAC_HASH( alg ) ) );
unsigned int digest_size = unsigned int digest_size =
@ -1099,11 +1098,9 @@ static int psa_hmac_start( psa_mac_operation_t *operation,
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); return( status );
status = psa_hash_finish( &operation->ctx.hmac.hash_ctx, status = psa_hash_finish( &operation->ctx.hmac.hash_ctx,
sum, sum_size, &sum_size); sum, sizeof( sum ), &key_length );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); return( status );
key_length = sum_size;
key_ptr = sum; key_ptr = sum;
} }