Skip to content

Commit

Permalink
YKCS11: Fix returning active function list
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed Aug 20, 2024
1 parent 8e5f5b6 commit 354e267
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions ykcs11/ykcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ int verbose;

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},
Expand Down Expand Up @@ -262,10 +261,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Finalize)(
return rv;
}

CK_DEFINE_FUNCTION(CK_RV, C_GetInfo)(
CK_INFO_PTR pInfo
)
{
static CK_RV C_GetInfo_Ex(CK_INFO_PTR pInfo, CK_VERSION cryptokiVersion) {
CK_RV rv;
DIN;

Expand All @@ -281,7 +277,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetInfo)(
goto info_out;
}

pInfo->cryptokiVersion = ((CK_FUNCTION_LIST_3_0 *) active_interface.pFunctionList)->version;
pInfo->cryptokiVersion = cryptokiVersion;
pInfo->libraryVersion.major = YKCS11_VERSION_MAJOR;
pInfo->libraryVersion.minor = (YKCS11_VERSION_MINOR * 10) + YKCS11_VERSION_PATCH;
pInfo->flags = 0;
Expand All @@ -295,6 +291,26 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetInfo)(
return rv;
}

CK_DEFINE_FUNCTION(CK_RV, C_GetInfo)(CK_INFO_PTR pInfo) {

DIN;

CK_RV rv = C_GetInfo_Ex(pInfo, function_list.version);

DOUT;
return rv;
}

static CK_RV C_GetInfo_3_0(CK_INFO_PTR pInfo) {

DIN;

CK_RV rv = C_GetInfo_Ex(pInfo, function_list_3.version);

DOUT;
return rv;
}

CK_DEFINE_FUNCTION(CK_RV, C_GetFunctionList)(
CK_FUNCTION_LIST_PTR_PTR ppFunctionList
)
Expand All @@ -308,7 +324,6 @@ 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 @@ -3961,7 +3976,6 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetInterface)
interfaces_list[i].pInterfaceName, func_list->version.major,
func_list->version.minor);
*ppInterface = (CK_INTERFACE_PTR) &interfaces_list[i];
active_interface = interfaces_list[i];
rv = CKR_OK;
break;
}
Expand Down Expand Up @@ -4302,7 +4316,7 @@ static const CK_FUNCTION_LIST_3_0 function_list_3 = {
{CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR},
C_Initialize,
C_Finalize,
C_GetInfo,
C_GetInfo_3_0,
C_GetFunctionList,
C_GetSlotList,
C_GetSlotInfo,
Expand Down

0 comments on commit 354e267

Please sign in to comment.