|
|
|
@ -7,11 +7,15 @@ |
|
|
|
|
// 1 2 3 4 5 6 7 8
|
|
|
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
|
|
|
|
|
|
|
|
// interface
|
|
|
|
|
#include <opencryptoki/apiclient.h> |
|
|
|
|
#include <string> |
|
|
|
|
#include <vector> |
|
|
|
|
#include <set> |
|
|
|
|
|
|
|
|
|
// for inline implementations only
|
|
|
|
|
#include <sstream> |
|
|
|
|
|
|
|
|
|
//! C++ Wrapper around Cryptoki API
|
|
|
|
|
namespace cryptoki { |
|
|
|
|
|
|
|
|
@ -57,204 +61,28 @@ namespace cryptoki { |
|
|
|
|
class Slot; |
|
|
|
|
typedef std::vector<Slot> SlotList; |
|
|
|
|
|
|
|
|
|
enum Mechanism { |
|
|
|
|
RSA_PKCS_KEY_PAIR_GEN = CKM_RSA_PKCS_KEY_PAIR_GEN, |
|
|
|
|
RSA_PKCS = CKM_RSA_PKCS, |
|
|
|
|
RSA_9796 = CKM_RSA_9796, |
|
|
|
|
RSA_X_509 = CKM_RSA_X_509, |
|
|
|
|
MD2_RSA_PKCS = CKM_MD2_RSA_PKCS, |
|
|
|
|
MD5_RSA_PKCS = CKM_MD5_RSA_PKCS, |
|
|
|
|
SHA1_RSA_PKCS = CKM_SHA1_RSA_PKCS, |
|
|
|
|
RIPEMD128_RSA_PKCS = CKM_RIPEMD128_RSA_PKCS, |
|
|
|
|
RIPEMD160_RSA_PKCS = CKM_RIPEMD160_RSA_PKCS, |
|
|
|
|
RSA_PKCS_OAEP = CKM_RSA_PKCS_OAEP, |
|
|
|
|
RSA_X9_31_KEY_PAIR_GEN = CKM_RSA_X9_31_KEY_PAIR_GEN, |
|
|
|
|
RSA_X9_31 = CKM_RSA_X9_31, |
|
|
|
|
SHA1_RSA_X9_31 = CKM_SHA1_RSA_X9_31, |
|
|
|
|
RSA_PKCS_PSS = CKM_RSA_PKCS_PSS, |
|
|
|
|
SHA1_RSA_PKCS_PSS = CKM_SHA1_RSA_PKCS_PSS, |
|
|
|
|
DSA_KEY_PAIR_GEN = CKM_DSA_KEY_PAIR_GEN, |
|
|
|
|
DSA = CKM_DSA, |
|
|
|
|
DSA_SHA1 = CKM_DSA_SHA1, |
|
|
|
|
DH_PKCS_KEY_PAIR_GEN = CKM_DH_PKCS_KEY_PAIR_GEN, |
|
|
|
|
DH_PKCS_DERIVE = CKM_DH_PKCS_DERIVE, |
|
|
|
|
X9_42_DH_KEY_PAIR_GEN = CKM_X9_42_DH_KEY_PAIR_GEN, |
|
|
|
|
X9_42_DH_DERIVE = CKM_X9_42_DH_DERIVE, |
|
|
|
|
X9_42_DH_HYBRID_DERIVE = CKM_X9_42_DH_HYBRID_DERIVE, |
|
|
|
|
X9_42_MQV_DERIVE = CKM_X9_42_MQV_DERIVE, |
|
|
|
|
SHA256_RSA_PKCS = CKM_SHA256_RSA_PKCS, |
|
|
|
|
RC2_KEY_GEN = CKM_RC2_KEY_GEN, |
|
|
|
|
RC2_ECB = CKM_RC2_ECB, |
|
|
|
|
RC2_CBC = CKM_RC2_CBC, |
|
|
|
|
RC2_MAC = CKM_RC2_MAC, |
|
|
|
|
RC2_MAC_GENERAL = CKM_RC2_MAC_GENERAL, |
|
|
|
|
RC2_CBC_PAD = CKM_RC2_CBC_PAD, |
|
|
|
|
RC4_KEY_GEN = CKM_RC4_KEY_GEN, |
|
|
|
|
RC4 = CKM_RC4, |
|
|
|
|
DES_KEY_GEN = CKM_DES_KEY_GEN, |
|
|
|
|
DES_ECB = CKM_DES_ECB, |
|
|
|
|
DES_CBC = CKM_DES_CBC, |
|
|
|
|
DES_MAC = CKM_DES_MAC, |
|
|
|
|
DES_MAC_GENERAL = CKM_DES_MAC_GENERAL, |
|
|
|
|
DES_CBC_PAD = CKM_DES_CBC_PAD, |
|
|
|
|
DES2_KEY_GEN = CKM_DES2_KEY_GEN, |
|
|
|
|
DES3_KEY_GEN = CKM_DES3_KEY_GEN, |
|
|
|
|
DES3_ECB = CKM_DES3_ECB, |
|
|
|
|
DES3_CBC = CKM_DES3_CBC, |
|
|
|
|
DES3_MAC = CKM_DES3_MAC, |
|
|
|
|
DES3_MAC_GENERAL = CKM_DES3_MAC_GENERAL, |
|
|
|
|
DES3_CBC_PAD = CKM_DES3_CBC_PAD, |
|
|
|
|
CDMF_KEY_GEN = CKM_CDMF_KEY_GEN, |
|
|
|
|
CDMF_ECB = CKM_CDMF_ECB, |
|
|
|
|
CDMF_CBC = CKM_CDMF_CBC, |
|
|
|
|
CDMF_MAC = CKM_CDMF_MAC, |
|
|
|
|
CDMF_MAC_GENERAL = CKM_CDMF_MAC_GENERAL, |
|
|
|
|
CDMF_CBC_PAD = CKM_CDMF_CBC_PAD, |
|
|
|
|
MD2 = CKM_MD2, |
|
|
|
|
MD2_HMAC = CKM_MD2_HMAC, |
|
|
|
|
MD2_HMAC_GENERAL = CKM_MD2_HMAC_GENERAL, |
|
|
|
|
MD5 = CKM_MD5, |
|
|
|
|
MD5_HMAC = CKM_MD5_HMAC, |
|
|
|
|
MD5_HMAC_GENERAL = CKM_MD5_HMAC_GENERAL, |
|
|
|
|
SHA_1 = CKM_SHA_1, |
|
|
|
|
SHA_1_HMAC = CKM_SHA_1_HMAC, |
|
|
|
|
SHA_1_HMAC_GENERAL = CKM_SHA_1_HMAC_GENERAL, |
|
|
|
|
RIPEMD128 = CKM_RIPEMD128, |
|
|
|
|
RIPEMD128_HMAC = CKM_RIPEMD128_HMAC, |
|
|
|
|
RIPEMD128_HMAC_GENERAL = CKM_RIPEMD128_HMAC_GENERAL, |
|
|
|
|
RIPEMD160 = CKM_RIPEMD160, |
|
|
|
|
RIPEMD160_HMAC = CKM_RIPEMD160_HMAC, |
|
|
|
|
RIPEMD160_HMAC_GENERAL = CKM_RIPEMD160_HMAC_GENERAL, |
|
|
|
|
SHA256 = CKM_SHA256, |
|
|
|
|
SHA256_HMAC = CKM_SHA256_HMAC, |
|
|
|
|
SHA256_HMAC_GENERAL = CKM_SHA256_HMAC_GENERAL, |
|
|
|
|
SHA384 = CKM_SHA384, |
|
|
|
|
SHA384_HMAC = CKM_SHA384_HMAC, |
|
|
|
|
SHA384_HMAC_GENERAL = CKM_SHA384_HMAC_GENERAL, |
|
|
|
|
SHA512 = CKM_SHA512, |
|
|
|
|
SHA512_HMAC = CKM_SHA512_HMAC, |
|
|
|
|
SHA512_HMAC_GENERAL = CKM_SHA512_HMAC_GENERAL, |
|
|
|
|
CAST_KEY_GEN = CKM_CAST_KEY_GEN, |
|
|
|
|
CAST_ECB = CKM_CAST_ECB, |
|
|
|
|
CAST_CBC = CKM_CAST_CBC, |
|
|
|
|
CAST_MAC = CKM_CAST_MAC, |
|
|
|
|
CAST_MAC_GENERAL = CKM_CAST_MAC_GENERAL, |
|
|
|
|
CAST_CBC_PAD = CKM_CAST_CBC_PAD, |
|
|
|
|
CAST3_KEY_GEN = CKM_CAST3_KEY_GEN, |
|
|
|
|
CAST3_ECB = CKM_CAST3_ECB, |
|
|
|
|
CAST3_CBC = CKM_CAST3_CBC, |
|
|
|
|
CAST3_MAC = CKM_CAST3_MAC, |
|
|
|
|
CAST3_MAC_GENERAL = CKM_CAST3_MAC_GENERAL, |
|
|
|
|
CAST3_CBC_PAD = CKM_CAST3_CBC_PAD, |
|
|
|
|
CAST5_KEY_GEN = CKM_CAST5_KEY_GEN, |
|
|
|
|
CAST128_KEY_GEN = CKM_CAST128_KEY_GEN, |
|
|
|
|
CAST5_ECB = CKM_CAST5_ECB, |
|
|
|
|
CAST128_ECB = CKM_CAST128_ECB, |
|
|
|
|
CAST5_CBC = CKM_CAST5_CBC, |
|
|
|
|
CAST128_CBC = CKM_CAST128_CBC, |
|
|
|
|
CAST5_MAC = CKM_CAST5_MAC, |
|
|
|
|
CAST128_MAC = CKM_CAST128_MAC, |
|
|
|
|
CAST5_MAC_GENERAL = CKM_CAST5_MAC_GENERAL, |
|
|
|
|
CAST128_MAC_GENERAL = CKM_CAST128_MAC_GENERAL, |
|
|
|
|
CAST5_CBC_PAD = CKM_CAST5_CBC_PAD, |
|
|
|
|
CAST128_CBC_PAD = CKM_CAST128_CBC_PAD, |
|
|
|
|
RC5_KEY_GEN = CKM_RC5_KEY_GEN, |
|
|
|
|
RC5_ECB = CKM_RC5_ECB, |
|
|
|
|
RC5_CBC = CKM_RC5_CBC, |
|
|
|
|
RC5_MAC = CKM_RC5_MAC, |
|
|
|
|
RC5_MAC_GENERAL = CKM_RC5_MAC_GENERAL, |
|
|
|
|
RC5_CBC_PAD = CKM_RC5_CBC_PAD, |
|
|
|
|
IDEA_KEY_GEN = CKM_IDEA_KEY_GEN, |
|
|
|
|
IDEA_ECB = CKM_IDEA_ECB, |
|
|
|
|
IDEA_CBC = CKM_IDEA_CBC, |
|
|
|
|
IDEA_MAC = CKM_IDEA_MAC, |
|
|
|
|
IDEA_MAC_GENERAL = CKM_IDEA_MAC_GENERAL, |
|
|
|
|
IDEA_CBC_PAD = CKM_IDEA_CBC_PAD, |
|
|
|
|
GENERIC_SECRET_KEY_GEN = CKM_GENERIC_SECRET_KEY_GEN, |
|
|
|
|
CONCATENATE_BASE_AND_KEY = CKM_CONCATENATE_BASE_AND_KEY, |
|
|
|
|
CONCATENATE_BASE_AND_DATA = CKM_CONCATENATE_BASE_AND_DATA, |
|
|
|
|
CONCATENATE_DATA_AND_BASE = CKM_CONCATENATE_DATA_AND_BASE, |
|
|
|
|
XOR_BASE_AND_DATA = CKM_XOR_BASE_AND_DATA, |
|
|
|
|
EXTRACT_KEY_FROM_KEY = CKM_EXTRACT_KEY_FROM_KEY, |
|
|
|
|
SSL3_PRE_MASTER_KEY_GEN = CKM_SSL3_PRE_MASTER_KEY_GEN, |
|
|
|
|
SSL3_MASTER_KEY_DERIVE = CKM_SSL3_MASTER_KEY_DERIVE, |
|
|
|
|
SSL3_KEY_AND_MAC_DERIVE = CKM_SSL3_KEY_AND_MAC_DERIVE, |
|
|
|
|
SSL3_MASTER_KEY_DERIVE_DH = CKM_SSL3_MASTER_KEY_DERIVE_DH, |
|
|
|
|
TLS_PRE_MASTER_KEY_GEN = CKM_TLS_PRE_MASTER_KEY_GEN, |
|
|
|
|
TLS_MASTER_KEY_DERIVE = CKM_TLS_MASTER_KEY_DERIVE, |
|
|
|
|
TLS_KEY_AND_MAC_DERIVE = CKM_TLS_KEY_AND_MAC_DERIVE, |
|
|
|
|
TLS_MASTER_KEY_DERIVE_DH = CKM_TLS_MASTER_KEY_DERIVE_DH, |
|
|
|
|
SSL3_MD5_MAC = CKM_SSL3_MD5_MAC, |
|
|
|
|
SSL3_SHA1_MAC = CKM_SSL3_SHA1_MAC, |
|
|
|
|
MD5_KEY_DERIVATION = CKM_MD5_KEY_DERIVATION, |
|
|
|
|
MD2_KEY_DERIVATION = CKM_MD2_KEY_DERIVATION, |
|
|
|
|
SHA1_KEY_DERIVATION = CKM_SHA1_KEY_DERIVATION, |
|
|
|
|
SHA256_KEY_DERIVATION = CKM_SHA256_KEY_DERIVATION, |
|
|
|
|
PBE_MD2_DES_CBC = CKM_PBE_MD2_DES_CBC, |
|
|
|
|
PBE_MD5_DES_CBC = CKM_PBE_MD5_DES_CBC, |
|
|
|
|
PBE_MD5_CAST_CBC = CKM_PBE_MD5_CAST_CBC, |
|
|
|
|
PBE_MD5_CAST3_CBC = CKM_PBE_MD5_CAST3_CBC, |
|
|
|
|
PBE_MD5_CAST5_CBC = CKM_PBE_MD5_CAST5_CBC, |
|
|
|
|
PBE_MD5_CAST128_CBC = CKM_PBE_MD5_CAST128_CBC, |
|
|
|
|
PBE_SHA1_CAST5_CBC = CKM_PBE_SHA1_CAST5_CBC, |
|
|
|
|
PBE_SHA1_CAST128_CBC = CKM_PBE_SHA1_CAST128_CBC, |
|
|
|
|
PBE_SHA1_RC4_128 = CKM_PBE_SHA1_RC4_128, |
|
|
|
|
PBE_SHA1_RC4_40 = CKM_PBE_SHA1_RC4_40, |
|
|
|
|
PBE_SHA1_DES3_EDE_CBC = CKM_PBE_SHA1_DES3_EDE_CBC, |
|
|
|
|
PBE_SHA1_DES2_EDE_CBC = CKM_PBE_SHA1_DES2_EDE_CBC, |
|
|
|
|
PBE_SHA1_RC2_128_CBC = CKM_PBE_SHA1_RC2_128_CBC, |
|
|
|
|
PBE_SHA1_RC2_40_CBC = CKM_PBE_SHA1_RC2_40_CBC, |
|
|
|
|
PKCS5_PBKD2 = CKM_PKCS5_PBKD2, |
|
|
|
|
PBA_SHA1_WITH_SHA1_HMAC = CKM_PBA_SHA1_WITH_SHA1_HMAC, |
|
|
|
|
KEY_WRAP_LYNKS = CKM_KEY_WRAP_LYNKS, |
|
|
|
|
KEY_WRAP_SET_OAEP = CKM_KEY_WRAP_SET_OAEP, |
|
|
|
|
SKIPJACK_KEY_GEN = CKM_SKIPJACK_KEY_GEN, |
|
|
|
|
SKIPJACK_ECB64 = CKM_SKIPJACK_ECB64, |
|
|
|
|
SKIPJACK_CBC64 = CKM_SKIPJACK_CBC64, |
|
|
|
|
SKIPJACK_OFB64 = CKM_SKIPJACK_OFB64, |
|
|
|
|
SKIPJACK_CFB64 = CKM_SKIPJACK_CFB64, |
|
|
|
|
SKIPJACK_CFB32 = CKM_SKIPJACK_CFB32, |
|
|
|
|
SKIPJACK_CFB16 = CKM_SKIPJACK_CFB16, |
|
|
|
|
SKIPJACK_CFB8 = CKM_SKIPJACK_CFB8, |
|
|
|
|
SKIPJACK_WRAP = CKM_SKIPJACK_WRAP, |
|
|
|
|
SKIPJACK_PRIVATE_WRAP = CKM_SKIPJACK_PRIVATE_WRAP, |
|
|
|
|
SKIPJACK_RELAYX = CKM_SKIPJACK_RELAYX, |
|
|
|
|
KEA_KEY_PAIR_GEN = CKM_KEA_KEY_PAIR_GEN, |
|
|
|
|
KEA_KEY_DERIVE = CKM_KEA_KEY_DERIVE, |
|
|
|
|
FORTEZZA_TIMESTAMP = CKM_FORTEZZA_TIMESTAMP, |
|
|
|
|
BATON_KEY_GEN = CKM_BATON_KEY_GEN, |
|
|
|
|
BATON_ECB128 = CKM_BATON_ECB128, |
|
|
|
|
BATON_ECB96 = CKM_BATON_ECB96, |
|
|
|
|
BATON_CBC128 = CKM_BATON_CBC128, |
|
|
|
|
BATON_COUNTER = CKM_BATON_COUNTER, |
|
|
|
|
BATON_SHUFFLE = CKM_BATON_SHUFFLE, |
|
|
|
|
BATON_WRAP = CKM_BATON_WRAP, |
|
|
|
|
ECDSA_KEY_PAIR_GEN = CKM_ECDSA_KEY_PAIR_GEN, |
|
|
|
|
EC_KEY_PAIR_GEN = CKM_EC_KEY_PAIR_GEN, |
|
|
|
|
ECDSA = CKM_ECDSA, |
|
|
|
|
ECDSA_SHA1 = CKM_ECDSA_SHA1, |
|
|
|
|
ECDH1_DERIVE = CKM_ECDH1_DERIVE, |
|
|
|
|
ECDH1_COFACTOR_DERIVE = CKM_ECDH1_COFACTOR_DERIVE, |
|
|
|
|
ECMQV_DERIVE = CKM_ECMQV_DERIVE, |
|
|
|
|
JUNIPER_KEY_GEN = CKM_JUNIPER_KEY_GEN, |
|
|
|
|
JUNIPER_ECB128 = CKM_JUNIPER_ECB128, |
|
|
|
|
JUNIPER_CBC128 = CKM_JUNIPER_CBC128, |
|
|
|
|
JUNIPER_COUNTER = CKM_JUNIPER_COUNTER, |
|
|
|
|
JUNIPER_SHUFFLE = CKM_JUNIPER_SHUFFLE, |
|
|
|
|
JUNIPER_WRAP = CKM_JUNIPER_WRAP, |
|
|
|
|
FASTHASH = CKM_FASTHASH, |
|
|
|
|
AES_KEY_GEN = CKM_AES_KEY_GEN, |
|
|
|
|
AES_ECB = CKM_AES_ECB, |
|
|
|
|
AES_CBC = CKM_AES_CBC, |
|
|
|
|
AES_MAC = CKM_AES_MAC, |
|
|
|
|
AES_MAC_GENERAL = CKM_AES_MAC_GENERAL, |
|
|
|
|
AES_CBC_PAD = CKM_AES_CBC_PAD, |
|
|
|
|
DSA_PARAMETER_GEN = CKM_DSA_PARAMETER_GEN, |
|
|
|
|
DH_PKCS_PARAMETER_GEN = CKM_DH_PKCS_PARAMETER_GEN, |
|
|
|
|
X9_42_DH_PARAMETER_GEN = CKM_X9_42_DH_PARAMETER_GEN, |
|
|
|
|
VENDOR_DEFINED = CKM_VENDOR_DEFINED |
|
|
|
|
typedef std::set<CK_MECHANISM_TYPE> MechanismList; |
|
|
|
|
|
|
|
|
|
//! Map Attribute Class to type
|
|
|
|
|
/*! @todo to be completed ... */ |
|
|
|
|
template<CK_ATTRIBUTE_TYPE Attribute> class AttributeType {}; |
|
|
|
|
template<> class AttributeType<CKA_CLASS> { |
|
|
|
|
public: typedef CK_OBJECT_CLASS Type; |
|
|
|
|
}; |
|
|
|
|
/*
|
|
|
|
|
template<> class AttributeType<> { |
|
|
|
|
public: typedef Type; |
|
|
|
|
}; |
|
|
|
|
template<> class AttributeType<> { |
|
|
|
|
public: typedef Type; |
|
|
|
|
}; |
|
|
|
|
template<> class AttributeType<> { |
|
|
|
|
public: typedef Type; |
|
|
|
|
}; |
|
|
|
|
typedef std::set<Mechanism> MechanismList; |
|
|
|
|
template<> class AttributeType<> { |
|
|
|
|
public: typedef Type; |
|
|
|
|
};*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<std::string::size_type SIZE> |
|
|
|
|
class FixString: public std::string { |
|
|
|
@ -286,6 +114,9 @@ namespace cryptoki { |
|
|
|
|
if (pos!=npos) resize(pos+1); else resize(0); |
|
|
|
|
return *this; |
|
|
|
|
} |
|
|
|
|
operator unsigned char*() { |
|
|
|
|
return (unsigned char*)begin().operator->(); |
|
|
|
|
} |
|
|
|
|
FixString fix() { |
|
|
|
|
FixString cpy(*this); |
|
|
|
|
cpy.resize(SIZE, ' '); |
|
|
|
@ -293,7 +124,225 @@ namespace cryptoki { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
typedef CK_MECHANISM_INFO MechanismInfo; |
|
|
|
|
struct MechanismInfo { |
|
|
|
|
CK_MECHANISM_TYPE id; |
|
|
|
|
std::string name; |
|
|
|
|
CK_ULONG minKeySize; |
|
|
|
|
CK_ULONG maxKeySize; |
|
|
|
|
CK_FLAGS flags; |
|
|
|
|
MechanismInfo(CK_MECHANISM_TYPE type): id(type) { |
|
|
|
|
switch (id) { |
|
|
|
|
case CKM_RSA_PKCS_KEY_PAIR_GEN: name="CKM_RSA_PKCS_KEY_PAIR_GEN"; break; |
|
|
|
|
case CKM_RSA_PKCS: name="CKM_RSA_PKCS"; break; |
|
|
|
|
case CKM_RSA_9796: name="CKM_RSA_9796"; break; |
|
|
|
|
case CKM_RSA_X_509: name="CKM_RSA_X_509"; break; |
|
|
|
|
case CKM_MD2_RSA_PKCS: name="CKM_MD2_RSA_PKCS"; break; |
|
|
|
|
case CKM_MD5_RSA_PKCS: name="CKM_MD5_RSA_PKCS"; break; |
|
|
|
|
case CKM_SHA1_RSA_PKCS: name="CKM_SHA1_RSA_PKCS"; break; |
|
|
|
|
case CKM_RIPEMD128_RSA_PKCS: name="CKM_RIPEMD128_RSA_PKCS"; break; |
|
|
|
|
case CKM_RIPEMD160_RSA_PKCS: name="CKM_RIPEMD160_RSA_PKCS"; break; |
|
|
|
|
case CKM_RSA_PKCS_OAEP: name="CKM_RSA_PKCS_OAEP"; break; |
|
|
|
|
case CKM_RSA_X9_31_KEY_PAIR_GEN: name="CKM_RSA_X9_31_KEY_PAIR_GEN"; break; |
|
|
|
|
case CKM_RSA_X9_31: name="CKM_RSA_X9_31"; break; |
|
|
|
|
case CKM_SHA1_RSA_X9_31: name="CKM_SHA1_RSA_X9_31"; break; |
|
|
|
|
case CKM_RSA_PKCS_PSS: name="CKM_RSA_PKCS_PSS"; break; |
|
|
|
|
case CKM_SHA1_RSA_PKCS_PSS: name="CKM_SHA1_RSA_PKCS_PSS"; break; |
|
|
|
|
case CKM_DSA_KEY_PAIR_GEN: name="CKM_DSA_KEY_PAIR_GEN"; break; |
|
|
|
|
case CKM_DSA: name="CKM_DSA"; break; |
|
|
|
|
case CKM_DSA_SHA1: name="CKM_DSA_SHA1"; break; |
|
|
|
|
case CKM_DH_PKCS_KEY_PAIR_GEN: name="CKM_DH_PKCS_KEY_PAIR_GEN"; break; |
|
|
|
|
case CKM_DH_PKCS_DERIVE: name="CKM_DH_PKCS_DERIVE"; break; |
|
|
|
|
case CKM_X9_42_DH_KEY_PAIR_GEN: name="CKM_X9_42_DH_KEY_PAIR_GEN"; break; |
|
|
|
|
case CKM_X9_42_DH_DERIVE: name="CKM_X9_42_DH_DERIVE"; break; |
|
|
|
|
case CKM_X9_42_DH_HYBRID_DERIVE: name="CKM_X9_42_DH_HYBRID_DERIVE"; break; |
|
|
|
|
case CKM_X9_42_MQV_DERIVE: name="CKM_X9_42_MQV_DERIVE"; break; |
|
|
|
|
case CKM_SHA256_RSA_PKCS: name="CKM_SHA256_RSA_PKCS"; break; |
|
|
|
|
case CKM_RC2_KEY_GEN: name="CKM_RC2_KEY_GEN"; break; |
|
|
|
|
case CKM_RC2_ECB: name="CKM_RC2_ECB"; break; |
|
|
|
|
case CKM_RC2_CBC: name="CKM_RC2_CBC"; break; |
|
|
|
|
case CKM_RC2_MAC: name="CKM_RC2_MAC"; break; |
|
|
|
|
case CKM_RC2_MAC_GENERAL: name="CKM_RC2_MAC_GENERAL"; break; |
|
|
|
|
case CKM_RC2_CBC_PAD: name="CKM_RC2_CBC_PAD"; break; |
|
|
|
|
case CKM_RC4_KEY_GEN: name="CKM_RC4_KEY_GEN"; break; |
|
|
|
|
case CKM_RC4: name="CKM_RC4"; break; |
|
|
|
|
case CKM_DES_KEY_GEN: name="CKM_DES_KEY_GEN"; break; |
|
|
|
|
case CKM_DES_ECB: name="CKM_DES_ECB"; break; |
|
|
|
|
case CKM_DES_CBC: name="CKM_DES_CBC"; break; |
|
|
|
|
case CKM_DES_MAC: name="CKM_DES_MAC"; break; |
|
|
|
|
case CKM_DES_MAC_GENERAL: name="CKM_DES_MAC_GENERAL"; break; |
|
|
|
|
case CKM_DES_CBC_PAD: name="CKM_DES_CBC_PAD"; break; |
|
|
|
|
case CKM_DES2_KEY_GEN: name="CKM_DES2_KEY_GEN"; break; |
|
|
|
|
case CKM_DES3_KEY_GEN: name="CKM_DES3_KEY_GEN"; break; |
|
|
|
|
case CKM_DES3_ECB: name="CKM_DES3_ECB"; break; |
|
|
|
|
case CKM_DES3_CBC: name="CKM_DES3_CBC"; break; |
|
|
|
|
case CKM_DES3_MAC: name="CKM_DES3_MAC"; break; |
|
|
|
|
case CKM_DES3_MAC_GENERAL: name="CKM_DES3_MAC_GENERAL"; break; |
|
|
|
|
case CKM_DES3_CBC_PAD: name="CKM_DES3_CBC_PAD"; break; |
|
|
|
|
case CKM_CDMF_KEY_GEN: name="CKM_CDMF_KEY_GEN"; break; |
|
|
|
|
case CKM_CDMF_ECB: name="CKM_CDMF_ECB"; break; |
|
|
|
|
case CKM_CDMF_CBC: name="CKM_CDMF_CBC"; break; |
|
|
|
|
case CKM_CDMF_MAC: name="CKM_CDMF_MAC"; break; |
|
|
|
|
case CKM_CDMF_MAC_GENERAL: name="CKM_CDMF_MAC_GENERAL"; break; |
|
|
|
|
case CKM_CDMF_CBC_PAD: name="CKM_CDMF_CBC_PAD"; break; |
|
|
|
|
case CKM_MD2: name="CKM_MD2"; break; |
|
|
|
|
case CKM_MD2_HMAC: name="CKM_MD2_HMAC"; break; |
|
|
|
|
case CKM_MD2_HMAC_GENERAL: name="CKM_MD2_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_MD5: name="CKM_MD5"; break; |
|
|
|
|
case CKM_MD5_HMAC: name="CKM_MD5_HMAC"; break; |
|
|
|
|
case CKM_MD5_HMAC_GENERAL: name="CKM_MD5_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_SHA_1: name="CKM_SHA_1"; break; |
|
|
|
|
case CKM_SHA_1_HMAC: name="CKM_SHA_1_HMAC"; break; |
|
|
|
|
case CKM_SHA_1_HMAC_GENERAL: name="CKM_SHA_1_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_RIPEMD128: name="CKM_RIPEMD128"; break; |
|
|
|
|
case CKM_RIPEMD128_HMAC: name="CKM_RIPEMD128_HMAC"; break; |
|
|
|
|
case CKM_RIPEMD128_HMAC_GENERAL: name="CKM_RIPEMD128_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_RIPEMD160: name="CKM_RIPEMD160"; break; |
|
|
|
|
case CKM_RIPEMD160_HMAC: name="CKM_RIPEMD160_HMAC"; break; |
|
|
|
|
case CKM_RIPEMD160_HMAC_GENERAL: name="CKM_RIPEMD160_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_SHA256: name="CKM_SHA256"; break; |
|
|
|
|
case CKM_SHA256_HMAC: name="CKM_SHA256_HMAC"; break; |
|
|
|
|
case CKM_SHA256_HMAC_GENERAL: name="CKM_SHA256_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_SHA384: name="CKM_SHA384"; break; |
|
|
|
|
case CKM_SHA384_HMAC: name="CKM_SHA384_HMAC"; break; |
|
|
|
|
case CKM_SHA384_HMAC_GENERAL: name="CKM_SHA384_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_SHA512: name="CKM_SHA512"; break; |
|
|
|
|
case CKM_SHA512_HMAC: name="CKM_SHA512_HMAC"; break; |
|
|
|
|
case CKM_SHA512_HMAC_GENERAL: name="CKM_SHA512_HMAC_GENERAL"; break; |
|
|
|
|
case CKM_CAST_KEY_GEN: name="CKM_CAST_KEY_GEN"; break; |
|
|
|
|
case CKM_CAST_ECB: name="CKM_CAST_ECB"; break; |
|
|
|
|
case CKM_CAST_CBC: name="CKM_CAST_CBC"; break; |
|
|
|
|
case CKM_CAST_MAC: name="CKM_CAST_MAC"; break; |
|
|
|
|
case CKM_CAST_MAC_GENERAL: name="CKM_CAST_MAC_GENERAL"; break; |
|
|
|
|
case CKM_CAST_CBC_PAD: name="CKM_CAST_CBC_PAD"; break; |
|
|
|
|
case CKM_CAST3_KEY_GEN: name="CKM_CAST3_KEY_GEN"; break; |
|
|
|
|
case CKM_CAST3_ECB: name="CKM_CAST3_ECB"; break; |
|
|
|
|
case CKM_CAST3_CBC: name="CKM_CAST3_CBC"; break; |
|
|
|
|
case CKM_CAST3_MAC: name="CKM_CAST3_MAC"; break; |
|
|
|
|
case CKM_CAST3_MAC_GENERAL: name="CKM_CAST3_MAC_GENERAL"; break; |
|
|
|
|
case CKM_CAST3_CBC_PAD: name="CKM_CAST3_CBC_PAD"; break; |
|
|
|
|
//case CKM_CAST5_KEY_GEN: name="CKM_CAST5_KEY_GEN"; break;
|
|
|
|
|
case CKM_CAST128_KEY_GEN: name="CKM_CAST5_KEY_GEN or CKM_CAST128_KEY_GEN"; break; |
|
|
|
|
//case CKM_CAST5_ECB: name="CKM_CAST5_ECB"; break;
|
|
|
|
|
case CKM_CAST128_ECB: name="CKM_CAST5_ECB or CKM_CAST128_ECB"; break; |
|
|
|
|
//case CKM_CAST5_CBC: name="CKM_CAST5_CBC"; break;
|
|
|
|
|
case CKM_CAST128_CBC: name="CKM_CAST5_CBC or CKM_CAST128_CBC"; break; |
|
|
|
|
//case CKM_CAST5_MAC: name="CKM_CAST5_MAC"; break;
|
|
|
|
|
case CKM_CAST128_MAC: name="CKM_CAST5_MAC or CKM_CAST128_MAC"; break; |
|
|
|
|
//case CKM_CAST5_MAC_GENERAL: name="CKM_CAST5_MAC_GENERAL"; break;
|
|
|
|
|
case CKM_CAST128_MAC_GENERAL: |
|
|
|
|
name="CKM_CAST5_MAC_GENERAL or CKM_CAST128_MAC_GENERAL"; break; |
|
|
|
|
//case CKM_CAST5_CBC_PAD: name="CKM_CAST5_CBC_PAD"; break;
|
|
|
|
|
case CKM_CAST128_CBC_PAD: name="CKM_CAST5_CBC_PAD or CKM_CAST128_CBC_PAD"; break; |
|
|
|
|
case CKM_RC5_KEY_GEN: name="CKM_RC5_KEY_GEN"; break; |
|
|
|
|
case CKM_RC5_ECB: name="CKM_RC5_ECB"; break; |
|
|
|
|
case CKM_RC5_CBC: name="CKM_RC5_CBC"; break; |
|
|
|
|
case CKM_RC5_MAC: name="CKM_RC5_MAC"; break; |
|
|
|
|
case CKM_RC5_MAC_GENERAL: name="CKM_RC5_MAC_GENERAL"; break; |
|
|
|
|
case CKM_RC5_CBC_PAD: name="CKM_RC5_CBC_PAD"; break; |
|
|
|
|
case CKM_IDEA_KEY_GEN: name="CKM_IDEA_KEY_GEN"; break; |
|
|
|
|
case CKM_IDEA_ECB: name="CKM_IDEA_ECB"; break; |
|
|
|
|
case CKM_IDEA_CBC: name="CKM_IDEA_CBC"; break; |
|
|
|
|
case CKM_IDEA_MAC: name="CKM_IDEA_MAC"; break; |
|
|
|
|
case CKM_IDEA_MAC_GENERAL: name="CKM_IDEA_MAC_GENERAL"; break; |
|
|
|
|
case CKM_IDEA_CBC_PAD: name="CKM_IDEA_CBC_PAD"; break; |
|
|
|
|
case CKM_GENERIC_SECRET_KEY_GEN: name="CKM_GENERIC_SECRET_KEY_GEN"; break; |
|
|
|
|
case CKM_CONCATENATE_BASE_AND_KEY: |
|
|
|
|
name="CKM_CONCATENATE_BASE_AND_KEY"; break; |
|
|
|
|
case CKM_CONCATENATE_BASE_AND_DATA: |
|
|
|
|
name="CKM_CONCATENATE_BASE_AND_DATA"; break; |
|
|
|
|
case CKM_CONCATENATE_DATA_AND_BASE: |
|
|
|
|
name="CKM_CONCATENATE_DATA_AND_BASE"; break; |
|
|
|
|
case CKM_XOR_BASE_AND_DATA: name="CKM_XOR_BASE_AND_DATA"; break; |
|
|
|
|
case CKM_EXTRACT_KEY_FROM_KEY: name="CKM_EXTRACT_KEY_FROM_KEY"; break; |
|
|
|
|
case CKM_SSL3_PRE_MASTER_KEY_GEN: name="CKM_SSL3_PRE_MASTER_KEY_GEN"; break; |
|
|
|
|
case CKM_SSL3_MASTER_KEY_DERIVE: name="CKM_SSL3_MASTER_KEY_DERIVE"; break; |
|
|
|
|
case CKM_SSL3_KEY_AND_MAC_DERIVE: name="CKM_SSL3_KEY_AND_MAC_DERIVE"; break; |
|
|
|
|
case CKM_SSL3_MASTER_KEY_DERIVE_DH: |
|
|
|
|
name="CKM_SSL3_MASTER_KEY_DERIVE_DH"; break; |
|
|
|
|
case CKM_TLS_PRE_MASTER_KEY_GEN: name="CKM_TLS_PRE_MASTER_KEY_GEN"; break; |
|
|
|
|
case CKM_TLS_MASTER_KEY_DERIVE: name="CKM_TLS_MASTER_KEY_DERIVE"; break; |
|
|
|
|
case CKM_TLS_KEY_AND_MAC_DERIVE: name="CKM_TLS_KEY_AND_MAC_DERIVE"; break; |
|
|
|
|
case CKM_TLS_MASTER_KEY_DERIVE_DH: name="CKM_TLS_MASTER_KEY_DERIVE_DH"; break; |
|
|
|
|
case CKM_SSL3_MD5_MAC: name="CKM_SSL3_MD5_MAC"; break; |
|
|
|
|
case CKM_SSL3_SHA1_MAC: name="CKM_SSL3_SHA1_MAC"; break; |
|
|
|
|
case CKM_MD5_KEY_DERIVATION: name="CKM_MD5_KEY_DERIVATION"; break; |
|
|
|
|
case CKM_MD2_KEY_DERIVATION: name="CKM_MD2_KEY_DERIVATION"; break; |
|
|
|
|
case CKM_SHA1_KEY_DERIVATION: name="CKM_SHA1_KEY_DERIVATION"; break; |
|
|
|
|
case CKM_SHA256_KEY_DERIVATION: name="CKM_SHA256_KEY_DERIVATION"; break; |
|
|
|
|
case CKM_PBE_MD2_DES_CBC: name="CKM_PBE_MD2_DES_CBC"; break; |
|
|
|
|
case CKM_PBE_MD5_DES_CBC: name="CKM_PBE_MD5_DES_CBC"; break; |
|
|
|
|
case CKM_PBE_MD5_CAST_CBC: name="CKM_PBE_MD5_CAST_CBC"; break; |
|
|
|
|
case CKM_PBE_MD5_CAST3_CBC: name="CKM_PBE_MD5_CAST3_CBC"; break; |
|
|
|
|
//case CKM_PBE_MD5_CAST5_CBC: name="CKM_PBE_MD5_CAST5_CBC"; break;
|
|
|
|
|
case CKM_PBE_MD5_CAST128_CBC: |
|
|
|
|
name="CKM_PBE_MD5_CAST5_CBC or CKM_PBE_MD5_CAST128_CBC"; break; |
|
|
|
|
//case CKM_PBE_SHA1_CAST5_CBC: name="CKM_PBE_SHA1_CAST5_CBC"; break;
|
|
|
|
|
case CKM_PBE_SHA1_CAST128_CBC: |
|
|
|
|
name="CKM_PBE_SHA1_CAST5_CBC or CKM_PBE_SHA1_CAST128_CBC"; break; |
|
|
|
|
case CKM_PBE_SHA1_RC4_128: name="CKM_PBE_SHA1_RC4_128"; break; |
|
|
|
|
case CKM_PBE_SHA1_RC4_40: name="CKM_PBE_SHA1_RC4_40"; break; |
|
|
|
|
case CKM_PBE_SHA1_DES3_EDE_CBC: name="CKM_PBE_SHA1_DES3_EDE_CBC"; break; |
|
|
|
|
case CKM_PBE_SHA1_DES2_EDE_CBC: name="CKM_PBE_SHA1_DES2_EDE_CBC"; break; |
|
|
|
|
case CKM_PBE_SHA1_RC2_128_CBC: name="CKM_PBE_SHA1_RC2_128_CBC"; break; |
|
|
|
|
case CKM_PBE_SHA1_RC2_40_CBC: name="CKM_PBE_SHA1_RC2_40_CBC"; break; |
|
|
|
|
case CKM_PKCS5_PBKD2: name="CKM_PKCS5_PBKD2"; break; |
|
|
|
|
case CKM_PBA_SHA1_WITH_SHA1_HMAC: name="CKM_PBA_SHA1_WITH_SHA1_HMAC"; break; |
|
|
|
|
case CKM_KEY_WRAP_LYNKS: name="CKM_KEY_WRAP_LYNKS"; break; |
|
|
|
|
case CKM_KEY_WRAP_SET_OAEP: name="CKM_KEY_WRAP_SET_OAEP"; break; |
|
|
|
|
case CKM_SKIPJACK_KEY_GEN: name="CKM_SKIPJACK_KEY_GEN"; break; |
|
|
|
|
case CKM_SKIPJACK_ECB64: name="CKM_SKIPJACK_ECB64"; break; |
|
|
|
|
case CKM_SKIPJACK_CBC64: name="CKM_SKIPJACK_CBC64"; break; |
|
|
|
|
case CKM_SKIPJACK_OFB64: name="CKM_SKIPJACK_OFB64"; break; |
|
|
|
|
case CKM_SKIPJACK_CFB64: name="CKM_SKIPJACK_CFB64"; break; |
|
|
|
|
case CKM_SKIPJACK_CFB32: name="CKM_SKIPJACK_CFB32"; break; |
|
|
|
|
case CKM_SKIPJACK_CFB16: name="CKM_SKIPJACK_CFB16"; break; |
|
|
|
|
case CKM_SKIPJACK_CFB8: name="CKM_SKIPJACK_CFB8"; break; |
|
|
|
|
case CKM_SKIPJACK_WRAP: name="CKM_SKIPJACK_WRAP"; break; |
|
|
|
|
case CKM_SKIPJACK_PRIVATE_WRAP: name="CKM_SKIPJACK_PRIVATE_WRAP"; break; |
|
|
|
|
case CKM_SKIPJACK_RELAYX: name="CKM_SKIPJACK_RELAYX"; break; |
|
|
|
|
case CKM_KEA_KEY_PAIR_GEN: name="CKM_KEA_KEY_PAIR_GEN"; break; |
|
|
|
|
case CKM_KEA_KEY_DERIVE: name="CKM_KEA_KEY_DERIVE"; break; |
|
|
|
|
case CKM_FORTEZZA_TIMESTAMP: name="CKM_FORTEZZA_TIMESTAMP"; break; |
|
|
|
|
case CKM_BATON_KEY_GEN: name="CKM_BATON_KEY_GEN"; break; |
|
|
|
|
case CKM_BATON_ECB128: name="CKM_BATON_ECB128"; break; |
|
|
|
|
case CKM_BATON_ECB96: name="CKM_BATON_ECB96"; break; |
|
|
|
|
case CKM_BATON_CBC128: name="CKM_BATON_CBC128"; break; |
|
|
|
|
case CKM_BATON_COUNTER: name="CKM_BATON_COUNTER"; break; |
|
|
|
|
case CKM_BATON_SHUFFLE: name="CKM_BATON_SHUFFLE"; break; |
|
|
|
|
case CKM_BATON_WRAP: name="CKM_BATON_WRAP"; break; |
|
|
|
|
//case CKM_ECDSA_KEY_PAIR_GEN: name="CKM_ECDSA_KEY_PAIR_GEN"; break;
|
|
|
|
|
case CKM_EC_KEY_PAIR_GEN: |
|
|
|
|
name="CKM_ECDSA_KEY_PAIR_GEN or CKM_EC_KEY_PAIR_GEN"; break; |
|
|
|
|
case CKM_ECDSA: name="CKM_ECDSA"; break; |
|
|
|
|
case CKM_ECDSA_SHA1: name="CKM_ECDSA_SHA1"; break; |
|
|
|
|
case CKM_ECDH1_DERIVE: name="CKM_ECDH1_DERIVE"; break; |
|
|
|
|
case CKM_ECDH1_COFACTOR_DERIVE: name="CKM_ECDH1_COFACTOR_DERIVE"; break; |
|
|
|
|
case CKM_ECMQV_DERIVE: name="CKM_ECMQV_DERIVE"; break; |
|
|
|
|
case CKM_JUNIPER_KEY_GEN: name="CKM_JUNIPER_KEY_GEN"; break; |
|
|
|
|
case CKM_JUNIPER_ECB128: name="CKM_JUNIPER_ECB128"; break; |
|
|
|
|
case CKM_JUNIPER_CBC128: name="CKM_JUNIPER_CBC128"; break; |
|
|
|
|
case CKM_JUNIPER_COUNTER: name="CKM_JUNIPER_COUNTER"; break; |
|
|
|
|
case CKM_JUNIPER_SHUFFLE: name="CKM_JUNIPER_SHUFFLE"; break; |
|
|
|
|
case CKM_JUNIPER_WRAP: name="CKM_JUNIPER_WRAP"; break; |
|
|
|
|
case CKM_FASTHASH: name="CKM_FASTHASH"; break; |
|
|
|
|
case CKM_AES_KEY_GEN: name="CKM_AES_KEY_GEN"; break; |
|
|
|
|
case CKM_AES_ECB: name="CKM_AES_ECB"; break; |
|
|
|
|
case CKM_AES_CBC: name="CKM_AES_CBC"; break; |
|
|
|
|
case CKM_AES_MAC: name="CKM_AES_MAC"; break; |
|
|
|
|
case CKM_AES_MAC_GENERAL: name="CKM_AES_MAC_GENERAL"; break; |
|
|
|
|
case CKM_AES_CBC_PAD: name="CKM_AES_CBC_PAD"; break; |
|
|
|
|
case CKM_DSA_PARAMETER_GEN: name="CKM_DSA_PARAMETER_GEN"; break; |
|
|
|
|
case CKM_DH_PKCS_PARAMETER_GEN: name="CKM_DH_PKCS_PARAMETER_GEN"; break; |
|
|
|
|
case CKM_X9_42_DH_PARAMETER_GEN: name="CKM_X9_42_DH_PARAMETER_GEN"; break; |
|
|
|
|
case CKM_VENDOR_DEFINED: name="CKM_VENDOR_DEFINED"; break; |
|
|
|
|
default: { |
|
|
|
|
std::stringstream ss; |
|
|
|
|
ss<<"unknown mechanism: "<<id; |
|
|
|
|
throw exception(ss.str()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct SlotInfo { |
|
|
|
|
FixString<64> slotDescription; |
|
|
|
@ -451,11 +500,15 @@ namespace cryptoki { |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
MechanismInfo mechanismInfo(Mechanism mechanism) { |
|
|
|
|
MechanismInfo info; |
|
|
|
|
MechanismInfo mechanisminfo(CK_MECHANISM_TYPE mechanism) { |
|
|
|
|
MechanismInfo info(mechanism); |
|
|
|
|
CK_MECHANISM_INFO cInfo; |
|
|
|
|
//! calls @c C_GetMechanismInfo
|
|
|
|
|
check(_init->_fn->C_GetMechanismInfo(_slot, mechanism, &info), |
|
|
|
|
check(_init->_fn->C_GetMechanismInfo(_slot, mechanism, &cInfo), |
|
|
|
|
CRYPTOKI_FN_LOG("C_GetMechanismInfo")); |
|
|
|
|
info.minKeySize = cInfo.ulMinKeySize; |
|
|
|
|
info.maxKeySize = cInfo.ulMaxKeySize; |
|
|
|
|
info.flags = cInfo.flags; |
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -473,7 +526,8 @@ namespace cryptoki { |
|
|
|
|
delete[] mechanisms; |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
for (CK_ULONG i(0); i<count; ++i) res.insert((Mechanism)mechanisms[i]); |
|
|
|
|
for (CK_ULONG i(0); i<count; ++i) |
|
|
|
|
res.insert(mechanisms[i]); |
|
|
|
|
} catch (...) { |
|
|
|
|
delete[] mechanisms; |
|
|
|
|
throw; |
|
|
|
@ -482,7 +536,7 @@ namespace cryptoki { |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SlotInfo slotInfo() { |
|
|
|
|
SlotInfo slotinfo() { |
|
|
|
|
SlotInfo info; |
|
|
|
|
CK_SLOT_INFO cInfo; |
|
|
|
|
//! calls @c C_GetSlotInfo
|
|
|
|
@ -496,7 +550,7 @@ namespace cryptoki { |
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TokenInfo tokenInfo() { |
|
|
|
|
TokenInfo tokeninfo() { |
|
|
|
|
TokenInfo info; |
|
|
|
|
//! calls @c C_GetTokenInfo
|
|
|
|
|
CK_TOKEN_INFO cInfo; |
|
|
|
@ -523,17 +577,17 @@ namespace cryptoki { |
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string inittoken(std::string in) { |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
/*! @bug does not compile:
|
|
|
|
|
@code |
|
|
|
|
bool inittoken(std::string pin, FixString<32> label) { |
|
|
|
|
//! calls @c C_InitToken
|
|
|
|
|
check(_init->_fn->C_InitToken |
|
|
|
|
(_slot, |
|
|
|
|
(unsigned char*)in.begin().operator->(), in.size(), |
|
|
|
|
(unsigned char*)res.begin().operator->()), |
|
|
|
|
CRYPTOKI_FN_LOG("C_InitToken")); |
|
|
|
|
return res; |
|
|
|
|
return check(_init->_fn->C_InitToken |
|
|
|
|
(_slot, |
|
|
|
|
(unsigned char*)pin.begin().operator->(), pin.size(), |
|
|
|
|
(unsigned char*)label.fix().begin().operator->()) |
|
|
|
|
CRYPTOKI_FN_LOG("C_InitToken")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
@ -631,7 +685,7 @@ namespace cryptoki { |
|
|
|
|
std::string decrypt(std::string in) { |
|
|
|
|
std::string res; |
|
|
|
|
res.resize(in.size()); |
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
CK_ULONG size(res.size()); //! @todo check if size is ok (seems so ...)
|
|
|
|
|
//! calls @c C_Decrypt
|
|
|
|
|
check(_slot._init->_fn->C_Decrypt |
|
|
|
|
(_session, |
|
|
|
@ -656,19 +710,11 @@ namespace cryptoki { |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string decryptfinal(std::string in) { |
|
|
|
|
std::string res; |
|
|
|
|
// res.resize(in.size());
|
|
|
|
|
// CK_ULONG size(res.size()); //! @todo check if size is ok
|
|
|
|
|
// //! calls @c C_DecryptFinal
|
|
|
|
|
// check(_slot._init->_fn->C_DecryptFinal
|
|
|
|
|
// (_session,
|
|
|
|
|
// (unsigned char*)in.begin().operator->(), in.size(),
|
|
|
|
|
// (unsigned char*)res.begin().operator->(), &size),
|
|
|
|
|
// CRYPTOKI_FN_LOG("C_DecryptFinal"));
|
|
|
|
|
// res.resize(size);
|
|
|
|
|
//! @todo check docu
|
|
|
|
|
return res; |
|
|
|
|
bool decryptfinal() { |
|
|
|
|
//! calls @c C_DecryptFinal
|
|
|
|
|
return check(_slot._init->_fn->C_DecryptFinal(_session, 0, 0), |
|
|
|
|
CRYPTOKI_FN_LOG("C_DecryptFinal")); |
|
|
|
|
//! @todo does this work?
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string decryptupdate(std::string in) { |
|
|
|
@ -1009,7 +1055,8 @@ namespace cryptoki { |
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
friend class Session; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CK_OBJECT_HANDLE _object; |
|
|
|
|
Session& _session; |
|
|
|
|
CK_RV _res; |
|
|
|
|
|
|
|
|
@ -1025,7 +1072,9 @@ namespace cryptoki { |
|
|
|
|
|
|
|
|
|
Object(); //! forbidden
|
|
|
|
|
|
|
|
|
|
Object(Session& session): _session(session), _res(CKR_OK) {} |
|
|
|
|
Object(Session& session): _session(session), _res(CKR_OK) { |
|
|
|
|
//! @todo _object = ???
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
@ -1049,6 +1098,12 @@ namespace cryptoki { |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
/*! @name Low Level Cryptoki Functions
|
|
|
|
|
|
|
|
|
|
Direct access to the low level cryptoki API. Better use the |
|
|
|
|
comfort methods. */ |
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool copyobject() { |
|
|
|
@ -1069,14 +1124,16 @@ namespace cryptoki { |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
|
@code |
|
|
|
|
bool decryptinit() { |
|
|
|
|
bool decryptinit(CK_MECHANISM_TYPE type, std::string param, |
|
|
|
|
const Object& key) { |
|
|
|
|
CK_MECHANISM mech = { |
|
|
|
|
type, param.begin().operator->(), param.size() |
|
|
|
|
}; |
|
|
|
|
//! calls @c C_DecryptInit
|
|
|
|
|
return check(_session._slot._init->_fn->C_DecryptInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), |
|
|
|
|
return check(_session._slot._init->_fn->C_DecryptInit |
|
|
|
|
(_session, &mech, key._object), |
|
|
|
|
CRYPTOKI_FN_LOG("C_DecryptInit")); |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! @todo Not implemented:
|
|
|
|
@ -1251,6 +1308,8 @@ namespace cryptoki { |
|
|
|
|
} |
|
|
|
|
@endcode */ |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|