From f1cd9514f32defb7a523f1657ef540b0aec01dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 28 Aug 2009 06:56:23 +0000 Subject: [PATCH] many new but completely untested methods --- configure.in | 2 +- .../{cryptoki-demo.cpp => cryptoki-demo.cxx} | 0 doc/examples/makefile.am | 19 + doc/examples/{pcsc-demo.cpp => pcsc-demo.cxx} | 2 +- doc/makefile.am | 2 + src/cryptoki.hxx | 428 +++++++++++------- src/makefile.am | 4 + 7 files changed, 295 insertions(+), 162 deletions(-) rename doc/examples/{cryptoki-demo.cpp => cryptoki-demo.cxx} (100%) create mode 100644 doc/examples/makefile.am rename doc/examples/{pcsc-demo.cpp => pcsc-demo.cxx} (97%) diff --git a/configure.in b/configure.in index 82284d8..ee26e92 100644 --- a/configure.in +++ b/configure.in @@ -13,7 +13,7 @@ AM_INIT_AUTOMAKE(x_packagename, x_major.x_minor.x_least, [marc@waeckerlin.org]) # files to create AC_CONFIG_FILES(makefile src/makefile test/makefile - doc/doxyfile doc/makefile) + doc/doxyfile doc/examples/makefile doc/makefile) # copy M4 to shell PACKAGENAME=x_packagename diff --git a/doc/examples/cryptoki-demo.cpp b/doc/examples/cryptoki-demo.cxx similarity index 100% rename from doc/examples/cryptoki-demo.cpp rename to doc/examples/cryptoki-demo.cxx diff --git a/doc/examples/makefile.am b/doc/examples/makefile.am new file mode 100644 index 0000000..13f96df --- /dev/null +++ b/doc/examples/makefile.am @@ -0,0 +1,19 @@ +## @id $Id$ + +## 1 2 3 4 5 6 7 8 +## 45678901234567890123456789012345678901234567890123456789012345678901234567890 + +noinst_PROGRAMS = pcsc-demo cryptoki-demo + +AM_CXXFLAGS = -I${top_srcdir}/src \ + -I/usr/include/PCSC \ + -I/usr/include/opencryptoki + +pcsc_demo_SOURCES = pcsc-demo.cxx +pcsc_demo_LDADD = -lpcsclite + +cryptoki_demo_SOURCES = cryptoki-demo.cxx +cryptoki_demo_LDADD = -ldl -lcryptoki++ +cryptoki_demo_LDFLAGS = -L${top_builddir}/src + +MAINTAINERCLEANFILES = makefile.in diff --git a/doc/examples/pcsc-demo.cpp b/doc/examples/pcsc-demo.cxx similarity index 97% rename from doc/examples/pcsc-demo.cpp rename to doc/examples/pcsc-demo.cxx index 4c9a286..a4380bb 100644 --- a/doc/examples/pcsc-demo.cpp +++ b/doc/examples/pcsc-demo.cxx @@ -1,5 +1,5 @@ //g++ -I ../svn -I /usr/include/PCSC test.cpp -lpcsclite -ggdb3 -#include "pcscpp/pcsc.hxx" +#include #include int main(int, char const*const*const argv) try { diff --git a/doc/makefile.am b/doc/makefile.am index 084e0bb..3352823 100644 --- a/doc/makefile.am +++ b/doc/makefile.am @@ -5,6 +5,8 @@ ## 1 2 3 4 5 6 7 8 ## 45678901234567890123456789012345678901234567890123456789012345678901234567890 +SUBDIRS = examples + develdir = ${pkgdatadir}/doc devel_DATA = html/index.html diff --git a/src/cryptoki.hxx b/src/cryptoki.hxx index 8787214..e4fe9b3 100644 --- a/src/cryptoki.hxx +++ b/src/cryptoki.hxx @@ -366,12 +366,22 @@ namespace cryptoki { @param exc wether exceptions should be thrown */ Init(const std::string& library="onepin-opensc-pkcs11.so", bool exc=true); + /*! @name C Like Error Handling + + You are strongly recommended not to disable exception + handling. If you disable it, you must check after every + operation whether it was successful or not. These methods + provide all you need for that. */ + //@{ + /*! @return @c true if last cryptoki on this object call was successful */ operator bool(); /*! @return error text of last cryptoki call */ std::string error(); + //@} + Info info() { Info inf; CK_INFO cInf; @@ -397,8 +407,9 @@ namespace cryptoki { class Slot { private: - friend class Session; friend class Init; + friend class Session; + friend class Object; Init* _init; CK_SLOT_ID _slot; @@ -420,6 +431,14 @@ namespace cryptoki { public: + /*! @name C Like Error Handling + + You are strongly recommended not to disable exception + handling. If you disable it, you must check after every + operation whether it was successful or not. These methods + provide all you need for that. */ + //@{ + /*! @return @c true if last cryptoki on this object call was successful */ operator bool() { return _res==CKR_OK; @@ -430,6 +449,8 @@ namespace cryptoki { return _init->error(_res); } + //@} + MechanismInfo mechanismInfo(Mechanism mechanism) { MechanismInfo info; //! calls @c C_GetMechanismInfo @@ -502,20 +523,27 @@ namespace cryptoki { return info; } - /*! @todo Not implemented: - @code - bool inittoken() { + std::string inittoken(std::string in) { + std::string res; + res.resize(in.size()); //! calls @c C_InitToken - return check(_init->_fn->C_InitToken(_slot, CK_CHAR_PTR, CK_ULONG, CK_CHAR_PTR), - CRYPTOKI_FN_LOG("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; } - @endcode */ /*! @todo Not implemented: @code - bool waitforslotevent() { + class SlotEventListener { + public: virtual void slotEvent() = 0; + } + + bool registerforslotevent(SlotEventListener&) { //! calls @c C_WaitForSlotEvent - return check(_init->_fn->C_WaitForSlotEvent(CK_FLAGS, _slot_PTR, CK_VOID_PTR), + return check(_init->_fn->C_WaitForSlotEvent(CK_FLAGS, &_slot, CK_VOID_PTR), CRYPTOKI_FN_LOG("C_WaitForSlotEvent")); } @endcode */ @@ -526,6 +554,8 @@ namespace cryptoki { class Session { private: + friend class Object; + Slot& _slot; CK_SESSION_HANDLE _session; CK_RV _res; @@ -549,12 +579,10 @@ namespace cryptoki { //! Opens a new session. /*! @param slot slot to open a session on */ Session(Slot& slot): _slot(slot), _session(0), _res(CKR_OK) { - /*! @todo implement //! calls @c C_OpenSession - return check(_slot._init->_fn->C_OpenSession(_slot._slot, CK_FLAGS, CK_VOID_PTR, CK_NOTIFY, - &_session), - CRYPTOKI_FN_LOG("C_OpenSession")); - */ + check(_slot._init->_fn->C_OpenSession(_slot._slot, 0, 0, 0, &_session), + CRYPTOKI_FN_LOG("C_OpenSession")); + //! @todo pass parameter } //! Closes actual session @@ -568,6 +596,14 @@ namespace cryptoki { } } + /*! @name C Like Error Handling + + You are strongly recommended not to disable exception + handling. If you disable it, you must check after every + operation whether it was successful or not. These methods + provide all you need for that. */ + //@{ + /*! @return @c true if last cryptoki on this object call was successful */ operator bool() { return _res==CKR_OK; @@ -576,86 +612,120 @@ namespace cryptoki { /*! @return error text of last cryptoki call */ std::string error() { return _slot._init->error(_res); - } + } - /*! @todo Not implemented: - @code - void cancel() { + //@} + + /*! @name Low Level Cryptoki Functions + + Direct access to the low level cryptoki API. Better use the + comfort methods. */ + //@{ + bool cancel() { //! calls @c C_CancelFunction return check(_slot._init->_fn->C_CancelFunction(_session), CRYPTOKI_FN_LOG("C_CancelFunction")); } - @endcode */ - /*! @todo Not implemented: - @code - bool decrypt() { + std::string decrypt(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_Decrypt - return check(_slot._init->_fn->C_Decrypt(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_Decrypt")); - } - @endcode */ - - /*! @todo Not implemented: - @code - bool decryptdigestupdate() { + check(_slot._init->_fn->C_Decrypt + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_Decrypt")); + res.resize(size); + return res; + } + + std::string decryptdigestupdate(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_DecryptDigestUpdate - return check(_slot._init->_fn->C_DecryptDigestUpdate(_session, CK_BYTE_PTR, CK_ULONG, - CK_BYTE_PTR, CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_DecryptDigestUpdate")); - } - @endcode */ - - /*! @todo Not implemented: - @code - bool decryptfinal() { - //! calls @c C_DecryptFinal - return check(_slot._init->_fn->C_DecryptFinal(_session, CK_BYTE_PTR, CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_DecryptFinal")); - } - @endcode */ - - /*! @todo Not implemented: - @code - bool decryptupdate() { + check(_slot._init->_fn->C_DecryptDigestUpdate + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_DecryptDigestUpdate")); + res.resize(size); + 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; + } + + std::string decryptupdate(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_DecryptUpdate - return check(_slot._init->_fn->C_DecryptUpdate(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_DecryptUpdate")); - } - @endcode */ - - /*! @todo Not implemented: - @code - bool decryptverifyupdate() { + check(_slot._init->_fn->C_DecryptUpdate + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_DecryptUpdate")); + res.resize(size); + return res; + } + + std::string decryptverifyupdate(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_DecryptVerifyUpdate - return check(_slot._init->_fn->C_DecryptVerifyUpdate(_session, CK_BYTE_PTR, CK_ULONG, - CK_BYTE_PTR, CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_DecryptVerifyUpdate")); - } - @endcode */ - - /*! @todo Not implemented: - @code - bool digest() { + check(_slot._init->_fn->C_DecryptVerifyUpdate + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_DecryptVerifyUpdate")); + res.resize(size); + return res; + } + + std::string digest(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_Digest - return check(_slot._init->_fn->C_Digest(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_Digest")); - } - @endcode */ - - /*! @todo Not implemented: - @code - bool digestencryptupdate() { + check(_slot._init->_fn->C_Digest + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_Digest")); + res.resize(size); + return res; + } + + std::string digestencryptupdate(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_DigestEncryptUpdate - return check(_slot._init->_fn->C_DigestEncryptUpdate(_session, CK_BYTE_PTR, CK_ULONG, - CK_BYTE_PTR, CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_DigestEncryptUpdate")); + check(_slot._init->_fn->C_DigestEncryptUpdate + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_DigestEncryptUpdate")); + res.resize(size); + return res; } - @endcode */ /*! @todo Not implemented: @code @@ -684,15 +754,19 @@ namespace cryptoki { } @endcode */ - /*! @todo Not implemented: - @code - bool encrypt() { + std::string encrypt(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_Encrypt - return check(_slot._init->_fn->C_Encrypt(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_Encrypt")); + check(_slot._init->_fn->C_Encrypt + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_Encrypt")); + res.resize(size); + return res; } - @endcode */ /*! @todo Not implemented: @code @@ -703,15 +777,19 @@ namespace cryptoki { } @endcode */ - /*! @todo Not implemented: - @code - bool encryptupdate() { + std::string encryptupdate(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_EncryptUpdate - return check(_slot._init->_fn->C_EncryptUpdate(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_EncryptUpdate")); + check(_slot._init->_fn->C_EncryptUpdate + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_EncryptUpdate")); + res.resize(size); + return res; } - @endcode */ /*! @todo Not implemented: @code @@ -780,7 +858,7 @@ namespace cryptoki { @code bool initpin() { //! calls @c C_InitPIN - return check(_init->_fn->C_InitPIN(_session, CK_CHAR_PTR, CK_ULONG), + return check(_slot._init->_fn->C_InitPIN(_session, CK_CHAR_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_InitPIN")); } @endcode */ @@ -789,7 +867,7 @@ namespace cryptoki { @code bool login() { //! calls @c C_Login - return check(_init->_fn->C_Login(_session, CK_USER_TYPE, CK_CHAR_PTR, CK_ULONG), + return check(_slot._init->_fn->C_Login(_session, CK_USER_TYPE, CK_CHAR_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_Login")); } @endcode */ @@ -798,7 +876,7 @@ namespace cryptoki { @code bool logout() { //! calls @c C_Logout - return check(_init->_fn->C_Logout(_session), + return check(_slot._init->_fn->C_Logout(_session), CRYPTOKI_FN_LOG("C_Logout")); } @endcode */ @@ -808,7 +886,7 @@ namespace cryptoki { @code bool seedrandom() { //! calls @c C_SeedRandom - return check(_init->_fn->C_SeedRandom(_session, CK_BYTE_PTR, CK_ULONG), + return check(_slot._init->_fn->C_SeedRandom(_session, CK_BYTE_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_SeedRandom")); } @endcode */ @@ -817,55 +895,67 @@ namespace cryptoki { @code bool setpin() { //! calls @c C_SetPIN - return check(_init->_fn->C_SetPIN(_session, CK_CHAR_PTR, CK_ULONG, CK_CHAR_PTR, CK_ULONG), + return check(_slot._init->_fn->C_SetPIN(_session, CK_CHAR_PTR, CK_ULONG, CK_CHAR_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_SetPIN")); } @endcode */ - /*! @todo Not implemented: - @code - bool sign() { + std::string sign(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_Sign - return check(_init->_fn->C_Sign(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_Sign")); - } - @endcode */ - - /*! @todo Not implemented: - @code - bool signencryptupdate() { + check(_slot._init->_fn->C_Sign + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_Sign")); + res.resize(size); + return res; + } + + std::string signencryptupdate(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_SignEncryptUpdate - return check(_init->_fn->C_SignEncryptUpdate(_session, CK_BYTE_PTR, CK_ULONG, - CK_BYTE_PTR, CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_SignEncryptUpdate")); + check(_slot._init->_fn->C_SignEncryptUpdate + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_SignEncryptUpdate")); + res.resize(size); + return res; } - @endcode */ /*! @todo Not implemented: @code bool signfinal() { //! calls @c C_SignFinal - return check(_init->_fn->C_SignFinal(_session, CK_BYTE_PTR, CK_ULONG_PTR), + return check(_slot._init->_fn->C_SignFinal(_session, CK_BYTE_PTR, CK_ULONG_PTR), CRYPTOKI_FN_LOG("C_SignFinal")); } @endcode */ - /*! @todo Not implemented: - @code - bool signrecover() { + std::string signrecover(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_SignRecover - return check(_init->_fn->C_SignRecover(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_SignRecover")); + check(_slot._init->_fn->C_SignRecover + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_SignRecover")); + res.resize(size); + return res; } - @endcode */ /*! @todo Not implemented: @code bool signupdate() { //! calls @c C_SignUpdate - return check(_init->_fn->C_SignUpdate(_session, CK_BYTE_PTR, CK_ULONG), + return check(_slot._init->_fn->C_SignUpdate(_session, CK_BYTE_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_SignUpdate")); } @endcode */ @@ -874,7 +964,8 @@ namespace cryptoki { @code bool verify() { //! calls @c C_Verify - return check(_init->_fn->C_Verify(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, CK_ULONG), + return check(_slot._init->_fn->C_Verify(_session, CK_BYTE_PTR, CK_ULONG, + CK_BYTE_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_Verify")); } @endcode */ @@ -883,53 +974,69 @@ namespace cryptoki { @code bool verifyfinal() { //! calls @c C_VerifyFinal - return check(_init->_fn->C_VerifyFinal(_session, CK_BYTE_PTR, CK_ULONG), + return check(_slot._init->_fn->C_VerifyFinal(_session, CK_BYTE_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_VerifyFinal")); } @endcode */ - /*! @todo Not implemented: - @code - bool verifyrecover() { + std::string verifyrecover(std::string in) { + std::string res; + res.resize(in.size()); + CK_ULONG size(res.size()); //! @todo check if size is ok //! calls @c C_VerifyRecover - return check(_init->_fn->C_VerifyRecover(_session, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, - CK_ULONG_PTR), - CRYPTOKI_FN_LOG("C_VerifyRecover")); + check(_slot._init->_fn->C_VerifyRecover + (_session, + (unsigned char*)in.begin().operator->(), in.size(), + (unsigned char*)res.begin().operator->(), &size), + CRYPTOKI_FN_LOG("C_VerifyRecover")); + res.resize(size); + return res; } - @endcode */ /*! @todo Not implemented: @code bool verifyupdate() { //! calls @c C_VerifyUpdate - return check(_init->_fn->C_VerifyUpdate(_session, CK_BYTE_PTR, CK_ULONG), + return check(_slot._init->_fn->C_VerifyUpdate(_session, CK_BYTE_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_VerifyUpdate")); } @endcode */ - + //@} }; -#ifdef NO_OBJECTS_YET //! @todo class Object { private: + friend class Session; + + Session& _session; CK_RV _res; bool check(CK_RV result, const std::string& context="") { _res = result; - if (_exc && !*this) + if (_session._slot._init->_exc && !*this) if (context.size()) throw access_error(context+": "+error()); else throw access_error(error()); return _res==CKR_OK; } + + Object(); //! forbidden + Object(Session& session): _session(session), _res(CKR_OK) {} + public: - Object(): _res(CKR_OK) {} + /*! @name C Like Error Handling + You are strongly recommended not to disable exception + handling. If you disable it, you must check after every + operation whether it was successful or not. These methods + provide all you need for that. */ + //@{ + /*! @return @c true if last cryptoki on this object call was successful */ operator bool() { return _res==CKR_OK; @@ -937,14 +1044,16 @@ namespace cryptoki { /*! @return error text of last cryptoki call */ std::string error() { - return error(_res); + return _session._slot._init->error(_res); } + + //@} /*! @todo Not implemented: @code bool copyobject() { //! calls @c C_CopyObject - return check(_init->_fn->C_CopyObject(_session, CK_OBJECT_HANDLE, + return check(_session._slot._init->_fn->C_CopyObject(_session, CK_OBJECT_HANDLE, CK_ATTRIBUTE_PTR, CK_ULONG, CK_OBJECT_HANDLE_PTR), CRYPTOKI_FN_LOG("C_CopyObject")); } @@ -954,7 +1063,7 @@ namespace cryptoki { @code bool createobject() { //! calls @c C_CreateObject - return check(_init->_fn->C_CreateObject(_session, CK_ATTRIBUTE_PTR, CK_ULONG, + return check(_session._slot._init->_fn->C_CreateObject(_session, CK_ATTRIBUTE_PTR, CK_ULONG, CK_OBJECT_HANDLE_PTR), CRYPTOKI_FN_LOG("C_CreateObject")); } @@ -964,7 +1073,7 @@ namespace cryptoki { @code bool decryptinit() { //! calls @c C_DecryptInit - return check(_init->_fn->C_DecryptInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_DecryptInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_DecryptInit")); } @endcode */ @@ -974,7 +1083,7 @@ namespace cryptoki { @code bool derivekey() { //! calls @c C_DeriveKey - return check(_init->_fn->C_DeriveKey(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE, + return check(_session._slot._init->_fn->C_DeriveKey(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE, CK_ATTRIBUTE_PTR, CK_ULONG, CK_OBJECT_HANDLE_PTR), CRYPTOKI_FN_LOG("C_DeriveKey")); } @@ -984,7 +1093,7 @@ namespace cryptoki { @code bool destroyobject() { //! calls @c C_DestroyObject - return check(_init->_fn->C_DestroyObject(_session, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_DestroyObject(_session, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_DestroyObject")); } @endcode */ @@ -994,7 +1103,7 @@ namespace cryptoki { @code bool digestkey() { //! calls @c C_DigestKey - return check(_init->_fn->C_DigestKey(_session, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_DigestKey(_session, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_DigestKey")); } @endcode */ @@ -1004,7 +1113,7 @@ namespace cryptoki { @code bool encryptinit() { //! calls @c C_EncryptInit - return check(_init->_fn->C_EncryptInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_EncryptInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_EncryptInit")); } @endcode */ @@ -1014,7 +1123,7 @@ namespace cryptoki { @code bool findobjects() { //! calls @c C_FindObjects - return check(_init->_fn->C_FindObjects(_session, CK_OBJECT_HANDLE_PTR, CK_ULONG, + return check(_session._slot._init->_fn->C_FindObjects(_session, CK_OBJECT_HANDLE_PTR, CK_ULONG, CK_ULONG_PTR), CRYPTOKI_FN_LOG("C_FindObjects")); } @@ -1024,7 +1133,7 @@ namespace cryptoki { @code bool generatekey() { //! calls @c C_GenerateKey - return check(_init->_fn->C_GenerateKey(_session, CK_MECHANISM_PTR, CK_ATTRIBUTE_PTR, + return check(_session._slot._init->_fn->C_GenerateKey(_session, CK_MECHANISM_PTR, CK_ATTRIBUTE_PTR, CK_ULONG, CK_OBJECT_HANDLE_PTR), CRYPTOKI_FN_LOG("C_GenerateKey")); } @@ -1035,7 +1144,7 @@ namespace cryptoki { @code bool generatekeypair() { //! calls @c C_GenerateKeyPair - return check(_init->_fn->C_GenerateKeyPair(_session, CK_MECHANISM_PTR, CK_ATTRIBUTE_PTR, + return check(_session._slot._init->_fn->C_GenerateKeyPair(_session, CK_MECHANISM_PTR, CK_ATTRIBUTE_PTR, CK_ULONG, CK_ATTRIBUTE_PTR, CK_ULONG, CK_OBJECT_HANDLE_PTR, CK_OBJECT_HANDLE_PTR), CRYPTOKI_FN_LOG("C_GenerateKeyPair")); @@ -1046,7 +1155,7 @@ namespace cryptoki { @code bool getattributevalue() { //! calls @c C_GetAttributeValue - return check(_init->_fn->C_GetAttributeValue(_session, CK_OBJECT_HANDLE, + return check(_session._slot._init->_fn->C_GetAttributeValue(_session, CK_OBJECT_HANDLE, CK_ATTRIBUTE_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_GetAttributeValue")); } @@ -1056,7 +1165,7 @@ namespace cryptoki { @code bool getobjectsize() { //! calls @c C_GetObjectSize - return check(_init->_fn->C_GetObjectSize(_session, CK_OBJECT_HANDLE, CK_ULONG_PTR), + return check(_session._slot._init->_fn->C_GetObjectSize(_session, CK_OBJECT_HANDLE, CK_ULONG_PTR), CRYPTOKI_FN_LOG("C_GetObjectSize")); } @endcode */ @@ -1066,7 +1175,7 @@ namespace cryptoki { @code bool setattributevalue() { //! calls @c C_SetAttributeValue - return check(_init->_fn->C_SetAttributeValue(_session, CK_OBJECT_HANDLE, + return check(_session._slot._init->_fn->C_SetAttributeValue(_session, CK_OBJECT_HANDLE, CK_ATTRIBUTE_PTR, CK_ULONG), CRYPTOKI_FN_LOG("C_SetAttributeValue")); } @@ -1076,7 +1185,7 @@ namespace cryptoki { @code bool setoperationstate() { //! calls @c C_SetOperationState - return check(_init->_fn->C_SetOperationState(_session, CK_BYTE_PTR, CK_ULONG, + return check(_session._slot._init->_fn->C_SetOperationState(_session, CK_BYTE_PTR, CK_ULONG, CK_OBJECT_HANDLE, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_SetOperationState")); } @@ -1086,7 +1195,7 @@ namespace cryptoki { @code bool signinit() { //! calls @c C_SignInit - return check(_init->_fn->C_SignInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_SignInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_SignInit")); } @endcode */ @@ -1096,7 +1205,7 @@ namespace cryptoki { @code bool signrecoverinit() { //! calls @c C_SignRecoverInit - return check(_init->_fn->C_SignRecoverInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_SignRecoverInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_SignRecoverInit")); } @endcode */ @@ -1105,7 +1214,7 @@ namespace cryptoki { @code bool unwrapkey() { //! calls @c C_UnwrapKey - return check(_init->_fn->C_UnwrapKey(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE, + return check(_session._slot._init->_fn->C_UnwrapKey(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE, CK_BYTE_PTR, CK_ULONG, CK_ATTRIBUTE_PTR, CK_ULONG, CK_OBJECT_HANDLE_PTR), CRYPTOKI_FN_LOG("C_UnwrapKey")); @@ -1116,7 +1225,7 @@ namespace cryptoki { @code bool verifyinit() { //! calls @c C_VerifyInit - return check(_init->_fn->C_VerifyInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_VerifyInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_VerifyInit")); } @endcode */ @@ -1126,7 +1235,7 @@ namespace cryptoki { @code bool verifyrecoverinit() { //! calls @c C_VerifyRecoverInit - return check(_init->_fn->C_VerifyRecoverInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), + return check(_session._slot._init->_fn->C_VerifyRecoverInit(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE), CRYPTOKI_FN_LOG("C_VerifyRecoverInit")); } @endcode */ @@ -1136,7 +1245,7 @@ namespace cryptoki { @code bool wrapkey() { //! calls @c C_WrapKey - return check(_init->_fn->C_WrapKey(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE, + return check(_session._slot._init->_fn->C_WrapKey(_session, CK_MECHANISM_PTR, CK_OBJECT_HANDLE, CK_OBJECT_HANDLE, CK_BYTE_PTR, CK_ULONG_PTR), CRYPTOKI_FN_LOG("C_WrapKey")); } @@ -1151,4 +1260,3 @@ namespace cryptoki { #endif } -#endif diff --git a/src/makefile.am b/src/makefile.am index d6305ee..b6d2a11 100644 --- a/src/makefile.am +++ b/src/makefile.am @@ -7,6 +7,10 @@ include_HEADERS = pcsc.hxx cryptoki.hxx +lib_LTLIBRARIES = libcryptoki++.la + +libcryptoki___la_SOURCES = cryptoki.cxx cryptoki.hxx + if BUILD_WIN else endif