From ae382791fba342d5a630b727f7ad144f053ad03a Mon Sep 17 00:00:00 2001 From: Moran Peker Date: Thu, 31 May 2018 14:06:17 +0300 Subject: [PATCH] add missing psa_cipher_abort( operation ) --- library/psa_crypto.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 56f3e1d4e..a85b16845 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1356,7 +1356,8 @@ static psa_status_t psa_cipher_setup(psa_cipher_operation_t *operation, mode = MBEDTLS_PADDING_NONE; break; default: - return ( PSA_ERROR_INVALID_ARGUMENT ); + psa_cipher_abort( operation ); + return( PSA_ERROR_INVALID_ARGUMENT ); } ret = mbedtls_cipher_set_padding_mode( &operation->ctx.cipher, mode ); if( ret != 0 ) @@ -1430,10 +1431,8 @@ psa_status_t psa_encrypt_set_iv(psa_cipher_operation_t *operation, return( PSA_ERROR_BAD_STATE ); if( iv_length != operation->iv_size ) { - if( ( ( operation->alg ) & PSA_ALG_ARC4 ) == PSA_ALG_ARC4 ) - return( PSA_ERROR_BAD_STATE ); - else - return( PSA_ERROR_INVALID_ARGUMENT ); + psa_cipher_abort( operation ); + return( PSA_ERROR_INVALID_ARGUMENT ); } ret = mbedtls_cipher_set_iv( &operation->ctx.cipher, iv, iv_length ); if( ret != 0 )