From 6f0e72038d34bc7b26f42170f4bd8f38dfec7cf6 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 12:57:18 +0100 Subject: [PATCH] Align set nonce variables with psa convention Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 39 +++++++++++---------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 26c6c768e0..4ac4210602 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3771,7 +3771,7 @@ exit: /* BEGIN_CASE */ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, int alg_arg, - int nonce_len, + int nonce_length, int allow_null_nonce_buffer, data_t *additional_data, data_t *input_data, @@ -3786,11 +3786,11 @@ void aead_multipart_set_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; - unsigned char *output_data = NULL; - unsigned char *final_data = NULL; + 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]; int index = 0; @@ -3808,13 +3808,13 @@ void aead_multipart_set_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( ); @@ -3826,12 +3826,12 @@ void aead_multipart_set_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 ); - if( nonce_len == 0 ) + if( nonce_length == 0 ) { if( !allow_null_nonce_buffer ) { @@ -3841,15 +3841,15 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, } else { - ASSERT_ALLOC( nonce_buffer, nonce_len ); + ASSERT_ALLOC( nonce_buffer, nonce_length ); - for( index = 0; index < nonce_len - 1; ++index) + for( index = 0; index < nonce_length - 1; ++index) { nonce_buffer[index] = 'a' + index; } } - status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_len ); + status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_length ); TEST_EQUAL( status, expected_status ); @@ -3861,17 +3861,18 @@ void aead_multipart_set_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 ); mbedtls_free( nonce_buffer ); psa_aead_abort( &operation ); PSA_DONE( );