From ea6ad617c16297ca15ea061fe6b4c11fc825752f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Tue, 29 Sep 2009 07:24:04 +0000 Subject: [PATCH] destroy object --- src/cryptoki.cxx | 5 +++++ src/cryptoki.hxx | 35 +++++++++++++++++++++++------------ src/pcsc.hxx | 2 +- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/cryptoki.cxx b/src/cryptoki.cxx index 164a6fa..dbf9925 100644 --- a/src/cryptoki.cxx +++ b/src/cryptoki.cxx @@ -277,6 +277,11 @@ namespace cryptoki { for (AttributeList::size_type i(0); i())) { @@ -226,6 +233,10 @@ namespace cryptoki { value = std::string((char*)&v, sizeof(TYPE)); return *this; } + template TYPE to() const { + assert(sizeof(TYPE)==value.size()); + return *reinterpret_cast(value.begin().operator->()); + } CK_ATTRIBUTE_TYPE type; std::string value; }; @@ -833,10 +844,12 @@ namespace cryptoki { //! Opens a new session. /*! @param slot slot to open a session on */ - Session(Slot& slot): _slot(slot), _session(0), _res(CKR_OK) { + Session(Slot& slot, bool rw=false): + _slot(slot), _session(0), _res(CKR_OK) { //! calls @c C_OpenSession check(_slot._init->_fn->C_OpenSession - (_slot._slot, CKF_SERIAL_SESSION, 0, 0, &_session), + (_slot._slot, CKF_SERIAL_SESSION|(rw?CKF_RW_SESSION:0), + 0, 0, &_session), CRYPTOKI_FN_LOG("C_OpenSession")); //! @todo pass parameter } @@ -1372,14 +1385,14 @@ namespace cryptoki { } @endcode */ - bool decryptinit(CK_MECHANISM_TYPE type, std::string param, - const Object& key) { + //! Call this method on a key object only. + bool decryptinit(CK_MECHANISM_TYPE type, std::string param) { CK_MECHANISM mech = { type, param.begin().operator->(), param.size() }; //! calls @c C_DecryptInit return check(_session->_slot._init->_fn->C_DecryptInit - (_session->_session, &mech, key._object), + (_session->_session, &mech, _object), CRYPTOKI_FN_LOG("C_DecryptInit")); } @@ -1394,14 +1407,12 @@ namespace cryptoki { } @endcode */ - /*! @todo Not implemented: - @code - bool destroyobject() { + bool destroy() { //! calls @c C_DestroyObject - return check(_session->_slot._init->_fn->C_DestroyObject(_session->_session, CK_OBJECT_HANDLE), + return check(_session->_slot._init->_fn->C_DestroyObject + (_session->_session, _object), CRYPTOKI_FN_LOG("C_DestroyObject")); } - @endcode */ /*! @todo Not implemented: diff --git a/src/pcsc.hxx b/src/pcsc.hxx index e230a80..a968f3a 100644 --- a/src/pcsc.hxx +++ b/src/pcsc.hxx @@ -76,7 +76,7 @@ namespace pcsc { //============================================================================ - //! @addtogroup pcsclib + //! @addtogroup pcscexceptions //@{ //----------------------------------------------------------------------------