From 262f5f4771977719eb9d2eda3a0ac39bc43e668a Mon Sep 17 00:00:00 2001 From: Alessio Di Mauro Date: Tue, 24 Nov 2015 16:56:17 +0100 Subject: [PATCH] Make ykcs11 functions pointer global to all tests. --- ykcs11/tests/ykcs11_tests.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ykcs11/tests/ykcs11_tests.c b/ykcs11/tests/ykcs11_tests.c index 2db0a36..f644b7c 100644 --- a/ykcs11/tests/ykcs11_tests.c +++ b/ykcs11/tests/ykcs11_tests.c @@ -2,12 +2,15 @@ #include #include +#include #define MANUFACTURER_ID "Yubico (www.yubico.com)" #define YKCS11_DESCRIPTION "PKCS#11 PIV Library (SP-800-73)" #define CRYPTOKI_VERSION_MAJ 2 #define CRYPTOKI_VERSION_MIN 40 +CK_FUNCTION_LIST_PTR funcs; + static void get_functions(CK_FUNCTION_LIST_PTR_PTR funcs) { if (C_GetFunctionList(funcs) != CKR_OK) { @@ -20,9 +23,6 @@ static void get_functions(CK_FUNCTION_LIST_PTR_PTR funcs) { static void test_lib_info() { CK_INFO info; - CK_FUNCTION_LIST_PTR funcs; - - get_functions(&funcs); if (funcs->C_GetInfo(&info) != CKR_OK) { fprintf(stderr, "GetInfo failed\n"); @@ -55,10 +55,6 @@ static void test_lib_info() { static void test_initalize() { - CK_FUNCTION_LIST_PTR funcs; - - get_functions(&funcs); - if (funcs->C_Initialize(NULL) != CKR_OK) { fprintf(stderr, "Unable to initialize YKCS11\n"); exit(EXIT_FAILURE); @@ -71,12 +67,25 @@ static void test_initalize() { } +static void test_token_info() { + + CK_TOKEN_INFO info; + + assert(funcs->C_GetTokenInfo(0, &info) == CKR_OK); + /*fprintf + }*/ + +} + int main(void) { + get_functions(&funcs); + test_lib_info(); #ifdef HW_TESTS test_initalize(); + test_token_info(); #endif return EXIT_SUCCESS;