From a9b5d108709af1d09943d947c3d4943bb7db7f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Mon, 13 Jan 2014 10:41:34 +0000 Subject: [PATCH] add methods to convert slot and token info from C-structure; refs #28 --- src/cryptoki.hxx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/cryptoki.hxx b/src/cryptoki.hxx index fd6a38c..cb96d1d 100644 --- a/src/cryptoki.hxx +++ b/src/cryptoki.hxx @@ -872,13 +872,20 @@ namespace cryptoki { return res; } + //! Read Slot Information SlotInfo slotinfo() { CRYPTOLOG("log"); - SlotInfo info; CK_SLOT_INFO cInfo; //! calls @c C_GetSlotInfo if (!check(_library->C_GetSlotInfo(_slot, &cInfo), - CRYPTOKI_FN_LOG("C_GetSlotInfo"))) return info; + CRYPTOKI_FN_LOG("C_GetSlotInfo"))) + return slotinfo(cInfo); + } + + //! Convert C-Structure of Slot Information Into C++ + SlotInfo slotinfo(const CK_SLOT_INFO& cInfo) { + CRYPTOLOG("log"); + SlotInfo info; info.slotDescription = cInfo.slotDescription; info.manufacturerID = cInfo.manufacturerID; info.flags = cInfo.flags; @@ -886,14 +893,20 @@ namespace cryptoki { info.firmwareVersion = cInfo.firmwareVersion; return info; } - + + //! Read Token Information TokenInfo tokeninfo() { CRYPTOLOG("log"); - TokenInfo info; //! calls @c C_GetTokenInfo CK_TOKEN_INFO cInfo; if (!check(_library->C_GetTokenInfo(_slot, &cInfo), - CRYPTOKI_FN_LOG("C_GetTokenInfo"))) return info; + CRYPTOKI_FN_LOG("C_GetTokenInfo"))) + return tokeninfo(cInfo); + } + + //! Convert C-Structure of Token Information Into C++ + TokenInfo tokeninfo(const CK_TOKEN_INFO cInfo) { + TokenInfo info; info.label = cInfo.label; info.manufacturerID = cInfo.manufacturerID; info.model = cInfo.model;