From c8288354a210c7908d603a2507082dce96a57a5a Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Thu, 4 Mar 2021 14:02:19 +0100 Subject: [PATCH] move hash update zero-length-input check back into the core Signed-off-by: Steven Cooreman --- library/psa_crypto.c | 5 +++++ library/psa_crypto_hash.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9c645efb69..c5f9601f86 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2226,6 +2226,11 @@ psa_status_t psa_hash_update( psa_hash_operation_t *operation, if( operation->id == 0 ) return( PSA_ERROR_BAD_STATE ); + /* Don't require hash implementations to behave correctly on a + * zero-length input, which may have an invalid pointer. */ + if( input_length == 0 ) + return( PSA_SUCCESS ); + psa_status_t status = psa_driver_wrapper_hash_update( operation, input, input_length ); if( status != PSA_SUCCESS ) diff --git a/library/psa_crypto_hash.c b/library/psa_crypto_hash.c index deb13c2155..8ac21d0cb6 100644 --- a/library/psa_crypto_hash.c +++ b/library/psa_crypto_hash.c @@ -216,11 +216,6 @@ psa_status_t mbedtls_psa_hash_update( { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - /* Don't require hash implementations to behave correctly on a - * zero-length input, which may have an invalid pointer. */ - if( input_length == 0 ) - return( PSA_SUCCESS ); - switch( operation->alg ) { #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD2)