Certificate has now label and id; refs #28

master
Marc Wäckerlin 10 years ago
parent 0f91b4163e
commit 4f4fd9a5a9
  1. 29
      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<Certificate> Certificates;
//@}
@ -248,7 +267,9 @@ namespace suisseid {
.from<CK_OBJECT_CLASS>(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 {
<<id));
for (cryptoki::ObjectList::iterator cert(certs.begin());
cert!=certs.end(); ++cert) { // return first matching cert
return cert->attribute(CKA_VALUE).value;
return Certificate(cert->attribute(CKA_VALUE).value,
cert->attribute(CKA_LABEL).value,
id);
}
}
throw no_certfound(keylabel);

Loading…
Cancel
Save