From 4f4fd9a5a96e8f26c907ef54ac3ac14ca34a2532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Thu, 3 Apr 2014 14:14:18 +0000 Subject: [PATCH] Certificate has now label and id; refs #28 --- src/suisseid.hxx | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/suisseid.hxx b/src/suisseid.hxx index c8b898c..a5c3960 100644 --- a/src/suisseid.hxx +++ b/src/suisseid.hxx @@ -145,7 +145,26 @@ namespace suisseid { /*! @addtogroup suisseidtypes */ //@{ /// DER encoded binary certificate - typedef std::string Certificate; + class Certificate: public std::string { + public: + Certificate(const std::string& v, + const std::string& l, + const cryptoki::Attribute& i): + std::string(v), + _label(l), + _id(i) { + } + const std::string& label() { + return _label; + } + const cryptoki::Attribute& id() { + return _id; + } + private: + std::string _label; + cryptoki::Attribute _id; + }; + /// List of DER encoded binary certificates typedef std::vector Certificates; //@} @@ -248,7 +267,9 @@ namespace suisseid { .from(CKO_CERTIFICATE))); for (cryptoki::ObjectList::iterator cert(certs.begin()); cert!=certs.end(); ++cert) - res.push_back(cert->attribute(CKA_VALUE).value); + res.push_back(Certificate(cert->attribute(CKA_VALUE).value, + cert->attribute(CKA_LABEL).value, + cert->attribute(CKA_ID))); return res; } @@ -268,7 +289,9 @@ namespace suisseid { <attribute(CKA_VALUE).value; + return Certificate(cert->attribute(CKA_VALUE).value, + cert->attribute(CKA_LABEL).value, + id); } } throw no_certfound(keylabel);