More refactoring.
This commit is contained in:
+21
-8
@@ -30,7 +30,7 @@ CK_BBOOL parse_readers(const CK_BYTE_PTR readers, const CK_ULONG len,
|
||||
if (readers[i] == '\0' && i != len - 1) {
|
||||
slots[*n_slots].vid = get_vendor_id(p);
|
||||
|
||||
if (slots[*n_slots].vid == UNKNOWN) {
|
||||
if (slots[*n_slots].vid == UNKNOWN) { // TODO: distinguish between tokenless and unsupported?
|
||||
// Unknown slot, just save what info we have
|
||||
memset(&slots[*n_slots].info, 0, sizeof(CK_SLOT_INFO));
|
||||
memset(slots[*n_slots].info.slotDescription, ' ', sizeof(slots[*n_slots].info.slotDescription));
|
||||
@@ -42,16 +42,26 @@ CK_BBOOL parse_readers(const CK_BYTE_PTR readers, const CK_ULONG len,
|
||||
// Values must NOT be null terminated and ' ' padded
|
||||
|
||||
memset(slots[*n_slots].info.slotDescription, ' ', sizeof(slots[*n_slots].info.slotDescription));
|
||||
s = vendor.get_slot_description();
|
||||
l = strlen(s);
|
||||
strncpy(slots[*n_slots].info.slotDescription, s, l);
|
||||
s = slots[*n_slots].info.slotDescription;
|
||||
l = sizeof(slots[*n_slots].info.slotDescription);
|
||||
if (vendor.get_slot_description(s, l) != CKR_OK)
|
||||
return CK_FALSE;
|
||||
|
||||
memset(slots[*n_slots].info.manufacturerID, ' ', sizeof(slots[*n_slots].info.manufacturerID));
|
||||
s = vendor.get_slot_manufacturer();
|
||||
l = strlen(s);
|
||||
strncpy(slots[*n_slots].info.manufacturerID, s, l);
|
||||
s = slots[*n_slots].info.manufacturerID;
|
||||
l = sizeof(slots[*n_slots].info.manufacturerID);
|
||||
if(vendor.get_slot_manufacturer(s, l) != CKR_OK)
|
||||
return CK_FALSE;
|
||||
|
||||
slots[*n_slots].info.flags = vendor.get_slot_flags();
|
||||
if (vendor.get_slot_flags(&slots[*n_slots].info.flags) != CKR_OK)
|
||||
return CK_FALSE;
|
||||
|
||||
// Treating hw and fw version the same
|
||||
if (vendor.get_slot_version(&slots[*n_slots].info.hardwareVersion) != CKR_OK)
|
||||
return CK_FALSE;
|
||||
|
||||
if (vendor.get_slot_version(&slots[*n_slots].info.firmwareVersion) != CKR_OK)
|
||||
return CK_FALSE;
|
||||
|
||||
if (has_token(slots + *n_slots))
|
||||
(*n_with_token)++;
|
||||
@@ -59,4 +69,7 @@ CK_BBOOL parse_readers(const CK_BYTE_PTR readers, const CK_ULONG len,
|
||||
(*n_slots)++;
|
||||
p += i + 1;
|
||||
}
|
||||
|
||||
return CK_TRUE;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user