From a609337ca04a85306ae875dfb584b8ccc9715bd6 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Mon, 19 Nov 2018 13:57:58 -0500 Subject: [PATCH] x509: remove unnecessary calls to psa_hash_abort According to the documentation, it does not need to be called after a failed psa_hash call. --- library/x509_crt.c | 2 -- library/x509write_csr.c | 7 ++----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/library/x509_crt.c b/library/x509_crt.c index 2e4a79658..92c052cc2 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1917,14 +1917,12 @@ static int x509_crt_check_signature( const mbedtls_x509_crt *child, if( psa_hash_update( &hash_operation, child->tbs.p, child->tbs.len ) != PSA_SUCCESS ) { - psa_hash_abort( &hash_operation ); return( -1 ); } if( psa_hash_finish( &hash_operation, hash, sizeof( hash ), &hash_len ) != PSA_SUCCESS ) { - psa_hash_abort( &hash_operation ); return( -1 ); } #endif /* MBEDTLS_USE_PSA_CRYPTO */ diff --git a/library/x509write_csr.c b/library/x509write_csr.c index 6270b6335..f2950ad2f 100644 --- a/library/x509write_csr.c +++ b/library/x509write_csr.c @@ -202,15 +202,12 @@ int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, s if( psa_hash_setup( &hash_operation, hash_alg ) != PSA_SUCCESS ) return( MBEDTLS_ERR_X509_FATAL_ERROR ); - if( psa_hash_update( &hash_operation, c, len) != PSA_SUCCESS ) - { - psa_hash_abort( &hash_operation ); + if( psa_hash_update( &hash_operation, c, len ) != PSA_SUCCESS ) return( MBEDTLS_ERR_X509_FATAL_ERROR ); - } + if( psa_hash_finish( &hash_operation, hash, sizeof( hash ), &hash_len ) != PSA_SUCCESS ) { - psa_hash_abort( &hash_operation ); return( MBEDTLS_ERR_X509_FATAL_ERROR ); } #else /* MBEDTLS_USE_PSA_CRYPTO */