From d588ea17042c4c0a212a2f61187859f6aa8a53cd Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Mon, 11 Jan 2021 19:36:04 +0100 Subject: [PATCH] Allow skipping AES-192 for alternative implementations in PSA test suite Signed-off-by: Steven Cooreman --- tests/suites/test_suite_psa_crypto.function | 56 +++++++++++++++------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index ef35d578f..786789287 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4061,6 +4061,7 @@ void aead_encrypt( int key_type_arg, data_t *key_data, size_t output_length = 0; size_t tag_length = PSA_AEAD_TAG_LENGTH( alg ); psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; output_size = input_data->len + tag_length; /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE @@ -4078,13 +4079,26 @@ void aead_encrypt( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, &key ) ); - PSA_ASSERT( psa_aead_encrypt( key, alg, - nonce->x, nonce->len, - additional_data->x, additional_data->len, - input_data->x, input_data->len, - output_data, output_size, - &output_length ) ); + status = psa_aead_encrypt( key, alg, + nonce->x, nonce->len, + additional_data->x, additional_data->len, + input_data->x, input_data->len, + output_data, output_size, + &output_length ); +#if defined(MBEDTLS_AES_ALT) || \ + defined(MBEDTLS_AES_SETKEY_ENC_ALT) || \ + defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_AES) + if( status == PSA_ERROR_NOT_SUPPORTED && + key_type == PSA_KEY_TYPE_AES && + key_data->len == 24 ) + { + test_skip( "AES-192 not supported", __LINE__, __FILE__ ); + goto exit; + } +#endif /* AES could be alternatively implemented */ + + PSA_ASSERT( status ); ASSERT_COMPARE( expected_result->x, expected_result->len, output_data, output_length ); @@ -4113,6 +4127,7 @@ void aead_decrypt( int key_type_arg, data_t *key_data, size_t tag_length = PSA_AEAD_TAG_LENGTH( alg ); psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t expected_result = expected_result_arg; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; output_size = input_data->len - tag_length; /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE @@ -4131,14 +4146,27 @@ void aead_decrypt( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, &key ) ); - TEST_EQUAL( psa_aead_decrypt( key, alg, - nonce->x, nonce->len, - additional_data->x, - additional_data->len, - input_data->x, input_data->len, - output_data, output_size, - &output_length ), - expected_result ); + status = psa_aead_decrypt( key, alg, + nonce->x, nonce->len, + additional_data->x, + additional_data->len, + input_data->x, input_data->len, + output_data, output_size, + &output_length ); + +#if defined(MBEDTLS_AES_ALT) || \ + defined(MBEDTLS_AES_SETKEY_ENC_ALT) || \ + defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_AES) + if( status == PSA_ERROR_NOT_SUPPORTED && + key_type == PSA_KEY_TYPE_AES && + key_data->len == 24 ) + { + test_skip( "AES-192 not supported", __LINE__, __FILE__ ); + goto exit; + } +#endif /* AES could be alternatively implemented */ + + TEST_EQUAL( status, expected_result ); if( expected_result == PSA_SUCCESS ) ASSERT_COMPARE( expected_data->x, expected_data->len,