xtest: pkcs11 test through libckteec and the PKCS11 TA
Introduce pkcs11 tests for PKCS#11 services through the PKCS11 TA.
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Victor Chong <victor.chong@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/host/xtest/pkcs11_1000.c b/host/xtest/pkcs11_1000.c
new file mode 100644
index 0000000..d2805e0
--- /dev/null
+++ b/host/xtest/pkcs11_1000.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018, Linaro Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include <pkcs11.h>
+
+#include "xtest_test.h"
+#include "xtest_helpers.h"
+
+static void xtest_tee_test_1000(ADBG_Case_t *c)
+{
+ CK_RV rv;
+
+ rv = C_Initialize(NULL);
+ if (!ADBG_EXPECT_CK_OK(c, rv))
+ return;
+
+ rv = C_Finalize(NULL);
+ if (!ADBG_EXPECT_CK_OK(c, rv))
+ return;
+
+ rv = C_Initialize(NULL);
+ if (!ADBG_EXPECT_CK_OK(c, rv))
+ return;
+
+ rv = C_Initialize(NULL);
+ ADBG_EXPECT_CK_RESULT(c, CKR_CRYPTOKI_ALREADY_INITIALIZED, rv);
+
+ rv = C_Finalize(NULL);
+ ADBG_EXPECT_CK_OK(c, rv);
+}
+
+ADBG_CASE_DEFINE(pkcs11, 1000, xtest_tee_test_1000,
+ "Initialize and close Cryptoki library");