added -lcrypto to examples; refs #10
This commit is contained in:
		| @@ -25,7 +25,7 @@ LDFLAGS += -lpcsclite | |||||||
| endif | endif | ||||||
| endif | endif | ||||||
| if !MINGW32 | if !MINGW32 | ||||||
| LDFLAGS += -ldl -lpthread -lssl | LDFLAGS += -ldl -lpthread -lssl -lcrypto | ||||||
| endif | endif | ||||||
|  |  | ||||||
| pcsc_demo_SOURCES = pcsc-demo.cxx | pcsc_demo_SOURCES = pcsc-demo.cxx | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
|  | touch iostream && \ | ||||||
| ./bootstrap.sh && \ | ./bootstrap.sh && \ | ||||||
| LDFLAGS="-L/usr/lib32 -L/usr/local/lib32 -m32" \ | LDFLAGS="-L/usr/lib32 -L/usr/local/lib32 -m32" \ | ||||||
|   CXXFLAGS="-m32" \ |   CXXFLAGS="-m32" \ | ||||||
|   CPPFLAGS="-DCRYPTOKI_LOG\(X\)='std::clog<<X<<"'"@"'"<<__PRETTY_FUNCTION__<<std::endl'" \ |   CPPFLAGS="-include iostream -DCRYPTOKI_LOG\(X\)='std::clog<<"'"CRYPTOKI_"'"<<X<<"'"_@_"'"<<__PRETTY_FUNCTION__<<std::endl' -DPCSC_LOG\(X\)='std::clog<<"'"PCSC_"'"<<X<<"'"_@_"'"<<__PRETTY_FUNCTION__<<std::endl' -DOPENSSL_LOG\(X\)='std::clog<<"'"OPENSSL_"'"<<X<<"'"_@_"'"<<__PRETTY_FUNCTION__<<std::endl'" \ | ||||||
|   ./configure \ |   ./configure \ | ||||||
|   --libdir=/usr/local/lib32 \ |   --libdir=/usr/local/lib32 \ | ||||||
|   --build=x86_64 \ |   --build=x86_64 \ | ||||||
| @@ -18,6 +19,9 @@ LDFLAGS="-L/opt/local/i586-mingw32msvc/lib" \ | |||||||
| make && \ | make && \ | ||||||
| sudo make install && \ | sudo make install && \ | ||||||
| make clean && \ | make clean && \ | ||||||
|  |   CPPFLAGS="-include iostream -DCRYPTOKI_LOG\(X\)='std::clog<<"'"CRYPTOKI_"'"<<X<<"'"_@_"'"<<__PRETTY_FUNCTION__<<std::endl' -DPCSC_LOG\(X\)='std::clog<<"'"PCSC_"'"<<X<<"'"_@_"'"<<__PRETTY_FUNCTION__<<std::endl' -DOPENSSL_LOG\(X\)='std::clog<<"'"OPENSSL_"'"<<X<<"'"_@_"'"<<__PRETTY_FUNCTION__<<std::endl'" \ | ||||||
| ./configure && \ | ./configure && \ | ||||||
| make check && \ | make check && \ | ||||||
| sudo make install | sudo make install && \ | ||||||
|  | rm iostream | ||||||
|  |  | ||||||
|   | |||||||
| @@ -203,16 +203,22 @@ namespace cryptoki { | |||||||
|     CRYPTOKI_LOG("log"); |     CRYPTOKI_LOG("log"); | ||||||
|     SlotList res; |     SlotList res; | ||||||
|     CK_ULONG count(0); |     CK_ULONG count(0); | ||||||
|  |     std::cout<<"CALL: C_GetSlotList"<<std::endl; | ||||||
|     //! calls @c C_GetSlotList |     //! calls @c C_GetSlotList | ||||||
|     check(_fn->C_GetSlotList(tokenPresent?TRUE:FALSE, 0, &count), |     check(_fn->C_GetSlotList(tokenPresent?TRUE:FALSE, 0, &count), | ||||||
|           CRYPTOKI_FN_LOG("C_GetSlotList")); |           CRYPTOKI_FN_LOG("C_GetSlotList")); | ||||||
|  |     std::cout<<"C_GetSlotList returns "<<count<<" slots"<<std::endl; | ||||||
|     if (!count || !*this) return res; |     if (!count || !*this) return res; | ||||||
|     CK_SLOT_ID* slots = 0; |     CK_SLOT_ID* slots = 0; | ||||||
|     try { |     try { | ||||||
|       do { |       do { | ||||||
|         delete[] slots; |         delete[] slots; | ||||||
|         slots = new CK_SLOT_ID[count]; |         slots = new CK_SLOT_ID[count]; | ||||||
|  |         std::cout<<"CALL: C_GetSlotList to get IDs"<<std::endl; | ||||||
|         _res = _fn->C_GetSlotList(tokenPresent?TRUE:FALSE, slots, &count); |         _res = _fn->C_GetSlotList(tokenPresent?TRUE:FALSE, slots, &count); | ||||||
|  |         std::cout<<"C_GetSlotList returns "<<count<<" slots"<<std::endl; | ||||||
|  |         if (_res==CKR_BUFFER_TOO_SMALL) | ||||||
|  |           std::cout<<"Buffer too small - repeat"<<std::endl; | ||||||
|       } while (_res==CKR_BUFFER_TOO_SMALL); |       } while (_res==CKR_BUFFER_TOO_SMALL); | ||||||
|       check(_res, CRYPTOKI_FN_LOG("C_GetSlotList")); |       check(_res, CRYPTOKI_FN_LOG("C_GetSlotList")); | ||||||
|       if (!*this) return res; |       if (!*this) return res; | ||||||
| @@ -294,7 +300,6 @@ namespace cryptoki { | |||||||
|     attrs.push_back(Attribute(CKA_ISSUER, cert.issuerDER())); |     attrs.push_back(Attribute(CKA_ISSUER, cert.issuerDER())); | ||||||
|     attrs.push_back(Attribute(CKA_SERIAL_NUMBER, cert.serial())); |     attrs.push_back(Attribute(CKA_SERIAL_NUMBER, cert.serial())); | ||||||
|     attrs.push_back(Attribute(CKA_VALUE, cert.valueDER())); |     attrs.push_back(Attribute(CKA_VALUE, cert.valueDER())); | ||||||
|     CRYPTOKI_LOG("create: serial = "<<crypto::hex(cert.serial())); |  | ||||||
|     return create(attrs); |     return create(attrs); | ||||||
|   } |   } | ||||||
|    |    | ||||||
| @@ -340,6 +345,19 @@ namespace cryptoki { | |||||||
|     return create(attrs); |     return create(attrs); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   //---------------------------------------------------------------------------- | ||||||
|  |   Object  Session::create(const std::string& application, | ||||||
|  |                           const std::string& label, | ||||||
|  |                           const std::string& data) { | ||||||
|  |     AttributeList attrs; | ||||||
|  |     attrs.push_back(Attribute(CKA_CLASS).from<CK_OBJECT_CLASS>(CKO_DATA)); | ||||||
|  |     attrs.push_back(Attribute(CKA_TOKEN).from<CK_BBOOL>(TRUE)); | ||||||
|  |     attrs.push_back(Attribute(CKA_APPLICATION, application)); | ||||||
|  |     attrs.push_back(Attribute(CKA_LABEL, label)); | ||||||
|  |     attrs.push_back(Attribute(CKA_VALUE, data)); | ||||||
|  |     return create(attrs); | ||||||
|  |   } | ||||||
|  |    | ||||||
|   //---------------------------------------------------------------------------- |   //---------------------------------------------------------------------------- | ||||||
|   Object Session::create(const AttributeList& attrs) { |   Object Session::create(const AttributeList& attrs) { | ||||||
|     CRYPTOKI_LOG("log"); |     CRYPTOKI_LOG("log"); | ||||||
|   | |||||||
| @@ -976,6 +976,9 @@ namespace cryptoki { | |||||||
|       //! Create a new PrivateKey Object. |       //! Create a new PrivateKey Object. | ||||||
|       Object create(const std::string& label, const openssl::PrivateKey& key, |       Object create(const std::string& label, const openssl::PrivateKey& key, | ||||||
|                     const openssl::X509& cert); |                     const openssl::X509& cert); | ||||||
|  |       //! | ||||||
|  |       Object create(const std::string& application, const std::string& label, | ||||||
|  |                     const std::string& data); | ||||||
|        |        | ||||||
|       //@} |       //@} | ||||||
|        |        | ||||||
|   | |||||||
| @@ -239,7 +239,7 @@ namespace pcsc { | |||||||
|           Status status() { |           Status status() { | ||||||
|             DWORD dummy(0); |             DWORD dummy(0); | ||||||
|             DWORD s; |             DWORD s; | ||||||
|             DWORD len(MAX_ATR_SIZE); |             DWORD len(10*(MAX_ATR_SIZE+33)); // 33 is default on Linux | ||||||
|             unsigned char a[len]; |             unsigned char a[len]; | ||||||
|             check(SCardStatus(_id, 0, &dummy, &s, &_protocol, a, &len), |             check(SCardStatus(_id, 0, &dummy, &s, &_protocol, a, &len), | ||||||
|                   "query smartcard status"); |                   "query smartcard status"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user