|
|
|
|
@@ -171,11 +171,16 @@ PK11_FreeSlotList(PK11SlotList *list)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* add a slot to a list
|
|
|
|
|
* "slot" is the slot to be added. Ownership is not transferred.
|
|
|
|
|
* "sorted" indicates whether or not the slot should be inserted according to
|
|
|
|
|
* cipherOrder of the associated module. PR_FALSE indicates that the slot
|
|
|
|
|
* should be inserted to the head of the list.
|
|
|
|
|
*/
|
|
|
|
|
SECStatus
|
|
|
|
|
PK11_AddSlotToList(PK11SlotList *list,PK11SlotInfo *slot)
|
|
|
|
|
PK11_AddSlotToList(PK11SlotList *list,PK11SlotInfo *slot, PRBool sorted)
|
|
|
|
|
{
|
|
|
|
|
PK11SlotListElement *le;
|
|
|
|
|
PK11SlotListElement *element;
|
|
|
|
|
|
|
|
|
|
le = (PK11SlotListElement *) PORT_Alloc(sizeof(PK11SlotListElement));
|
|
|
|
|
if (le == NULL) return SECFailure;
|
|
|
|
|
@@ -184,9 +189,23 @@ PK11_AddSlotToList(PK11SlotList *list,PK11SlotInfo *slot)
|
|
|
|
|
le->prev = NULL;
|
|
|
|
|
le->refCount = 1;
|
|
|
|
|
PZ_Lock(list->lock);
|
|
|
|
|
if (list->head) list->head->prev = le; else list->tail = le;
|
|
|
|
|
le->next = list->head;
|
|
|
|
|
list->head = le;
|
|
|
|
|
element = list->head;
|
|
|
|
|
/* Insertion sort, with higher cipherOrders are sorted first in the list */
|
|
|
|
|
while (element && sorted && (element->slot->module->cipherOrder >
|
|
|
|
|
le->slot->module->cipherOrder)) {
|
|
|
|
|
element = element->next;
|
|
|
|
|
}
|
|
|
|
|
if (element) {
|
|
|
|
|
le->prev = element->prev;
|
|
|
|
|
element->prev = le;
|
|
|
|
|
le->next = element;
|
|
|
|
|
} else {
|
|
|
|
|
le->prev = list->tail;
|
|
|
|
|
le->next = NULL;
|
|
|
|
|
list->tail = le;
|
|
|
|
|
}
|
|
|
|
|
if (le->prev) le->prev->next = le;
|
|
|
|
|
if (list->head == element) list->head = le;
|
|
|
|
|
PZ_Unlock(list->lock);
|
|
|
|
|
|
|
|
|
|
return SECSuccess;
|
|
|
|
|
@@ -208,11 +227,12 @@ PK11_DeleteSlotFromList(PK11SlotList *list,PK11SlotListElement *le)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Move a list to the end of the target list. NOTE: There is no locking
|
|
|
|
|
* here... This assumes BOTH lists are private copy lists.
|
|
|
|
|
* Move a list to the end of the target list.
|
|
|
|
|
* NOTE: There is no locking here... This assumes BOTH lists are private copy
|
|
|
|
|
* lists. It also does not re-sort the target list.
|
|
|
|
|
*/
|
|
|
|
|
SECStatus
|
|
|
|
|
PK11_MoveListToList(PK11SlotList *target,PK11SlotList *src)
|
|
|
|
|
pk11_MoveListToList(PK11SlotList *target,PK11SlotList *src)
|
|
|
|
|
{
|
|
|
|
|
if (src->head == NULL) return SECSuccess;
|
|
|
|
|
|
|
|
|
|
@@ -511,7 +531,7 @@ PK11_FindSlotsByNames(const char *dllName, const char* slotName,
|
|
|
|
|
((NULL == slotName) || (0 == *slotName)) &&
|
|
|
|
|
((NULL == tokenName) || (0 == *tokenName)) ) {
|
|
|
|
|
/* default to softoken */
|
|
|
|
|
PK11_AddSlotToList(slotList, PK11_GetInternalKeySlot());
|
|
|
|
|
PK11_AddSlotToList(slotList, PK11_GetInternalKeySlot(), PR_TRUE);
|
|
|
|
|
return slotList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -539,7 +559,7 @@ PK11_FindSlotsByNames(const char *dllName, const char* slotName,
|
|
|
|
|
( (!slotName) || (tmpSlot->slot_name &&
|
|
|
|
|
(0==PORT_Strcmp(tmpSlot->slot_name, slotName)))) ) {
|
|
|
|
|
if (tmpSlot) {
|
|
|
|
|
PK11_AddSlotToList(slotList, tmpSlot);
|
|
|
|
|
PK11_AddSlotToList(slotList, tmpSlot, PR_TRUE);
|
|
|
|
|
slotcount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -910,7 +930,7 @@ PK11_LoadSlotList(PK11SlotInfo *slot, PK11PreSlotInfo *psi, int count)
|
|
|
|
|
CK_MECHANISM_TYPE mechanism = PK11_DefaultArray[i].mechanism;
|
|
|
|
|
PK11SlotList *slotList = PK11_GetSlotList(mechanism);
|
|
|
|
|
|
|
|
|
|
if (slotList) PK11_AddSlotToList(slotList,slot);
|
|
|
|
|
if (slotList) PK11_AddSlotToList(slotList,slot,PR_FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -937,7 +957,7 @@ PK11_UpdateSlotAttribute(PK11SlotInfo *slot, PK11DefaultArrayEntry *entry,
|
|
|
|
|
|
|
|
|
|
/* add this slot to the list */
|
|
|
|
|
if (slotList!=NULL)
|
|
|
|
|
result = PK11_AddSlotToList(slotList, slot);
|
|
|
|
|
result = PK11_AddSlotToList(slotList, slot, PR_FALSE);
|
|
|
|
|
|
|
|
|
|
} else { /* trying to turn off */
|
|
|
|
|
|
|
|
|
|
@@ -1910,12 +1930,12 @@ PK11_GetAllTokens(CK_MECHANISM_TYPE type, PRBool needRW, PRBool loadCerts,
|
|
|
|
|
|| PK11_DoesMechanism(slot, type)) {
|
|
|
|
|
if (pk11_LoginStillRequired(slot,wincx)) {
|
|
|
|
|
if (PK11_IsFriendly(slot)) {
|
|
|
|
|
PK11_AddSlotToList(friendlyList, slot);
|
|
|
|
|
PK11_AddSlotToList(friendlyList, slot, PR_TRUE);
|
|
|
|
|
} else {
|
|
|
|
|
PK11_AddSlotToList(loginList, slot);
|
|
|
|
|
PK11_AddSlotToList(loginList, slot, PR_TRUE);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
PK11_AddSlotToList(list, slot);
|
|
|
|
|
PK11_AddSlotToList(list, slot, PR_TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1923,9 +1943,9 @@ PK11_GetAllTokens(CK_MECHANISM_TYPE type, PRBool needRW, PRBool loadCerts,
|
|
|
|
|
}
|
|
|
|
|
SECMOD_ReleaseReadLock(moduleLock);
|
|
|
|
|
|
|
|
|
|
PK11_MoveListToList(list,friendlyList);
|
|
|
|
|
pk11_MoveListToList(list,friendlyList);
|
|
|
|
|
PK11_FreeSlotList(friendlyList);
|
|
|
|
|
PK11_MoveListToList(list,loginList);
|
|
|
|
|
pk11_MoveListToList(list,loginList);
|
|
|
|
|
PK11_FreeSlotList(loginList);
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|