diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 6bce6bb999..b3defc8e21 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2064,7 +2064,7 @@ depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_decrypt_fail:PSA_ALG_CBC_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a":"6bc1bee223":PSA_ERROR_INVALID_ARGUMENT PSA symetric decrypt: CCM*-no-tag, input too short (15 bytes) -depends_on:MBEDTLS_AES_C +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C cipher_decrypt_fail:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"19ebfde2d5468ba0a3031bde629b11fd":"5a8aa485c316e9":"2a2a2a2a2a2a2a2a":PSA_ERROR_INVALID_ARGUMENT PSA symmetric decrypt: AES-ECB, 0 bytes, good diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 40dca9d0cb..af6ef7942a 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3561,8 +3561,11 @@ void cipher_decrypt_fail( int alg_arg, unsigned char *input = NULL; size_t input_buffer_size = 0; unsigned char *output = NULL; + unsigned char *output_multi = NULL; size_t output_buffer_size = 0; size_t output_length = 0; + size_t function_output_length; + psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; if ( PSA_ERROR_BAD_STATE != expected_status ) @@ -3589,13 +3592,65 @@ void cipher_decrypt_fail( int alg_arg, output_buffer_size = PSA_CIPHER_DECRYPT_OUTPUT_SIZE( key_type, alg, input_buffer_size ); ASSERT_ALLOC( output, output_buffer_size ); + /* Decrypt, one-short */ status = psa_cipher_decrypt( key, alg, input, input_buffer_size, output, output_buffer_size, &output_length ); TEST_EQUAL( status, expected_status ); + /* Decrypt, multi-part */ + status = psa_cipher_decrypt_setup( &operation, key, alg ); + if( status == PSA_SUCCESS ) + { + output_buffer_size = PSA_CIPHER_UPDATE_OUTPUT_SIZE( key_type, alg, + input_arg->len ) + + PSA_CIPHER_FINISH_OUTPUT_SIZE( key_type, alg ); + ASSERT_ALLOC( output_multi, output_buffer_size ); + + if( iv->len > 0 ) + { + status = psa_cipher_set_iv( &operation, iv->x, iv->len ); + + if( status != PSA_SUCCESS ) + TEST_EQUAL( status, expected_status ); + } + + if( status == PSA_SUCCESS ) + { + status = psa_cipher_update( &operation, + input_arg->x, input_arg->len, + output_multi, output_buffer_size, + &function_output_length ); + if( status == PSA_SUCCESS ) + { + output_length = function_output_length; + + status = psa_cipher_finish( &operation, + output_multi + output_length, + output_buffer_size - output_length, + &function_output_length ); + + TEST_EQUAL( status, expected_status ); + } + else + { + TEST_EQUAL( status, expected_status ); + } + } + else + { + TEST_EQUAL( status, expected_status ); + } + } + else + { + TEST_EQUAL( status, expected_status ); + } + exit: + psa_cipher_abort( &operation ); mbedtls_free( input ); mbedtls_free( output ); + mbedtls_free( output_multi ); psa_destroy_key( key ); PSA_DONE( ); }