Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "pkcs11: fixed slotIDs when a new slot list is requested"
This reverts commit 7fb72cc.
  • Loading branch information
frankmorgner committed Feb 19, 2020
1 parent cd5c91b commit 31d8c2d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
22 changes: 1 addition & 21 deletions src/pkcs11/pkcs11-global.c
Expand Up @@ -451,13 +451,8 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
pSlotList==NULL_PTR? "plug-n-play":"refresh");

/* Slot list can only change in v2.20 */
if (pSlotList == NULL_PTR) {
if (pSlotList == NULL_PTR)
sc_ctx_detect_readers(context);
for (i=0; i<list_size(&virtual_slots); i++) {
slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
slot->flags &= ~SC_PKCS11_SLOT_FLAG_SEEN;
}
}

card_detect_all();

Expand Down Expand Up @@ -488,21 +483,6 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
prev_reader = slot->reader;
}

/* Slot list can only change in v2.20 */
if (pSlotList == NULL_PTR) {
/* slot->id is derived from its location in the list virtual_slots.
* When the slot list changes, so does slot->id, so we reindex the
* slots here the same way it is done in `create_slot()`
*
* TODO use a persistent CK_SLOT_ID, e.g. by using something like
* `slot->id = sc_crc32(slot, sizeof *slot);` (this example, however,
* is currently not thread safe). */
for (i=0; i<list_size(&virtual_slots); i++) {
slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);
}
}

if (pSlotList == NULL_PTR) {
sc_log(context, "was only a size inquiry (%lu)\n", numMatches);
*pulCount = numMatches;
Expand Down
2 changes: 1 addition & 1 deletion src/pkcs11/slot.c
Expand Up @@ -115,6 +115,7 @@ CK_RV create_slot(sc_reader_t *reader)
}

slot->login_user = -1;
slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);
init_slot_info(&slot->slot_info, reader);
sc_log(context, "Initializing slot with id 0x%lx", slot->id);

Expand All @@ -125,7 +126,6 @@ CK_RV create_slot(sc_reader_t *reader)
slot->slot_info.hardwareVersion.major = reader->version_major;
slot->slot_info.hardwareVersion.minor = reader->version_minor;
}
slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);

return CKR_OK;
}
Expand Down

0 comments on commit 31d8c2d

Please sign in to comment.