|
|
|
@ -203,22 +203,16 @@ namespace cryptoki { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|
SlotList res; |
|
|
|
|
CK_ULONG count(0); |
|
|
|
|
std::cout<<"CALL: C_GetSlotList"<<std::endl; |
|
|
|
|
//! calls @c C_GetSlotList
|
|
|
|
|
check(_fn->C_GetSlotList(tokenPresent?TRUE:FALSE, 0, &count), |
|
|
|
|
CRYPTOKI_FN_LOG("C_GetSlotList")); |
|
|
|
|
std::cout<<"C_GetSlotList returns "<<count<<" slots"<<std::endl; |
|
|
|
|
if (!count || !*this) return res; |
|
|
|
|
CK_SLOT_ID* slots = 0; |
|
|
|
|
try { |
|
|
|
|
do { |
|
|
|
|
delete[] slots; |
|
|
|
|
slots = new CK_SLOT_ID[count]; |
|
|
|
|
std::cout<<"CALL: C_GetSlotList to get IDs"<<std::endl; |
|
|
|
|
_res = _fn->C_GetSlotList(tokenPresent?TRUE:FALSE, slots, &count); |
|
|
|
|
std::cout<<"C_GetSlotList returns "<<count<<" slots"<<std::endl; |
|
|
|
|
if (_res==CKR_BUFFER_TOO_SMALL) |
|
|
|
|
std::cout<<"Buffer too small - repeat"<<std::endl; |
|
|
|
|
} while (_res==CKR_BUFFER_TOO_SMALL); |
|
|
|
|
check(_res, CRYPTOKI_FN_LOG("C_GetSlotList")); |
|
|
|
|
if (!*this) return res; |
|
|
|
@ -300,6 +294,7 @@ namespace cryptoki { |
|
|
|
|
attrs.push_back(Attribute(CKA_ISSUER, cert.issuerDER())); |
|
|
|
|
attrs.push_back(Attribute(CKA_SERIAL_NUMBER, cert.serial())); |
|
|
|
|
attrs.push_back(Attribute(CKA_VALUE, cert.valueDER())); |
|
|
|
|
CRYPTOKI_LOG("create: serial = "<<crypto::hex(cert.serial())); |
|
|
|
|
return create(attrs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -345,19 +340,6 @@ namespace cryptoki { |
|
|
|
|
return create(attrs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
Object Session::create(const std::string& application, |
|
|
|
|
const std::string& label, |
|
|
|
|
const std::string& data) { |
|
|
|
|
AttributeList attrs; |
|
|
|
|
attrs.push_back(Attribute(CKA_CLASS).from<CK_OBJECT_CLASS>(CKO_DATA)); |
|
|
|
|
attrs.push_back(Attribute(CKA_TOKEN).from<CK_BBOOL>(TRUE)); |
|
|
|
|
attrs.push_back(Attribute(CKA_APPLICATION, application)); |
|
|
|
|
attrs.push_back(Attribute(CKA_LABEL, label)); |
|
|
|
|
attrs.push_back(Attribute(CKA_VALUE, data)); |
|
|
|
|
return create(attrs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
Object Session::create(const AttributeList& attrs) { |
|
|
|
|
CRYPTOKI_LOG("log"); |
|
|
|
|