moved copy-initialization to copy constructor; refs #28

master
Marc Wäckerlin 11 years ago
parent a9b5d10870
commit a6871ee20b
  1. 71
      src/cryptoki.hxx

@ -572,6 +572,15 @@ namespace cryptoki {
CK_FLAGS flags; CK_FLAGS flags;
CK_VERSION hardwareVersion; CK_VERSION hardwareVersion;
CK_VERSION firmwareVersion; CK_VERSION firmwareVersion;
//! Convert C-Structure of Slot Information Into C++
SlotInfo(const CK_SLOT_INFO& cInfo):
slotDescription(cInfo.slotDescription),
manufacturerID(cInfo.manufacturerID),
flags(cInfo.flags),
hardwareVersion(cInfo.hardwareVersion),
firmwareVersion(cInfo.firmwareVersion) {
}
}; };
struct TokenInfo { struct TokenInfo {
@ -593,6 +602,28 @@ namespace cryptoki {
CK_VERSION hardwareVersion; CK_VERSION hardwareVersion;
CK_VERSION firmwareVersion; CK_VERSION firmwareVersion;
FixString<16> utcTime; FixString<16> utcTime;
//! Convert C-Structure of Token Information Into C++
TokenInfo(const CK_TOKEN_INFO& cInfo):
label(cInfo.label),
manufacturerID(cInfo.manufacturerID),
model(cInfo.model),
serialNumber(cInfo.serialNumber),
flags(cInfo.flags),
maxSessionCount(cInfo.ulMaxSessionCount),
sessionCount(cInfo.ulSessionCount),
maxRwSessionCount(cInfo.ulMaxRwSessionCount),
rwSessionCount(cInfo.ulRwSessionCount),
maxPinLen(cInfo.ulMaxPinLen),
minPinLen(cInfo.ulMinPinLen),
totalPublicMemory(cInfo.ulTotalPublicMemory),
freePublicMemory(cInfo.ulFreePublicMemory),
totalPrivateMemory(cInfo.ulTotalPrivateMemory),
freePrivateMemory(cInfo.ulFreePrivateMemory),
hardwareVersion(cInfo.hardwareVersion),
firmwareVersion(cInfo.firmwareVersion),
utcTime(cInfo.utcTime) {
}
}; };
struct Info { struct Info {
@ -879,19 +910,7 @@ namespace cryptoki {
//! 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"))) CRYPTOKI_FN_LOG("C_GetSlotInfo")))
return slotinfo(cInfo); 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.manufacturerID = cInfo.manufacturerID;
info.flags = cInfo.flags;
info.hardwareVersion = cInfo.hardwareVersion;
info.firmwareVersion = cInfo.firmwareVersion;
return info;
} }
//! Read Token Information //! Read Token Information
@ -901,31 +920,7 @@ namespace cryptoki {
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"))) CRYPTOKI_FN_LOG("C_GetTokenInfo")))
return tokeninfo(cInfo); 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.manufacturerID = cInfo.manufacturerID;
info.model = cInfo.model;
info.serialNumber = cInfo.serialNumber;
info.flags = cInfo.flags;
info.maxSessionCount = cInfo.ulMaxSessionCount;
info.sessionCount = cInfo.ulSessionCount;
info.maxRwSessionCount = cInfo.ulMaxRwSessionCount;
info.rwSessionCount = cInfo.ulRwSessionCount;
info.maxPinLen = cInfo.ulMaxPinLen;
info.minPinLen = cInfo.ulMinPinLen;
info.totalPublicMemory = cInfo.ulTotalPublicMemory;
info.freePublicMemory = cInfo.ulFreePublicMemory;
info.totalPrivateMemory = cInfo.ulTotalPrivateMemory;
info.freePrivateMemory = cInfo.ulFreePrivateMemory;
info.hardwareVersion = cInfo.hardwareVersion;
info.firmwareVersion = cInfo.firmwareVersion;
info.utcTime = cInfo.utcTime;
return info;
} }
/*! @bug does not compile: /*! @bug does not compile:

Loading…
Cancel
Save