From a393619dc2f69e33a69097444c0f5c4e78243a9c Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 6 Dec 2021 08:38:57 +0100 Subject: [PATCH] Change test on local nonce buffer size to an assertion Signed-off-by: Ronald Cron --- library/psa_crypto.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index daa34ffa34..d3a2865ab7 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3893,11 +3893,9 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, goto exit; } - if( required_nonce_size > sizeof( local_nonce ) ) - { - status = PSA_ERROR_GENERIC_ERROR; - goto exit; - } +#if defined(assert) + assert( required_nonce_size <= sizeof( local_nonce ) ); +#endif status = psa_generate_random( local_nonce, required_nonce_size ); if( status != PSA_SUCCESS )