attributes are on the way

master
Marc Wäckerlin 16 years ago
parent b5643a87a2
commit 481ae4ed8d
  1. 13
      doc/examples/cryptoki-demo.cxx
  2. 62
      src/cryptoki.hxx

@ -2,7 +2,20 @@
#include <cryptoki.hxx>
#include <iostream>
template <int NUM, typename TYPE> std::vector<TYPE> toVector(TYPE in[NUM]) {
return std::vector<TYPE>(in, in+NUM);
}
#define VECTOR(ARRAY) toVector<sizeof(ARRAY)/sizeof(ARRAY[0])>(ARRAY)
template <typename Array> void print(const std::vector<Array>& v) {
for (typename std::vector<Array>::const_iterator it(v.begin()); it!=v.end(); ++it)
std::cout<<"Item: "<<*it<<std::endl;
}
int main(int argc, char const*const*const argv) try {
//std::vector<int> v(toVector<4>((int[]){1,2,3,4}));
std::vector<int> v(VECTOR(((int[]){1,2,3,4})));
print(v);
cryptoki::Init init(argc==2?argv[1]:"onepin-opensc-pkcs11.so");
cryptoki::Info inf(init.info());
std::cout<<"##################### INFO #####################"<<std::endl

@ -63,26 +63,32 @@ namespace cryptoki {
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;
};
template<> class AttributeType<> {
public: typedef Type;
};*/
typedef std::vector<CK_ATTRIBUTE_TYPE> AttributeTypeList;
typedef std::vector<CK_ATTRIBUTE> AttributeList;
// //! 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;
// public: typedef Type Param;
// };
// template<> class AttributeType<CKA_KEY_TYPE> {
// public: typedef CK_KEY_TYPE Type;
// public: typedef Type Param;
// };
// template<> class AttributeType<CKA_APPLICATION> {
// public: typedef CK_CHAR Type;
// public: typedef std::string Param;
// };
// template<> class AttributeType<CKA_VALUE> {
// public: typedef CKA_BYTE Type;
// public: typedef std::string Param;
// };
// template<> class AttributeType<> {
// public: typedef Type;
// public: typedef Type Param;
// };
template<std::string::size_type SIZE>
class FixString: public std::string {
@ -1208,15 +1214,17 @@ namespace cryptoki {
}
@endcode */
/*! @todo Not implemented:
@code
bool getattributevalue() {
AttributeList getattributevalue(const AttributeTypeList& attributes) {
AttributeList res;
for (AttributeTypeList::const_iterator it(attributes.begin());
it!=attributes.end(); ++it)
res.push_back((CK_ATTRIBUTE){*it, 0, 0});
//! calls @c C_GetAttributeValue
return check(_session._slot._init->_fn->C_GetAttributeValue(_session, CK_OBJECT_HANDLE,
CK_ATTRIBUTE_PTR, CK_ULONG),
CRYPTOKI_FN_LOG("C_GetAttributeValue"));
// return check(_session._slot._init->_fn->C_GetAttributeValue(_session, _object,
// CK_ATTRIBUTE_PTR, CK_ULONG),
// CRYPTOKI_FN_LOG("C_GetAttributeValue"));
return res;
}
@endcode */
/*! @todo Not implemented:
@code

Loading…
Cancel
Save