From fbb4c6d9a249ebce03e89509676d92f589502d8d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 16:44:21 +0100 Subject: [PATCH] Replace AEAD operation init func with macro Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 33 +++++---------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 7c988067a..406509091 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -316,7 +316,7 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; unsigned char *output_data = NULL; unsigned char *part_data = NULL; unsigned char *final_data = NULL; @@ -391,9 +391,6 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, ASSERT_ALLOC( final_data, final_output_size ); - operation = psa_aead_operation_init( ); - - if( is_encrypt ) status = psa_aead_encrypt_setup( &operation, key, alg ); else @@ -3693,7 +3690,7 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; @@ -3729,8 +3726,6 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, ASSERT_ALLOC( ciphertext, ciphertext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -3792,7 +3787,7 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; uint8_t *nonce_buffer = NULL; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; @@ -3828,8 +3823,6 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, ASSERT_ALLOC( ciphertext, ciphertext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -3908,7 +3901,7 @@ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; 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; @@ -3937,8 +3930,6 @@ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, ASSERT_ALLOC( ciphertext, ciphertext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -3993,7 +3984,7 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; 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; @@ -4025,8 +4016,6 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, ASSERT_ALLOC( tag_buffer, tag_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -4079,7 +4068,7 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; 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; @@ -4112,8 +4101,6 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, ASSERT_ALLOC( finish_plaintext, verify_plaintext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_decrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -4166,7 +4153,7 @@ void aead_multipart_setup( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; 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; @@ -4181,8 +4168,6 @@ void aead_multipart_setup( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, &key ) ); - operation = psa_aead_operation_init( ); - mbedtls_test_set_step( 0 ); status = psa_aead_encrypt_setup( &operation, key, alg ); @@ -4214,7 +4199,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; unsigned char *output_data = NULL; unsigned char *final_data = NULL; size_t output_size = 0; @@ -4258,8 +4243,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test all operations error without calling setup first. */ - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_set_nonce( &operation, nonce->x, nonce->len ), PSA_ERROR_BAD_STATE );