From c17e8a9bf242b1ce57cdfbb6f857d7faa0d0579e Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 19 Mar 2021 14:12:26 +0100 Subject: [PATCH] psa: cipher: Use PSA_CIPHER_IV_LENGTH to compute the IV length The IV length computed in the cipher PSA implementation is the default IV length thus use the PSA macro PSA_CIPHER_IV_LENGTH defined to do that. Signed-off-by: Ronald Cron --- library/psa_crypto_cipher.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index 464bd57782..4d46aaf869 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -221,17 +221,7 @@ static psa_status_t cipher_setup( operation->block_length = ( PSA_ALG_IS_STREAM_CIPHER( alg ) ? 1 : PSA_BLOCK_CIPHER_BLOCK_LENGTH( key_type ) ); - if( ( alg & PSA_ALG_CIPHER_FROM_BLOCK_FLAG ) != 0 && - alg != PSA_ALG_ECB_NO_PADDING ) - { - operation->iv_length = PSA_BLOCK_CIPHER_BLOCK_LENGTH( key_type ); - } -#if defined(BUILTIN_KEY_TYPE_CHACHA20) - else - if( ( alg == PSA_ALG_STREAM_CIPHER ) && - ( key_type == PSA_KEY_TYPE_CHACHA20 ) ) - operation->iv_length = 12; -#endif + operation->iv_length = PSA_CIPHER_IV_LENGTH( key_type, alg ); exit: return( mbedtls_to_psa_error( ret ) );