Skip to content

Commit

Permalink
Fallback if C_GetInterface returns 0x54
Browse files Browse the repository at this point in the history
Addresses #621

Signed-off-by: S-P Chan <[email protected]>
  • Loading branch information
space88man committed Feb 22, 2024
1 parent 7756404 commit 9b1cdf2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions p11-kit/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ dlopen_and_get_function_list (Module *mod,
dl_module_t dl;
char *error;
CK_RV rv;
int fallback = 0;

assert (mod != NULL);
assert (path != NULL);
Expand Down Expand Up @@ -392,15 +393,22 @@ dlopen_and_get_function_list (Module *mod,
if (gi) {
/* Get the default standard interface */
rv = gi ((unsigned char *)"PKCS 11", NULL, &interface, 0);
if (rv != CKR_OK) {
switch(rv) {
case CKR_FUNCTION_NOT_SUPPORTED:
fallback = 1;
break;
case CKR_OK:
/* TODO check the version and flag it somehere? */
*funcs = interface->pFunctionList;
break;
default:
p11_message (_("call to C_GetInterface failed in module: %s: %s"),
path, p11_kit_strerror (rv));
return rv;
}
}

/* TODO check the version and flag it somehere? */
*funcs = interface->pFunctionList;
} else {
if (!gi || fallback) {
p11_debug ("C_GetInterface not available. Falling back to C_GetFunctionList()");

gfl = p11_dl_symbol (dl, "C_GetFunctionList");
Expand Down

0 comments on commit 9b1cdf2

Please sign in to comment.