From f127763ec9d234ec50adb01c9697649fdcb2395f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 24 Aug 2021 18:11:37 +0100 Subject: [PATCH] Align generate nonce variables with psa convention Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 45 +++++++++++---------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 58e43870b..26c6c768e 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3671,8 +3671,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, /* BEGIN_CASE */ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, int alg_arg, - int nonce_len, - int expected_generated_len_arg, + int nonce_length, + int expected_nonce_length_arg, data_t *additional_data, data_t *input_data, int expected_status_arg ) @@ -3686,13 +3686,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; - size_t nonce_generated_len = 0; - size_t expected_generated_len = expected_generated_len_arg; - unsigned char *output_data = NULL; - unsigned char *final_data = NULL; + size_t actual_nonce_length = 0; + size_t expected_nonce_length = expected_nonce_length_arg; + unsigned char *output = NULL; + unsigned char *ciphertext = NULL; size_t output_size = 0; - size_t finish_output_size = 0; - size_t output_length = 0; + size_t ciphertext_size = 0; + size_t ciphertext_length = 0; size_t tag_length = 0; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; @@ -3709,13 +3709,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); - ASSERT_ALLOC( output_data, output_size ); + ASSERT_ALLOC( output, output_size ); - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + ciphertext_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + TEST_ASSERT( ciphertext_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - ASSERT_ALLOC( final_data, finish_output_size ); + ASSERT_ALLOC( ciphertext, ciphertext_size ); operation = psa_aead_operation_init( ); @@ -3727,20 +3727,20 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, if( status == PSA_ERROR_NOT_SUPPORTED ) { MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_len ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_length ); } PSA_ASSERT( status ); status = psa_aead_generate_nonce( &operation, nonce_buffer, - nonce_len, - &nonce_generated_len ); + nonce_length, + &actual_nonce_length ); TEST_EQUAL( status, expected_status ); - TEST_EQUAL( nonce_generated_len, expected_generated_len ); + TEST_EQUAL( actual_nonce_length, expected_nonce_length ); - TEST_ASSERT( nonce_generated_len < PSA_AEAD_NONCE_MAX_SIZE ); + TEST_ASSERT( actual_nonce_length < PSA_AEAD_NONCE_MAX_SIZE ); if( expected_status == PSA_SUCCESS ) { @@ -3751,17 +3751,18 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, additional_data->len ) ); PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, - output_data, output_size, &output_length ) ); + output, output_size, + &ciphertext_length ) ); - PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size, - &output_length, tag_buffer, + PSA_ASSERT( psa_aead_finish( &operation, ciphertext, ciphertext_size, + &ciphertext_length, tag_buffer, PSA_AEAD_TAG_MAX_SIZE, &tag_length ) ); } exit: psa_destroy_key( key ); - mbedtls_free( output_data ); - mbedtls_free( final_data ); + mbedtls_free( output ); + mbedtls_free( ciphertext ); psa_aead_abort( &operation ); PSA_DONE( ); }