Skip to content

Commit

Permalink
YKCS11: Code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed May 22, 2024
1 parent 0318bcb commit 6e7cc82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ykcs11/tests/ykcs11_interfaces_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void get_default_functions() {
funcs = interface->pFunctionList;
}

static void get_named_functions(CK_UTF8CHAR_PTR name) {
static void get_named_functions() {
CK_INTERFACE_PTR interface;
asrt(C_GetInterface((CK_UTF8CHAR_PTR)"PKCS 11",NULL,&interface,0), CKR_OK, "C_GetInterface named");
funcs = interface->pFunctionList;
Expand Down Expand Up @@ -113,7 +113,7 @@ int main(void) {
get_versioned_functions(CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR);
test_lib_info(CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR);

get_named_functions("PKCS 11");
get_named_functions();
test_lib_info(CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR);

return EXIT_SUCCESS;
Expand Down
12 changes: 7 additions & 5 deletions ykcs11/ykcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ static const CK_FUNCTION_LIST function_list;
static const CK_FUNCTION_LIST_3_0 function_list_3;
static struct CK_INTERFACE active_interface;

static const CK_INTERFACE interfaces_list[] = {{(CK_CHAR_PTR) "PKCS 11",
(CK_VOID_PTR)&function_list_3, 0},
{(CK_CHAR_PTR) "PKCS 11",
(CK_VOID_PTR)&function_list, 0}};


static CK_SESSION_HANDLE get_session_handle(ykcs11_session_t *session) {
return (CK_SESSION_HANDLE)(session - sessions + 1);
}
Expand Down Expand Up @@ -302,6 +308,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetFunctionList)(
goto funclist_out;
}
*ppFunctionList = (CK_FUNCTION_LIST_PTR)&function_list;
active_interface = interfaces_list[1];
rv = CKR_OK;


Expand Down Expand Up @@ -3874,11 +3881,6 @@ CK_DEFINE_FUNCTION(CK_RV, C_CancelFunction)(
return CKR_FUNCTION_NOT_PARALLEL;
}

static const CK_INTERFACE interfaces_list[] = {{(CK_CHAR_PTR) "PKCS 11",
(CK_VOID_PTR)&function_list_3, 0},
{(CK_CHAR_PTR) "PKCS 11",
(CK_VOID_PTR)&function_list, 0}};

/* C_GetInterfaceList returns all the interfaces supported by the module*/
CK_DEFINE_FUNCTION(CK_RV, C_GetInterfaceList)
(CK_INTERFACE_PTR pInterfacesList, /* returned interfaces */
Expand Down

0 comments on commit 6e7cc82

Please sign in to comment.