Add missing calls to psa_hash_abort in hash functions
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index c7d5a67..b94e0e6 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1110,6 +1110,7 @@
size_t hash_size,
size_t *hash_length )
{
+ psa_status_t status;
int ret;
size_t actual_hash_length = PSA_HASH_SIZE( operation->alg );
@@ -1123,7 +1124,10 @@
memset( hash, '!', hash_size );
if( hash_size < actual_hash_length )
- return( PSA_ERROR_BUFFER_TOO_SMALL );
+ {
+ status = PSA_ERROR_BUFFER_TOO_SMALL;
+ goto exit;
+ }
switch( operation->alg )
{
@@ -1168,8 +1172,10 @@
ret = MBEDTLS_ERR_MD_BAD_INPUT_DATA;
break;
}
+ status = mbedtls_to_psa_error( ret );
- if( ret == 0 )
+exit:
+ if( status == PSA_SUCCESS )
{
*hash_length = actual_hash_length;
return( psa_hash_abort( operation ) );
@@ -1177,7 +1183,7 @@
else
{
psa_hash_abort( operation );
- return( mbedtls_to_psa_error( ret ) );
+ return( status );
}
}