Skip to content

Commit

Permalink
xtest: pkcs11_1001: Test CK_UNAVAILABLE_INFORMATION output value
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vesajaaskelainen committed Feb 4, 2024
1 parent 9d56621 commit 2d80c07
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions host/xtest/pkcs11_1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,36 @@ static void xtest_pkcs11_test_1001(ADBG_Case_t *c)
if (!ADBG_EXPECT_CK_OK(c, rv))
goto out;

/**
* OP-TEE's PKCS#11 implementaion always responds with
* CK_UNAVAILABLE_INFORMATION for fields:
*
* - ulMaxSessionCount
* - ulMaxRwSessionCount
* - ulTotalPublicMemory
* - ulFreePublicMemory
*
* Verify that CK_UNAVAILABLE_INFORMATION is correctly
* translated (32 bit vs 64 bit difference).
*/

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 (max_slot_id < slot)
max_slot_id = slot;
}
Expand Down

0 comments on commit 2d80c07

Please sign in to comment.