pass label on creation

master
Marc Wäckerlin 15 years ago
parent 6732fc693b
commit c197689ead
  1. 9
      src/cryptoki.cxx
  2. 6
      src/cryptoki.hxx

@ -240,21 +240,24 @@ namespace cryptoki {
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
Object Session::create(const openssl::X509& cert) { Object Session::create(const std::string& label, const openssl::X509& cert) {
AttributeList attrs; AttributeList attrs;
attrs.push_back(Attribute(CKA_CLASS) attrs.push_back(Attribute(CKA_CLASS)
.from<CK_OBJECT_CLASS>(CKO_CERTIFICATE)); .from<CK_OBJECT_CLASS>(CKO_CERTIFICATE));
attrs.push_back(Attribute(CKA_CERTIFICATE_TYPE) attrs.push_back(Attribute(CKA_CERTIFICATE_TYPE)
.from<CK_CERTIFICATE_TYPE>(CKC_X_509)); .from<CK_CERTIFICATE_TYPE>(CKC_X_509));
attrs.push_back(Attribute(CKA_LABEL, label));
attrs.push_back(Attribute(CKA_SUBJECT, cert.subjectDER())); attrs.push_back(Attribute(CKA_SUBJECT, cert.subjectDER()));
attrs.push_back(Attribute(CKA_VALUE, cert.valueDER())); attrs.push_back(Attribute(CKA_VALUE, cert.valueDER()));
return create(attrs); return create(attrs);
} }
Object Session::create(const openssl::PrivateKey& key) { Object Session::create(const std::string& label,
const openssl::PrivateKey& key) {
AttributeList attrs; AttributeList attrs;
return create(attrs); return create(attrs);
} }
Object Session::create(const openssl::PKCS12& p12) { Object Session::create(const std::string& label,
const openssl::PKCS12& p12) {
AttributeList attrs; AttributeList attrs;
return create(attrs); return create(attrs);
} }

@ -866,11 +866,11 @@ namespace cryptoki {
ObjectList find(const AttributeList& attrs=AttributeList()); ObjectList find(const AttributeList& attrs=AttributeList());
//! Create a new Certificate Object. //! Create a new Certificate Object.
Object create(const openssl::X509& cert); Object create(const std::string& label, const openssl::X509& cert);
//! Create a new PrivateKey Object. //! Create a new PrivateKey Object.
Object create(const openssl::PrivateKey& key); Object create(const std::string& label, const openssl::PrivateKey& key);
//! Create a new Certificate and optional PrivateKey Object. //! Create a new Certificate and optional PrivateKey Object.
Object create(const openssl::PKCS12& p12); Object create(const std::string& label, const openssl::PKCS12& p12);
//@} //@}

Loading…
Cancel
Save