aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Hu <david.hu@arm.com>2020-05-19 17:41:46 +0800
committerDavid Hu <david.hu@arm.com>2020-05-29 02:17:07 +0000
commit3650297e1cc7373dd5e21dde2b05444c0840f57f (patch)
tree44b14628dfed86c5c7759b1fd1dc193f8402f780 /test
parent06976a684cec9117113b3464f81571a08baa56c9 (diff)
downloadtrusted-firmware-m-3650297e1cc7373dd5e21dde2b05444c0840f57f.tar.gz
Test: Add test cases for AEAD with truncated authentication tag
Add Crypto test cases to verify AEAD interface with truncated authentication tag. Change-Id: Ied34592ed2ca1f23480720a15f0a178b691236c4 Signed-off-by: David Hu <david.hu@arm.com>
Diffstat (limited to 'test')
-rw-r--r--test/suites/crypto/crypto_tests_common.h5
-rw-r--r--test/suites/crypto/non_secure/crypto_ns_interface_testsuite.c18
-rw-r--r--test/suites/crypto/secure/crypto_sec_interface_testsuite.c18
3 files changed, 41 insertions, 0 deletions
diff --git a/test/suites/crypto/crypto_tests_common.h b/test/suites/crypto/crypto_tests_common.h
index f2b6bbeb6e..a9e012f624 100644
--- a/test/suites/crypto/crypto_tests_common.h
+++ b/test/suites/crypto/crypto_tests_common.h
@@ -59,6 +59,11 @@ extern "C" {
#define TEST_MAX_KEY_LENGTH (64)
/**
+ * \brief The length of truncated authentication tag for AEAD algorithm
+ */
+#define TRUNCATED_AUTH_TAG_LEN (8)
+
+/**
* \brief Tests the key interfaces with different key types
*
* \param[in] key_type PSA key type
diff --git a/test/suites/crypto/non_secure/crypto_ns_interface_testsuite.c b/test/suites/crypto/non_secure/crypto_ns_interface_testsuite.c
index f8448f1645..dcd3a6c883 100644
--- a/test/suites/crypto/non_secure/crypto_ns_interface_testsuite.c
+++ b/test/suites/crypto/non_secure/crypto_ns_interface_testsuite.c
@@ -48,6 +48,9 @@ static void tfm_crypto_test_6031(struct test_result_t *ret);
static void tfm_crypto_test_6032(struct test_result_t *ret);
static void tfm_crypto_test_6033(struct test_result_t *ret);
static void tfm_crypto_test_6034(struct test_result_t *ret);
+#ifdef TFM_CRYPTO_TEST_ALG_CCM
+static void tfm_crypto_test_6035(struct test_result_t *ret);
+#endif /* TFM_CRYPTO_TEST_ALG_CCM */
static struct test_t crypto_tests[] = {
{&tfm_crypto_test_6001, "TFM_CRYPTO_TEST_6001",
@@ -110,6 +113,11 @@ static struct test_t crypto_tests[] = {
"Non Secure key policy check permissions", {TEST_PASSED} },
{&tfm_crypto_test_6034, "TFM_CRYPTO_TEST_6034",
"Non Secure persistent key interface", {TEST_PASSED} },
+#ifdef TFM_CRYPTO_TEST_ALG_CCM
+ {&tfm_crypto_test_6035, "TFM_CRYPTO_TEST_6035",
+ "Non Secure AEAD interface with truncated auth tag (AES-128-CCM-8)",
+ {TEST_PASSED} },
+#endif /* TFM_CRYPTO_TEST_ALG_CCM */
};
void register_testsuite_ns_crypto_interface(struct test_suite_t *p_test_suite)
@@ -257,3 +265,13 @@ static void tfm_crypto_test_6034(struct test_result_t *ret)
{
psa_persistent_key_test(1, ret);
}
+
+#ifdef TFM_CRYPTO_TEST_ALG_CCM
+static void tfm_crypto_test_6035(struct test_result_t *ret)
+{
+ psa_algorithm_t alg = PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_CCM,
+ TRUNCATED_AUTH_TAG_LEN);
+
+ psa_aead_test(PSA_KEY_TYPE_AES, alg, ret);
+}
+#endif /* TFM_CRYPTO_TEST_ALG_GCM */
diff --git a/test/suites/crypto/secure/crypto_sec_interface_testsuite.c b/test/suites/crypto/secure/crypto_sec_interface_testsuite.c
index 1980346f3c..7e6eeaacfa 100644
--- a/test/suites/crypto/secure/crypto_sec_interface_testsuite.c
+++ b/test/suites/crypto/secure/crypto_sec_interface_testsuite.c
@@ -50,6 +50,9 @@ static void tfm_crypto_test_5032(struct test_result_t *ret);
static void tfm_crypto_test_5033(struct test_result_t *ret);
static void tfm_crypto_test_5034(struct test_result_t *ret);
static void tfm_crypto_test_5035(struct test_result_t *ret);
+#ifdef TFM_CRYPTO_TEST_ALG_CCM
+static void tfm_crypto_test_5036(struct test_result_t *ret);
+#endif /* TFM_CRYPTO_TEST_ALG_CCM */
static struct test_t crypto_tests[] = {
{&tfm_crypto_test_5001, "TFM_CRYPTO_TEST_5001",
@@ -114,6 +117,11 @@ static struct test_t crypto_tests[] = {
"Secure persistent key interface", {TEST_PASSED} },
{&tfm_crypto_test_5035, "TFM_CRYPTO_TEST_5035",
"Key access control", {TEST_PASSED} },
+#ifdef TFM_CRYPTO_TEST_ALG_CCM
+ {&tfm_crypto_test_5036, "TFM_CRYPTO_TEST_6036",
+ "Secure AEAD interface with truncated auth tag (AES-128-CCM-8)",
+ {TEST_PASSED} },
+#endif /* TFM_CRYPTO_TEST_ALG_CCM */
};
void register_testsuite_s_crypto_interface(struct test_suite_t *p_test_suite)
@@ -301,3 +309,13 @@ static void tfm_crypto_test_5035(struct test_result_t *ret)
}
return;
}
+
+#ifdef TFM_CRYPTO_TEST_ALG_CCM
+static void tfm_crypto_test_5036(struct test_result_t *ret)
+{
+ psa_algorithm_t alg = PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_CCM,
+ TRUNCATED_AUTH_TAG_LEN);
+
+ psa_aead_test(PSA_KEY_TYPE_AES, alg, ret);
+}
+#endif /* TFM_CRYPTO_TEST_ALG_GCM */