|
|
|
@ -586,6 +586,9 @@ namespace cryptoki { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct TokenInfo; // forward declaration
|
|
|
|
|
std::ostream& operator<<(std::ostream& out, const TokenInfo& ti); |
|
|
|
|
|
|
|
|
|
struct TokenInfo { |
|
|
|
|
FixString<32> label; |
|
|
|
|
FixString<32> manufacturerID; |
|
|
|
@ -607,6 +610,7 @@ namespace cryptoki { |
|
|
|
|
FixString<16> utcTime; |
|
|
|
|
|
|
|
|
|
TokenInfo() { |
|
|
|
|
CRYPTOLOG("log"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//! Convert C-Structure of Token Information Into C++
|
|
|
|
@ -629,9 +633,35 @@ namespace cryptoki { |
|
|
|
|
hardwareVersion(cInfo.hardwareVersion), |
|
|
|
|
firmwareVersion(cInfo.firmwareVersion), |
|
|
|
|
utcTime(cInfo.utcTime) { |
|
|
|
|
CRYPTOLOG("log *this={"<<std::endl<<*this);//<<std::endl<<'}');
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& out, const TokenInfo& ti) { |
|
|
|
|
return out |
|
|
|
|
<<"label="<<ti.label<<std::endl |
|
|
|
|
<<"manufacturerID="<<ti.manufacturerID<<std::endl |
|
|
|
|
<<"model="<<ti.model<<std::endl |
|
|
|
|
<<"serialNumber="<<ti.serialNumber<<std::endl |
|
|
|
|
<<"flags="<<ti.flags<<std::endl |
|
|
|
|
<<"maxSessionCount="<<ti.maxSessionCount<<std::endl |
|
|
|
|
<<"sessionCount="<<ti.sessionCount<<std::endl |
|
|
|
|
<<"maxRwSessionCount="<<ti.maxRwSessionCount<<std::endl |
|
|
|
|
<<"rwSessionCount="<<ti.rwSessionCount<<std::endl |
|
|
|
|
<<"maxPinLen="<<ti.maxPinLen<<std::endl |
|
|
|
|
<<"minPinLen="<<ti.minPinLen<<std::endl |
|
|
|
|
<<"totalPublicMemory="<<ti.totalPublicMemory<<std::endl |
|
|
|
|
<<"freePublicMemory="<<ti.freePublicMemory<<std::endl |
|
|
|
|
<<"totalPrivateMemory="<<ti.totalPrivateMemory<<std::endl |
|
|
|
|
<<"freePrivateMemory="<<ti.freePrivateMemory<<std::endl |
|
|
|
|
<<"hardwareVersion="<<ti.hardwareVersion.major<<'.' |
|
|
|
|
<<ti.hardwareVersion.minor<<std::endl |
|
|
|
|
<<"firmwareVersion="<<ti.firmwareVersion.major<<'.' |
|
|
|
|
<<ti.firmwareVersion.minor<<std::endl |
|
|
|
|
<<"utcTime="<<ti.utcTime; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct Info { |
|
|
|
|
CK_VERSION cryptokiVersion; |
|
|
|
|
FixString<32> manufacturerID; |
|
|
|
@ -916,6 +946,7 @@ namespace cryptoki { |
|
|
|
|
//! calls @c C_GetSlotInfo
|
|
|
|
|
if (!check(_library->C_GetSlotInfo(_slot, &cInfo), |
|
|
|
|
CRYPTOKI_FN_LOG("C_GetSlotInfo"))) |
|
|
|
|
return SlotInfo(); |
|
|
|
|
return SlotInfo(cInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -926,6 +957,7 @@ namespace cryptoki { |
|
|
|
|
CK_TOKEN_INFO cInfo; |
|
|
|
|
if (!check(_library->C_GetTokenInfo(_slot, &cInfo), |
|
|
|
|
CRYPTOKI_FN_LOG("C_GetTokenInfo"))) |
|
|
|
|
return TokenInfo(); |
|
|
|
|
return TokenInfo(cInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1266,7 +1298,27 @@ namespace cryptoki { |
|
|
|
|
- @c ulDeviceError An error code defined by the |
|
|
|
|
cryptographic device. Used for errors not covered by |
|
|
|
|
Cryptoki. */ |
|
|
|
|
typedef CK_SESSION_INFO Info; |
|
|
|
|
struct Info: public CK_SESSION_INFO { |
|
|
|
|
Info(const CK_SESSION_INFO& si): CK_SESSION_INFO(si) { |
|
|
|
|
} |
|
|
|
|
bool readonly() { |
|
|
|
|
return !readwrite(); |
|
|
|
|
} |
|
|
|
|
bool readwrite() { |
|
|
|
|
return flags|CKF_RW_SESSION; |
|
|
|
|
} |
|
|
|
|
std::string stateString() { |
|
|
|
|
switch (state) { |
|
|
|
|
case 0: return "CKS_RO_PUBLIC_SESSION"; |
|
|
|
|
case 1: return "CKS_RO_USER_FUNCTIONS"; |
|
|
|
|
case 2: return "CKS_RW_PUBLIC_SESSION "; |
|
|
|
|
case 3: return "CKS_RW_USER_FUNCTIONS"; |
|
|
|
|
case 4: return "CKS_RW_SO_FUNCTIONS"; |
|
|
|
|
default: return "<UNKNOWN>"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @return session information */ |
|
|
|
|
Info getsessioninfo() { |
|
|
|
@ -1278,17 +1330,6 @@ namespace cryptoki { |
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string state(const Info& info) { |
|
|
|
|
switch (info.state) { |
|
|
|
|
case 0: return "CKS_RO_PUBLIC_SESSION"; |
|
|
|
|
case 1: return "CKS_RO_USER_FUNCTIONS"; |
|
|
|
|
case 2: return "CKS_RW_PUBLIC_SESSION "; |
|
|
|
|
case 3: return "CKS_RW_USER_FUNCTIONS"; |
|
|
|
|
case 4: return "CKS_RW_SO_FUNCTIONS"; |
|
|
|
|
default: return "<UNKNOWN>"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool initpin() { |
|
|
|
|