attributes are on the way
This commit is contained in:
		| @@ -2,7 +2,20 @@ | |||||||
| #include <cryptoki.hxx> | #include <cryptoki.hxx> | ||||||
| #include <iostream> | #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 { | 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::Init init(argc==2?argv[1]:"onepin-opensc-pkcs11.so"); | ||||||
|   cryptoki::Info inf(init.info()); |   cryptoki::Info inf(init.info()); | ||||||
|   std::cout<<"##################### INFO #####################"<<std::endl |   std::cout<<"##################### INFO #####################"<<std::endl | ||||||
|   | |||||||
| @@ -63,26 +63,32 @@ namespace cryptoki { | |||||||
|  |  | ||||||
|   typedef std::set<CK_MECHANISM_TYPE> MechanismList; |   typedef std::set<CK_MECHANISM_TYPE> MechanismList; | ||||||
|  |  | ||||||
|   //! Map Attribute Class to type |   typedef std::vector<CK_ATTRIBUTE_TYPE> AttributeTypeList; | ||||||
|   /*! @todo to be completed ... */ |   typedef std::vector<CK_ATTRIBUTE> AttributeList; | ||||||
|   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; |  | ||||||
|       };*/ |  | ||||||
|  |  | ||||||
|  | //   //! 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> |   template<std::string::size_type SIZE> | ||||||
|       class FixString: public std::string { |       class FixString: public std::string { | ||||||
| @@ -1208,15 +1214,17 @@ namespace cryptoki { | |||||||
|       } |       } | ||||||
|           @endcode */ |           @endcode */ | ||||||
|  |  | ||||||
|       /*! @todo Not implemented: |       AttributeList getattributevalue(const AttributeTypeList& attributes) { | ||||||
|           @code |         AttributeList res; | ||||||
|       bool getattributevalue() { |         for (AttributeTypeList::const_iterator it(attributes.begin()); | ||||||
|  |              it!=attributes.end(); ++it) | ||||||
|  |           res.push_back((CK_ATTRIBUTE){*it, 0, 0}); | ||||||
|         //! calls @c C_GetAttributeValue |         //! calls @c C_GetAttributeValue | ||||||
|         return check(_session._slot._init->_fn->C_GetAttributeValue(_session, CK_OBJECT_HANDLE, | //         return check(_session._slot._init->_fn->C_GetAttributeValue(_session, _object, | ||||||
|                                          CK_ATTRIBUTE_PTR, CK_ULONG), | //                                          CK_ATTRIBUTE_PTR, CK_ULONG), | ||||||
|                      CRYPTOKI_FN_LOG("C_GetAttributeValue")); | //                      CRYPTOKI_FN_LOG("C_GetAttributeValue")); | ||||||
|  |         return res; | ||||||
|       } |       } | ||||||
|           @endcode */ |  | ||||||
|  |  | ||||||
|       /*! @todo Not implemented: |       /*! @todo Not implemented: | ||||||
|           @code |           @code | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user