new creation attributes

master
Marc Wäckerlin 15 years ago
parent c197689ead
commit f962d84383
  1. 8
      src/cryptoki.cxx
  2. 3
      src/cryptoki.hxx
  3. 19
      src/openssl.hxx

@ -244,10 +244,16 @@ namespace cryptoki {
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_TOKEN).from<CK_BBOOL>(TRUE));
attrs.push_back(Attribute(CKA_PRIVATE).from<CK_BBOOL>(FALSE));
attrs.push_back(Attribute(CKA_MODIFIABLE).from<CK_BBOOL>(TRUE));
attrs.push_back(Attribute(CKA_LABEL, label));
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_ID, cert.id()));
attrs.push_back(Attribute(CKA_ISSUER, cert.issuerDER()));
attrs.push_back(Attribute(CKA_SERIAL_NUMBER, cert.serial()));
attrs.push_back(Attribute(CKA_VALUE, cert.valueDER())); attrs.push_back(Attribute(CKA_VALUE, cert.valueDER()));
return create(attrs); return create(attrs);
} }

@ -114,7 +114,8 @@ namespace cryptoki {
typedef std::vector<CK_ATTRIBUTE_TYPE> AttributeTypeList; typedef std::vector<CK_ATTRIBUTE_TYPE> AttributeTypeList;
struct Attribute { class Attribute {
public:
Attribute(CK_ATTRIBUTE_TYPE t = -1): type(t) {} Attribute(CK_ATTRIBUTE_TYPE t = -1): type(t) {}
Attribute(CK_ATTRIBUTE_TYPE t, const std::string& v): type(t), value(v) {} Attribute(CK_ATTRIBUTE_TYPE t, const std::string& v): type(t), value(v) {}
Attribute(CK_ATTRIBUTE& attr): Attribute(CK_ATTRIBUTE& attr):

@ -272,12 +272,19 @@ namespace openssl {
/* @bug http://albistechnologies.com reports: «could be a /* @bug http://albistechnologies.com reports: «could be a
failure in openSSL: len too short by 1 if serial number failure in openSSL: len too short by 1 if serial number
starts with 00 ASN1_INTEGER* ser = starts with 00 ASN1_INTEGER* ser =
X509_get_serialNumber(_x509);» */ X509_get_serialNumber(_x509);»
ASN1_INTEGER* ser(X509_get_serialNumber(_x509)); @code
//! @todo requires memory free? ASN1_INTEGER* ser(X509_get_serialNumber(_x509));
/*! @todo ser->type?!? http://albistechnologies.com prepends return std::string((char*)ser->data, ser->length);
tag and length in the first two char-fields. */ @endcode
return std::string((char*)ser->data, ser->length); - requires memory free?
- ser->type?!? http://albistechnologies.com prepends
tag and length in the first two char-fields. */
unsigned char* c(0);
int len(i2d_X509(_x509, &c));
std::string res((char*)c+15, c[14]);
OPENSSL_free(c);
return res;
} }
//! Get id. //! Get id.
std::string id() const { std::string id() const {

Loading…
Cancel
Save