diff options
author | David Hu <david.hu@arm.com> | 2022-06-21 22:23:47 +0800 |
---|---|---|
committer | Anton Komlev <Anton.Komlev@arm.com> | 2022-06-29 14:47:52 +0200 |
commit | 03b5608b988cf02c90f311537ffb64c098c5627c (patch) | |
tree | 0a514aac5f65fdb3a44d54abd72dc1a69828b0cf | |
parent | fdbc63741be5e8b8117d7758b627db2e1c482efa (diff) | |
download | tf-m-tests-03b5608b988cf02c90f311537ffb64c098c5627c.tar.gz |
Test: Disable single-part operation tests in Profile Small
Enable support multi-part operation tests in Profile Small to align
with TF-M changes.
Signed-off-by: David Hu <david.hu@arm.com>
Change-Id: If8aa59238f4ec37ccef8c414760c863272e5df1e
-rw-r--r-- | test/config/default_test_config.cmake | 1 | ||||
-rw-r--r-- | test/config/profile/profile_small_test.cmake | 1 | ||||
-rw-r--r-- | test/secure_fw/suites/crypto/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/secure_fw/suites/crypto/crypto_tests_common.c | 12 |
4 files changed, 15 insertions, 0 deletions
diff --git a/test/config/default_test_config.cmake b/test/config/default_test_config.cmake index 0ddef9cc..599d9ab8 100644 --- a/test/config/default_test_config.cmake +++ b/test/config/default_test_config.cmake @@ -64,6 +64,7 @@ set(TFM_CRYPTO_TEST_HKDF ON CACHE BOOL "Test th set(TFM_CRYPTO_TEST_ECDH ON CACHE BOOL "Test the ECDH key agreement algorithm") set(TFM_CRYPTO_TEST_CHACHA20 OFF CACHE BOOL "Test the ChaCha20 stream cipher") set(TFM_CRYPTO_TEST_ALG_CHACHA20_POLY1305 OFF CACHE BOOL "Test ChaCha20-Poly1305 AEAD algorithm") +set(TFM_CRYPTO_TEST_SINGLE_PART_FUNCS ON CACHE BOOL "Test single-part operations in hash, MAC, AEAD and symmetric ciphers") ################################## FWU Tests ################################### diff --git a/test/config/profile/profile_small_test.cmake b/test/config/profile/profile_small_test.cmake index 177b1d18..fcc122d7 100644 --- a/test/config/profile/profile_small_test.cmake +++ b/test/config/profile/profile_small_test.cmake @@ -19,3 +19,4 @@ set(TFM_CRYPTO_TEST_HKDF OFF CACHE BOOL "Test th set(TFM_CRYPTO_TEST_ECDH OFF CACHE BOOL "Test the ECDH key agreement algorithm") set(TFM_CRYPTO_TEST_CHACHA20 OFF CACHE BOOL "Test the ChaCha20 stream cipher") set(TFM_CRYPTO_TEST_ALG_CHACHA20_POLY1305 OFF CACHE BOOL "Test ChaCha20-Poly1305 AEAD algorithm") +set(TFM_CRYPTO_TEST_SINGLE_PART_FUNCS OFF CACHE BOOL "Test single-part operations in hash, MAC, AEAD and symmetric ciphers") diff --git a/test/secure_fw/suites/crypto/CMakeLists.txt b/test/secure_fw/suites/crypto/CMakeLists.txt index aa589235..20e84d93 100644 --- a/test/secure_fw/suites/crypto/CMakeLists.txt +++ b/test/secure_fw/suites/crypto/CMakeLists.txt @@ -54,6 +54,7 @@ if (TEST_NS_CRYPTO) $<$<NOT:$<BOOL:${CRYPTO_ASYM_ENCRYPT_MODULE_DISABLED}>>:TFM_CRYPTO_TEST_ASYM_ENCRYPT> $<$<BOOL:${TFM_CRYPTO_TEST_CHACHA20}>:TFM_CRYPTO_TEST_CHACHA20> $<$<BOOL:${TFM_CRYPTO_TEST_ALG_CHACHA20_POLY1305}>:TFM_CRYPTO_TEST_ALG_CHACHA20_POLY1305> + $<$<BOOL:${TFM_CRYPTO_TEST_SINGLE_PART_FUNCS}>:TFM_CRYPTO_TEST_SINGLE_PART_FUNCS> INTERFACE TEST_NS_CRYPTO ) diff --git a/test/secure_fw/suites/crypto/crypto_tests_common.c b/test/secure_fw/suites/crypto/crypto_tests_common.c index 7c8c5ca2..c31e0e5b 100644 --- a/test/secure_fw/suites/crypto/crypto_tests_common.c +++ b/test/secure_fw/suites/crypto/crypto_tests_common.c @@ -1000,6 +1000,7 @@ void psa_cipher_test(const psa_key_type_t key_type, psa_reset_key_attributes(&key_attributes); +#ifdef TFM_CRYPTO_TEST_SINGLE_PART_FUNCS /* Encrypt single part functions */ status = psa_cipher_encrypt(key_id_local, alg, plain_text, sizeof(plain_text), @@ -1050,6 +1051,7 @@ void psa_cipher_test(const psa_key_type_t key_type, /* Clear intermediate buffers for additional single-shot API tests */ memset(input.encrypted_data_pad, 0, sizeof(input.encrypted_data_pad)); memset(decrypted_data, 0, sizeof(decrypted_data)); +#endif /* TFM_CRYPTO_TEST_SINGLE_PART_FUNCS */ /* Replicate the same test as above, but now using the multipart APIs */ @@ -1125,6 +1127,7 @@ void psa_cipher_test(const psa_key_type_t key_type, /* Add the last output produced, it might be encrypted padding */ total_output_length += output_length; +#ifdef TFM_CRYPTO_TEST_SINGLE_PART_FUNCS /* Compare encrypted data produced with single-shot and multipart APIs */ comp_result = memcmp(encrypted_data_single_shot, input.encrypted_data, @@ -1133,6 +1136,7 @@ void psa_cipher_test(const psa_key_type_t key_type, TEST_FAIL("Single-shot crypt doesn't match with multipart crypt"); goto destroy_key; } +#endif /* TFM_CRYPTO_TEST_SINGLE_PART_FUNCS */ /* Setup the decryption object */ status = psa_cipher_decrypt_setup(&handle_dec, key_id_local, alg); @@ -1377,6 +1381,7 @@ void psa_hash_test(const psa_algorithm_t alg, return; } +#ifdef TFM_CRYPTO_TEST_SINGLE_PART_FUNCS /* Do the same as above with the single shot APIs */ status = psa_hash_compare(alg, (const uint8_t *)msg, strlen(msg), @@ -1385,6 +1390,7 @@ void psa_hash_test(const psa_algorithm_t alg, TEST_FAIL("Error using the single shot API"); return; } +#endif ret->val = TEST_PASSED; } @@ -1550,6 +1556,7 @@ void psa_mac_test(const psa_algorithm_t alg, goto destroy_key_mac; } +#ifdef TFM_CRYPTO_TEST_SINGLE_PART_FUNCS /* Do the same as above with the single shot APIs */ status = psa_mac_verify(key_id_local, alg, (const uint8_t *)msg, strlen(msg), @@ -1558,6 +1565,7 @@ void psa_mac_test(const psa_algorithm_t alg, if (status != PSA_SUCCESS) { TEST_FAIL("Error using the single shot API"); } +#endif destroy_key_mac: /* Destroy the key */ @@ -1634,6 +1642,7 @@ void psa_aead_test(const psa_key_type_t key_type, psa_reset_key_attributes(&retrieved_attributes); +#ifdef TFM_CRYPTO_TEST_SINGLE_PART_FUNCS /* Perform AEAD encryption */ status = psa_aead_encrypt(key_id_local, alg, nonce, nonce_length, associated_data, @@ -1700,6 +1709,7 @@ void psa_aead_test(const psa_key_type_t key_type, TEST_FAIL("Decrypted data doesn't match with plain text"); goto destroy_key_aead; } +#endif /* TFM_CRYPTO_TEST_SINGLE_PART_FUNCS */ /* Setup the encryption object */ status = psa_aead_encrypt_setup(&encop, key_id_local, alg); @@ -1821,6 +1831,7 @@ void psa_aead_test(const psa_key_type_t key_type, } total_encrypted_length += encrypted_data_length; +#ifdef TFM_CRYPTO_TEST_SINGLE_PART_FUNCS /* Compare tag between single part and multipart case */ comp_result = memcmp( &encrypted_data_single_shot[total_encrypted_length], @@ -1838,6 +1849,7 @@ void psa_aead_test(const psa_key_type_t key_type, TEST_FAIL("Single shot encrypted data does not match with multipart"); goto destroy_key_aead; } +#endif /* TFM_CRYPTO_TEST_SINGLE_PART_FUNCS */ /* Setup up the decryption object */ status = psa_aead_decrypt_setup(&decop, key_id_local, alg); |