psa_hash_update: robustify the case length=0
Don't require hash implementations to behave correctly on a
zero-length input, which may have an invalid pointer.
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index eb140ea..47605d4 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1018,6 +1018,12 @@
size_t input_length )
{
int ret;
+
+ /* 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_MD2_C)
@@ -1068,6 +1074,7 @@
ret = MBEDTLS_ERR_MD_BAD_INPUT_DATA;
break;
}
+
if( ret != 0 )
psa_hash_abort( operation );
return( mbedtls_to_psa_error( ret ) );