add methods to convert slot and token info from C-structure; refs #28

master
Marc Wäckerlin 11 years ago
parent 41d8c55db6
commit a9b5d10870
  1. 21
      src/cryptoki.hxx

@ -872,13 +872,20 @@ namespace cryptoki {
return res; return res;
} }
//! Read Slot Information
SlotInfo slotinfo() { SlotInfo slotinfo() {
CRYPTOLOG("log"); CRYPTOLOG("log");
SlotInfo info;
CK_SLOT_INFO cInfo; CK_SLOT_INFO cInfo;
//! calls @c C_GetSlotInfo //! calls @c C_GetSlotInfo
if (!check(_library->C_GetSlotInfo(_slot, &cInfo), if (!check(_library->C_GetSlotInfo(_slot, &cInfo),
CRYPTOKI_FN_LOG("C_GetSlotInfo"))) return info; CRYPTOKI_FN_LOG("C_GetSlotInfo")))
return slotinfo(cInfo);
}
//! Convert C-Structure of Slot Information Into C++
SlotInfo slotinfo(const CK_SLOT_INFO& cInfo) {
CRYPTOLOG("log");
SlotInfo info;
info.slotDescription = cInfo.slotDescription; info.slotDescription = cInfo.slotDescription;
info.manufacturerID = cInfo.manufacturerID; info.manufacturerID = cInfo.manufacturerID;
info.flags = cInfo.flags; info.flags = cInfo.flags;
@ -887,13 +894,19 @@ namespace cryptoki {
return info; return info;
} }
//! Read Token Information
TokenInfo tokeninfo() { TokenInfo tokeninfo() {
CRYPTOLOG("log"); CRYPTOLOG("log");
TokenInfo info;
//! calls @c C_GetTokenInfo //! calls @c C_GetTokenInfo
CK_TOKEN_INFO cInfo; CK_TOKEN_INFO cInfo;
if (!check(_library->C_GetTokenInfo(_slot, &cInfo), if (!check(_library->C_GetTokenInfo(_slot, &cInfo),
CRYPTOKI_FN_LOG("C_GetTokenInfo"))) return info; CRYPTOKI_FN_LOG("C_GetTokenInfo")))
return tokeninfo(cInfo);
}
//! Convert C-Structure of Token Information Into C++
TokenInfo tokeninfo(const CK_TOKEN_INFO cInfo) {
TokenInfo info;
info.label = cInfo.label; info.label = cInfo.label;
info.manufacturerID = cInfo.manufacturerID; info.manufacturerID = cInfo.manufacturerID;
info.model = cInfo.model; info.model = cInfo.model;

Loading…
Cancel
Save