xtest: add case 4010
Adds test case 4010 which implements a negative test with a too large
key for a secret key object.
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/host/xtest/xtest_4000.c b/host/xtest/xtest_4000.c
index d92296e..aa06ad5 100644
--- a/host/xtest/xtest_4000.c
+++ b/host/xtest/xtest_4000.c
@@ -39,6 +39,7 @@
static void xtest_tee_test_4007(ADBG_Case_t *Case_p);
static void xtest_tee_test_4008(ADBG_Case_t *Case_p);
static void xtest_tee_test_4009(ADBG_Case_t *Case_p);
+static void xtest_tee_test_4010(ADBG_Case_t *Case_p);
ADBG_CASE_DEFINE(XTEST_TEE_4001, xtest_tee_test_4001,
/* Title */
@@ -150,6 +151,17 @@
"Description of how to implement ..."
);
+ADBG_CASE_DEFINE(XTEST_TEE_4010, xtest_tee_test_4010,
+ /* Title */
+ "Test TEE Internal API create transient object (negative)",
+ /* Short description */
+ "Short description ...",
+ /* Requirement IDs */
+ "TEE-??",
+ /* How to implement */
+ "Description of how to implement ..."
+ );
+
static TEEC_Result ta_crypt_cmd_random_number_generate(ADBG_Case_t *c,
TEEC_Session *s,
void *buf, size_t blen);
@@ -4982,3 +4994,33 @@
noerror:
TEEC_CloseSession(&session);
}
+
+static void xtest_tee_test_4010(ADBG_Case_t *c)
+{
+ TEEC_Session session = { 0 };
+ uint32_t ret_orig;
+ TEE_ObjectHandle o;
+ static const uint8_t large_key[1024] = { 1, 2, 3, 4, 5, 6 };
+ static const TEE_Attribute attr = {
+ .attributeID = TEE_ATTR_SECRET_VALUE,
+ .content.ref.buffer = (void *)large_key,
+ .content.ref.length = sizeof(large_key),
+ };
+
+ if (!ADBG_EXPECT_TEEC_SUCCESS(c,
+ xtest_teec_open_session(&session, &crypt_user_ta_uuid, NULL,
+ &ret_orig)))
+ return;
+
+ if (!ADBG_EXPECT_TEEC_SUCCESS(c,
+ ta_crypt_cmd_allocate_transient_object(c, &session,
+ TEE_TYPE_HMAC_SHA256, 1024, &o)))
+ goto out;
+
+ ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_TARGET_DEAD,
+ ta_crypt_cmd_populate_transient_object(c, &session, o,
+ &attr, 1));
+
+out:
+ TEEC_CloseSession(&session);
+}
diff --git a/host/xtest/xtest_helpers.c b/host/xtest/xtest_helpers.c
index e4532f0..0ce5c63 100644
--- a/host/xtest/xtest_helpers.c
+++ b/host/xtest/xtest_helpers.c
@@ -224,7 +224,7 @@
res = TEEC_InvokeCommand(s, TA_CRYPT_CMD_POPULATE_TRANSIENT_OBJECT, &op,
&ret_orig);
- if (res != TEEC_SUCCESS) {
+ if (res != TEEC_SUCCESS && res != TEEC_ERROR_TARGET_DEAD) {
(void)ADBG_EXPECT_TEEC_ERROR_ORIGIN(c, TEEC_ORIGIN_TRUSTED_APP,
ret_orig);
}
diff --git a/host/xtest/xtest_main.c b/host/xtest/xtest_main.c
index 91e1eba..e1f8d3b 100644
--- a/host/xtest/xtest_main.c
+++ b/host/xtest/xtest_main.c
@@ -48,6 +48,7 @@
ADBG_SUITE_ENTRY(XTEST_TEE_4007, NULL)
ADBG_SUITE_ENTRY(XTEST_TEE_4008, NULL)
ADBG_SUITE_ENTRY(XTEST_TEE_4009, NULL)
+ADBG_SUITE_ENTRY(XTEST_TEE_4010, NULL)
/* FVP ADBG_SUITE_ENTRY(XTEST_TEE_5006, NULL) */
#ifdef USER_SPACE
ADBG_SUITE_ENTRY(XTEST_TEE_6001, NULL)
diff --git a/host/xtest/xtest_test.h b/host/xtest/xtest_test.h
index 0863fa5..8f2ac7f 100644
--- a/host/xtest/xtest_test.h
+++ b/host/xtest/xtest_test.h
@@ -42,6 +42,7 @@
ADBG_CASE_DECLARE(XTEST_TEE_4007);
ADBG_CASE_DECLARE(XTEST_TEE_4008);
ADBG_CASE_DECLARE(XTEST_TEE_4009);
+ADBG_CASE_DECLARE(XTEST_TEE_4010);
ADBG_CASE_DECLARE(XTEST_TEE_5006);