From 8d225a50400d3f288b77d5d9b3638a3db7cee51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= Date: Wed, 6 Dec 2023 13:36:55 +0200 Subject: [PATCH] xtest: pkcs11: Add check that CK_TOKEN_INFO outputs correct CK_ULONG's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OP-TEE's PKCS#11 TA TEE<->REE interface treats CK_ULONG's as 32 bit. In 64 bit machines this creates a problem for CK_ULONG values that are architecture dependent. One of those defines is CK_UNAVAILABLE_INFORMATION. This adds test case to make sure that when OP-TEE's PKCS#11 TA should give CK_UNAVAILABLE_INFORMATION it actually does that. Signed-off-by: Vesa Jääskeläinen --- host/xtest/pkcs11_1000.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/host/xtest/pkcs11_1000.c b/host/xtest/pkcs11_1000.c index 0282332af..b967d8538 100644 --- a/host/xtest/pkcs11_1000.c +++ b/host/xtest/pkcs11_1000.c @@ -309,6 +309,36 @@ static void xtest_pkcs11_test_1001(ADBG_Case_t *c) if (!ADBG_EXPECT_CK_OK(c, rv)) goto out; + /** + * Verify that fields with CK_UNAVAILABLE_INFORMATION gets + * correct value + */ + + if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, + token_info.ulMaxSessionCount, ==, + CK_UNAVAILABLE_INFORMATION)) + goto out; + if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, + token_info.ulMaxRwSessionCount, ==, + CK_UNAVAILABLE_INFORMATION)) + goto out; + if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, + token_info.ulTotalPublicMemory, ==, + CK_UNAVAILABLE_INFORMATION)) + goto out; + if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, + token_info.ulFreePublicMemory, ==, + CK_UNAVAILABLE_INFORMATION)) + goto out; + if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, + token_info.ulTotalPrivateMemory, ==, + CK_UNAVAILABLE_INFORMATION)) + goto out; + if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, + token_info.ulFreePrivateMemory, ==, + CK_UNAVAILABLE_INFORMATION)) + goto out; + if (max_slot_id < slot) max_slot_id = slot; }