|
|
|
@ -228,11 +228,13 @@ namespace cryptoki { |
|
|
|
|
|
|
|
|
|
SlotList Library::slotList(bool tokenPresent, std::string name) { |
|
|
|
|
CRYPTOLOG("log"); |
|
|
|
|
CRYPTOLOG("looking for card name: ")<<name<<(tokenPresent?" with token":""); |
|
|
|
|
SlotList res; |
|
|
|
|
CK_ULONG count(0); |
|
|
|
|
//! calls @c C_GetSlotList
|
|
|
|
|
_init->check(_init->_fn->C_GetSlotList(tokenPresent?TRUE:FALSE, 0, &count), |
|
|
|
|
CRYPTOKI_FN_LOG("C_GetSlotList")); |
|
|
|
|
CRYPTOLOG("found ")<<count<<" readers, result: "<<(*this?"success":"error"); |
|
|
|
|
if (!count || !*this) return res; |
|
|
|
|
CK_SLOT_ID* slots = 0; |
|
|
|
|
try { |
|
|
|
@ -246,8 +248,11 @@ namespace cryptoki { |
|
|
|
|
if (!*this) return res; |
|
|
|
|
for (CK_ULONG i(0); i<count; ++i) { |
|
|
|
|
Slot s(*this, slots[i]); |
|
|
|
|
if (!name.size() || name==s.slotinfo().slotDescription) |
|
|
|
|
CRYPTOLOG("found slot ")<<s.slotinfo().slotDescription; |
|
|
|
|
if (!name.size() || name==s.slotinfo().slotDescription) { |
|
|
|
|
CRYPTOLOG("-> slot matches"); |
|
|
|
|
res.push_back(s); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (...) { |
|
|
|
|
delete[] slots; |
|
|
|
|