psa_hmac_setup_internal: add some missing cleanup on failure

Clean ipad if hashing the key failed.
This commit is contained in:
Gilles Peskine 2018-07-17 16:24:34 +02:00 committed by itayzafrir
parent 9688997301
commit b8be288374

View File

@ -1429,11 +1429,11 @@ static psa_status_t psa_hmac_setup_internal( psa_hmac_internal_data *hmac,
{ {
status = psa_hash_update( &hmac->hash_ctx, key, key_length ); status = psa_hash_update( &hmac->hash_ctx, key, key_length );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); goto cleanup;
status = psa_hash_finish( &hmac->hash_ctx, status = psa_hash_finish( &hmac->hash_ctx,
ipad, sizeof( ipad ), &key_length ); ipad, sizeof( ipad ), &key_length );
if( status != PSA_SUCCESS ) if( status != PSA_SUCCESS )
return( status ); goto cleanup;
} }
/* A 0-length key is not commonly used in HMAC when used as a MAC, /* A 0-length key is not commonly used in HMAC when used as a MAC,
* but it is permitted. It is common when HMAC is used in HKDF, for * but it is permitted. It is common when HMAC is used in HKDF, for