|
|
@ -145,7 +145,26 @@ namespace suisseid { |
|
|
|
/*! @addtogroup suisseidtypes */ |
|
|
|
/*! @addtogroup suisseidtypes */ |
|
|
|
//@{
|
|
|
|
//@{
|
|
|
|
/// DER encoded binary certificate
|
|
|
|
/// 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
|
|
|
|
/// List of DER encoded binary certificates
|
|
|
|
typedef std::vector<Certificate> Certificates; |
|
|
|
typedef std::vector<Certificate> Certificates; |
|
|
|
//@}
|
|
|
|
//@}
|
|
|
@ -248,7 +267,9 @@ namespace suisseid { |
|
|
|
.from<CK_OBJECT_CLASS>(CKO_CERTIFICATE))); |
|
|
|
.from<CK_OBJECT_CLASS>(CKO_CERTIFICATE))); |
|
|
|
for (cryptoki::ObjectList::iterator cert(certs.begin()); |
|
|
|
for (cryptoki::ObjectList::iterator cert(certs.begin()); |
|
|
|
cert!=certs.end(); ++cert) |
|
|
|
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; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -268,7 +289,9 @@ namespace suisseid { |
|
|
|
<<id)); |
|
|
|
<<id)); |
|
|
|
for (cryptoki::ObjectList::iterator cert(certs.begin()); |
|
|
|
for (cryptoki::ObjectList::iterator cert(certs.begin()); |
|
|
|
cert!=certs.end(); ++cert) { // return first matching cert
|
|
|
|
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); |
|
|
|
throw no_certfound(keylabel); |
|
|
|