From 6f4e5bbe3735e0152205b7236ecd47acc08f945f Mon Sep 17 00:00:00 2001 From: gabor-mezei-arm Date: Fri, 25 Jun 2021 15:21:11 +0200 Subject: [PATCH] Initialize output buffer length to 0 Signed-off-by: gabor-mezei-arm --- library/psa_crypto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 509d53d871..c1517e5c1a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3495,6 +3495,8 @@ psa_status_t psa_cipher_encrypt( mbedtls_svc_key_id_t key, psa_key_type_t key_type; size_t iv_length; + *output_length = 0; + if( ! PSA_ALG_IS_CIPHER( alg ) ) return( PSA_ERROR_INVALID_ARGUMENT ); @@ -3547,6 +3549,8 @@ psa_status_t psa_cipher_decrypt( mbedtls_svc_key_id_t key, psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_slot_t *slot; + *output_length = 0; + if( ! PSA_ALG_IS_CIPHER( alg ) ) return( PSA_ERROR_INVALID_ARGUMENT );