3
* (C) 2016 Daniel Neus, Sirrix AG
4
* (C) 2016 Philipp Weber, Sirrix AG
6
* Botan is released under the Simplified BSD License (see license.txt)
9
#ifndef BOTAN_P11_X509_H_
10
#define BOTAN_P11_X509_H_
12
#include <botan/p11_object.h>
14
#if defined(BOTAN_HAS_X509_CERTIFICATES)
16
#include <botan/x509cert.h>
24
/// Common attributes of all PKCS#11 X509 certificates
25
class BOTAN_PUBLIC_API(2,0) X509_CertificateProperties final : public CertificateProperties
29
* @param subject DER-encoding of the certificate subject name
30
* @param value BER-encoding of the certificate
32
X509_CertificateProperties(const std::vector<uint8_t>& subject, const std::vector<uint8_t>& value);
34
/// @param id key identifier for public/private key pair
35
inline void set_id(const std::vector<uint8_t>& id)
37
add_binary(AttributeType::Id, id);
40
/// @param issuer DER-encoding of the certificate issuer name
41
inline void set_issuer(const std::vector<uint8_t>& issuer)
43
add_binary(AttributeType::Issuer, issuer);
46
/// @param serial DER-encoding of the certificate serial number
47
inline void set_serial(const std::vector<uint8_t>& serial)
49
add_binary(AttributeType::SerialNumber, serial);
52
/// @param hash hash value of the subject public key
53
inline void set_subject_pubkey_hash(const std::vector<uint8_t>& hash)
55
add_binary(AttributeType::HashOfSubjectPublicKey, hash);
58
/// @param hash hash value of the issuer public key
59
inline void set_issuer_pubkey_hash(const std::vector<uint8_t>& hash)
61
add_binary(AttributeType::HashOfIssuerPublicKey, hash);
64
/// @param alg defines the mechanism used to calculate `CKA_HASH_OF_SUBJECT_PUBLIC_KEY` and `CKA_HASH_OF_ISSUER_PUBLIC_KEY`
65
inline void set_hash_alg(MechanismType alg)
67
add_numeric(AttributeType::NameHashAlgorithm, static_cast<Ulong>(alg));
70
/// @return the subject
71
inline const std::vector<uint8_t>& subject() const
76
/// @return the BER-encoding of the certificate
77
inline const std::vector<uint8_t>& value() const
83
const std::vector<uint8_t> m_subject;
84
const std::vector<uint8_t> m_value;
87
/// Represents a PKCS#11 X509 certificate
88
class BOTAN_PUBLIC_API(2,0) PKCS11_X509_Certificate final : public Object, public X509_Certificate
91
static const ObjectClass Class = ObjectClass::Certificate;
94
* Create a PKCS11_X509_Certificate object from an existing PKCS#11 X509 cert
95
* @param session the session to use
96
* @param handle the handle of the X.509 certificate
98
PKCS11_X509_Certificate(Session& session, ObjectHandle handle);
101
* Imports a X.509 certificate
102
* @param session the session to use
103
* @param props the attributes of the X.509 certificate
105
PKCS11_X509_Certificate(Session& session, const X509_CertificateProperties& props);