Botan 3.14.1
Crypto and TLS for C&
p11_x509.cpp
Go to the documentation of this file.
1/*
2* PKCS#11 X.509
3* (C) 2016 Daniel Neus, Sirrix AG
4* (C) 2016 Philipp Weber, Sirrix AG
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/p11_x509.h>
10
11#if defined(BOTAN_HAS_X509_CERTIFICATES)
12
13 #include <botan/assert.h>
14
15namespace Botan::PKCS11 {
16
17namespace {
18
19// Parse before creating the token object, so invalid input leaves nothing behind
20const X509_CertificateProperties& check_certificate(const X509_CertificateProperties& props) {
21 const X509_Certificate cert(props.value());
22 BOTAN_UNUSED(cert);
23 return props; // NOLINT(*-return-const-ref-from-parameter)
24}
25
26} // namespace
27
28const X509_Certificate& PKCS11_X509_Certificate::certificate() const {
29 // TODO(Botan4) this should instead return a ref to a member variable
30 return (*this);
31}
32
33X509_CertificateProperties::X509_CertificateProperties(const std::vector<uint8_t>& subject,
34 const std::vector<uint8_t>& value) :
35 CertificateProperties(CertificateType::X509), m_subject(subject), m_value(value) {
36 add_binary(AttributeType::Subject, m_subject);
37 add_binary(AttributeType::Value, m_value);
38}
39
40PKCS11_X509_Certificate::PKCS11_X509_Certificate(Session& session, ObjectHandle handle) :
41 Object(session, handle), X509_Certificate(unlock(get_attribute_value(AttributeType::Value))) {}
42
43PKCS11_X509_Certificate::PKCS11_X509_Certificate(Session& session, const X509_CertificateProperties& props) :
44 Object(session, check_certificate(props)), X509_Certificate(props.value()) {}
45
46} // namespace Botan::PKCS11
47
48#endif
#define BOTAN_UNUSED
Definition assert.h:151
Common attributes of all certificate objects.
Definition p11_object.h:219
AttributeType
Definition p11.h:50
CertificateType
Definition p11.h:213
std::vector< T > unlock(const secure_vector< T > &in)
Definition secmem.h:155