From 3ee335dbe315d909d3ba80e3c1fc9bec7a3790fb Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Mon, 7 Feb 2022 14:51:37 +0100 Subject: [PATCH] Add Cipher Encrypt multi-part case Signed-off-by: Neil Armstrong --- tests/suites/test_suite_psa_crypto.function | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index d05a2de44..7a9c2160b 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3145,6 +3145,7 @@ void cipher_encrypt_alg_without_iv( int alg_arg, &iv_length ), PSA_ERROR_BAD_STATE ); + /* Encrypt, one-shot */ PSA_ASSERT( psa_cipher_encrypt( key, alg, input->x, input->len, output, output_buffer_size, &output_length ) ); TEST_ASSERT( output_length <= @@ -3154,7 +3155,24 @@ void cipher_encrypt_alg_without_iv( int alg_arg, ASSERT_COMPARE( expected_output->x, expected_output->len, output, output_length ); + + /* Encrypt, multi-part */ + PSA_ASSERT( psa_cipher_abort( &operation ) ); + PSA_ASSERT( psa_cipher_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_cipher_update( &operation, input->x, input->len, + output, output_buffer_size, + &output_length) ); + TEST_ASSERT( output_length <= + PSA_CIPHER_ENCRYPT_OUTPUT_SIZE( key_type, alg, input->len ) ); + TEST_ASSERT( output_length <= + PSA_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE( input->len ) ); + + ASSERT_COMPARE( expected_output->x, expected_output->len, + output, output_length ); + exit: + PSA_ASSERT( psa_cipher_abort( &operation ) ); mbedtls_free( output ); psa_destroy_key( key ); PSA_DONE( );