Imporve support for multiple readers/cards.
This commit is contained in:
+1
-2
@@ -49,8 +49,7 @@ CK_RV parse_readers(const CK_BYTE_PTR readers, const CK_ULONG len,
|
||||
memset(slots[*n_slots].info.slotDescription, ' ', sizeof(slots[*n_slots].info.slotDescription));
|
||||
s = slots[*n_slots].info.slotDescription;
|
||||
l = sizeof(slots[*n_slots].info.slotDescription);
|
||||
if (slot.get_slot_description(s, l) != CKR_OK)
|
||||
goto failure;
|
||||
strncpy((char *)s, (char *)p, l);
|
||||
|
||||
memset(slots[*n_slots].info.manufacturerID, ' ', sizeof(slots[*n_slots].info.manufacturerID));
|
||||
s = slots[*n_slots].info.manufacturerID;
|
||||
|
||||
+10
-7
@@ -47,7 +47,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
|
||||
)
|
||||
{
|
||||
DIN;
|
||||
char readers[2048];
|
||||
CK_BYTE readers[2048];
|
||||
CK_ULONG len = sizeof(readers);
|
||||
|
||||
// TODO: check for locks and mutexes
|
||||
@@ -60,16 +60,11 @@ CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
|
||||
return CKR_FUNCTION_FAILED; // TODO: better error?
|
||||
}
|
||||
|
||||
if (ykpiv_list_readers(piv_state, readers, &len) != YKPIV_OK) {
|
||||
if (ykpiv_list_readers(piv_state, (char*)readers, &len) != YKPIV_OK) {
|
||||
DBG(("Unable to list readers"));
|
||||
return CKR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
if(ykpiv_connect(piv_state, NULL) != YKPIV_OK) {
|
||||
DBG(("Unable to connect to reader"));
|
||||
return CKR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
if (parse_readers(readers, len, slots, &n_slots, &n_slots_with_token) != CK_TRUE)
|
||||
CKR_FUNCTION_FAILED;
|
||||
|
||||
@@ -480,6 +475,12 @@ CK_DEFINE_FUNCTION(CK_RV, C_OpenSession)(
|
||||
return CKR_SESSION_PARALLEL_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
// Connect to the slot
|
||||
if(ykpiv_connect(piv_state, (char *)slots[slotID].info.slotDescription) != YKPIV_OK) {
|
||||
DBG(("Unable to connect to reader"));
|
||||
return CKR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
token = get_token_vendor(slots[slotID].token->vid);
|
||||
|
||||
// Store the slot
|
||||
@@ -606,6 +607,8 @@ CK_DEFINE_FUNCTION(CK_RV, C_CloseSession)(
|
||||
memset(&session, 0, sizeof(ykcs11_session_t));
|
||||
session.handle = CK_INVALID_HANDLE;
|
||||
|
||||
ykpiv_disconnect(piv_state);
|
||||
|
||||
DOUT;
|
||||
return CKR_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user