diff --git a/doc/examples/cryptoki-demo.cxx b/doc/examples/cryptoki-demo.cxx index 064ca02..26760f7 100644 --- a/doc/examples/cryptoki-demo.cxx +++ b/doc/examples/cryptoki-demo.cxx @@ -2,7 +2,20 @@ #include #include +template std::vector toVector(TYPE in[NUM]) { + return std::vector(in, in+NUM); +} +#define VECTOR(ARRAY) toVector(ARRAY) + +template void print(const std::vector& v) { + for (typename std::vector::const_iterator it(v.begin()); it!=v.end(); ++it) + std::cout<<"Item: "<<*it< v(toVector<4>((int[]){1,2,3,4})); + std::vector 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 #####################"< MechanismList; - //! Map Attribute Class to type - /*! @todo to be completed ... */ - template class AttributeType {}; - template<> class AttributeType { - 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 AttributeTypeList; + typedef std::vector AttributeList; + +// //! Map Attribute Class to type +// /*! @todo to be completed ... */ +// template class AttributeType {}; +// template<> class AttributeType { +// public: typedef CK_OBJECT_CLASS Type; +// public: typedef Type Param; +// }; +// template<> class AttributeType { +// public: typedef CK_KEY_TYPE Type; +// public: typedef Type Param; +// }; +// template<> class AttributeType { +// public: typedef CK_CHAR Type; +// public: typedef std::string Param; +// }; +// template<> class AttributeType { +// public: typedef CKA_BYTE Type; +// public: typedef std::string Param; +// }; +// template<> class AttributeType<> { +// public: typedef Type; +// public: typedef Type Param; +// }; template 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