Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | Protected Member Functions | List of all members
Botan::PKCS11::CertificateProperties Class Reference

Common attributes of all certificate objects. More...

#include <p11_object.h>

Inheritance diagram for Botan::PKCS11::CertificateProperties:
Botan::PKCS11::StorageObjectProperties Botan::PKCS11::ObjectProperties Botan::PKCS11::AttributeContainer

Public Member Functions

template<typename TAlloc >
void add_binary (AttributeType attribute, const std::vector< uint8_t, TAlloc > &binary)
 
void add_binary (AttributeType attribute, const uint8_t *value, size_t length)
 
void add_bool (AttributeType attribute, bool value)
 
void add_class (ObjectClass object_class)
 
template<typename T >
requires std::is_integral<T>::value
void add_numeric (AttributeType attribute, T value)
 
void add_string (AttributeType attribute, std::string_view value)
 
const std::vector< Attribute > & attributes () const
 
CertificateType cert_type () const
 
 CertificateProperties (CertificateType cert_type)
 
size_t count () const
 
Attributedata () const
 
ObjectClass object_class () const
 
void set_category (CertificateCategory category)
 
void set_check_value (const std::vector< uint8_t > &checksum)
 
void set_copyable (bool value)
 
void set_destroyable (bool value)
 
void set_end_date (Date date)
 
void set_label (std::string_view label)
 
void set_modifiable (bool value)
 
void set_private (bool value)
 
void set_public_key_info (const std::vector< uint8_t > &pubkey_info)
 
void set_start_date (Date date)
 
void set_token (bool value)
 
void set_trusted (bool value)
 

Protected Member Functions

void add_attribute (AttributeType attribute, const uint8_t *value, Ulong size)
 Add an attribute with the given value and size to the attribute collection m_attributes
 

Detailed Description

Common attributes of all certificate objects.

Definition at line 209 of file p11_object.h.

Constructor & Destructor Documentation

◆ CertificateProperties()

Botan::PKCS11::CertificateProperties::CertificateProperties ( CertificateType cert_type)
Parameters
cert_typetype of certificate

Definition at line 117 of file p11_object.cpp.

117 :
120}
void add_numeric(AttributeType attribute, T value)
Definition p11_object.h:97
CertificateType cert_type() const
Definition p11_object.h:246
StorageObjectProperties(ObjectClass object_class)
CK_ULONG CK_CERTIFICATE_TYPE
Definition pkcs11t.h:393

References Botan::PKCS11::AttributeContainer::add_numeric(), and Botan::PKCS11::CertificateType.

Member Function Documentation

◆ add_attribute()

void Botan::PKCS11::AttributeContainer::add_attribute ( AttributeType attribute,
const uint8_t * value,
Ulong size )
protectedinherited

Add an attribute with the given value and size to the attribute collection m_attributes

Definition at line 40 of file p11_object.cpp.

40 {
41 bool exists = false;
42 // check if the attribute has been added already
43 for(auto& existing_attribute : m_attributes) {
44 if(existing_attribute.type == static_cast<CK_ATTRIBUTE_TYPE>(attribute)) {
45 // remove old entries
46 m_strings.remove_if(
47 [&existing_attribute](std::string_view data) { return data.data() == existing_attribute.pValue; });
48
49 m_numerics.remove_if(
50 [&existing_attribute](const uint64_t& data) { return &data == existing_attribute.pValue; });
51
52 m_vectors.remove_if([&existing_attribute](const secure_vector<uint8_t>& data) {
53 return data.data() == existing_attribute.pValue;
54 });
55
56 existing_attribute.pValue = const_cast<uint8_t*>(value);
57 existing_attribute.ulValueLen = size;
58 exists = true;
59 break;
60 }
61 }
62
63 if(!exists) {
64 m_attributes.push_back(Attribute{static_cast<CK_ATTRIBUTE_TYPE>(attribute), const_cast<uint8_t*>(value), size});
65 }
66}
CK_ATTRIBUTE Attribute
Definition p11.h:823
CK_ULONG CK_ATTRIBUTE_TYPE
Definition pkcs11t.h:416
CK_VOID_PTR pValue
Definition pkcs11t.h:566

References Botan::PKCS11::AttributeContainer::data(), and CK_ATTRIBUTE::pValue.

Referenced by Botan::PKCS11::AttributeContainer::add_binary(), Botan::PKCS11::AttributeContainer::add_bool(), Botan::PKCS11::AttributeContainer::add_class(), and Botan::PKCS11::AttributeContainer::add_string().

◆ add_binary() [1/2]

template<typename TAlloc >
void Botan::PKCS11::AttributeContainer::add_binary ( AttributeType attribute,
const std::vector< uint8_t, TAlloc > & binary )
inlineinherited

Add a binary attribute (e.g. CKA_ID / AttributeType::Id).

Parameters
attributeattribute type
binarybinary attribute value to add

Definition at line 79 of file p11_object.h.

79 {
80 add_binary(attribute, binary.data(), binary.size());
81 }
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)

◆ add_binary() [2/2]

void Botan::PKCS11::AttributeContainer::add_binary ( AttributeType attribute,
const uint8_t * value,
size_t length )
inherited

Add a binary attribute (e.g. CKA_ID / AttributeType::Id).

Parameters
attributeattribute type
valuebinary attribute value to add
lengthsize of the binary attribute value in bytes

Definition at line 30 of file p11_object.cpp.

30 {
31 m_vectors.push_back(secure_vector<uint8_t>(value, value + length));
32 add_attribute(attribute, reinterpret_cast<const uint8_t*>(m_vectors.back().data()), static_cast<Ulong>(length));
33}
void add_attribute(AttributeType attribute, const uint8_t *value, Ulong size)
Add an attribute with the given value and size to the attribute collection m_attributes
CK_ULONG Ulong
Definition p11.h:814

References Botan::PKCS11::AttributeContainer::add_attribute().

Referenced by Botan::PKCS11::Object::search(), and Botan::PKCS11::Object::search().

◆ add_bool()

void Botan::PKCS11::AttributeContainer::add_bool ( AttributeType attribute,
bool value )
inherited

Add a bool attribute (e.g. CKA_SENSITIVE / AttributeType::Sensitive).

Parameters
attributeattribute type
valueboolean value to add

Definition at line 35 of file p11_object.cpp.

35 {
36 m_numerics.push_back(value ? True : False);
37 add_attribute(attribute, reinterpret_cast<uint8_t*>(&m_numerics.back()), sizeof(Bbool));
38}
const Bbool True
Definition p11.h:833
const Bbool False
Definition p11.h:834
CK_BBOOL Bbool
Definition p11.h:812

References Botan::PKCS11::AttributeContainer::add_attribute(), Botan::PKCS11::False, and Botan::PKCS11::True.

◆ add_class()

void Botan::PKCS11::AttributeContainer::add_class ( ObjectClass object_class)
inherited

Add a class attribute (CKA_CLASS / AttributeType::Class).

Parameters
object_classclass attribute to add

Definition at line 18 of file p11_object.cpp.

18 {
19 m_numerics.emplace_back(static_cast<uint64_t>(object_class));
21 AttributeType::Class, reinterpret_cast<uint8_t*>(&m_numerics.back()), static_cast<Ulong>(sizeof(ObjectClass)));
22}

References Botan::PKCS11::AttributeContainer::add_attribute(), and Botan::PKCS11::Class.

Referenced by Botan::PKCS11::AttributeContainer::AttributeContainer().

◆ add_numeric()

template<typename T >
requires std::is_integral<T>::value
void Botan::PKCS11::AttributeContainer::add_numeric ( AttributeType attribute,
T value )
inlineinherited

Add a numeric attribute (e.g. CKA_MODULUS_BITS / AttributeType::ModulusBits).

Parameters
attributeattribute type
valuenumeric value to add

Definition at line 97 of file p11_object.h.

97 {
98 m_numerics.push_back(static_cast<uint64_t>(value));
99 add_attribute(attribute, reinterpret_cast<uint8_t*>(&m_numerics.back()), sizeof(T));
100 }
FE_25519 T
Definition ge.cpp:34

References T.

Referenced by CertificateProperties(), Botan::PKCS11::DomainParameterProperties::DomainParameterProperties(), and Botan::PKCS11::KeyProperties::KeyProperties().

◆ add_string()

void Botan::PKCS11::AttributeContainer::add_string ( AttributeType attribute,
std::string_view value )
inherited

Add a string attribute (e.g. CKA_LABEL / AttributeType::Label).

Parameters
attributeattribute type
valuestring value to add

Definition at line 24 of file p11_object.cpp.

24 {
25 m_strings.push_back(std::string(value));
27 attribute, reinterpret_cast<const uint8_t*>(m_strings.back().data()), static_cast<Ulong>(value.size()));
28}

References Botan::PKCS11::AttributeContainer::add_attribute().

Referenced by Botan::PKCS11::Object::search(), and Botan::PKCS11::Object::search().

◆ attributes()

const std::vector< Attribute > & Botan::PKCS11::AttributeContainer::attributes ( ) const
inlineinherited
Returns
the attributes this container contains

Definition at line 44 of file p11_object.h.

44{ return m_attributes; }

Referenced by Botan::PKCS11::Object::search(), Botan::PKCS11::Object::search(), and Botan::PKCS11::Object::search().

◆ cert_type()

CertificateType Botan::PKCS11::CertificateProperties::cert_type ( ) const
inline
Returns
the certificate type of this certificate object

Definition at line 246 of file p11_object.h.

246{ return m_cert_type; }

◆ count()

size_t Botan::PKCS11::AttributeContainer::count ( ) const
inlineinherited
Returns
the number of attributes in this container

Definition at line 50 of file p11_object.h.

50{ return m_attributes.size(); }

Referenced by Botan::PKCS11::Object::copy(), and Botan::PKCS11::Object::Object().

◆ data()

Attribute * Botan::PKCS11::AttributeContainer::data ( ) const
inlineinherited
Returns
raw attribute data

Definition at line 47 of file p11_object.h.

47{ return const_cast<Attribute*>(m_attributes.data()); }

Referenced by Botan::PKCS11::AttributeContainer::add_attribute(), Botan::PKCS11::Object::copy(), and Botan::PKCS11::Object::Object().

◆ object_class()

ObjectClass Botan::PKCS11::ObjectProperties::object_class ( ) const
inlineinherited
Returns
the object class of this object

Definition at line 157 of file p11_object.h.

157{ return m_object_class; }

◆ set_category()

void Botan::PKCS11::CertificateProperties::set_category ( CertificateCategory category)
inline
Parameters
categoryone of CertificateCategory

Definition at line 218 of file p11_object.h.

218 {
220 }
CK_ULONG CK_CERTIFICATE_CATEGORY
Definition pkcs11t.h:1923

◆ set_check_value()

void Botan::PKCS11::CertificateProperties::set_check_value ( const std::vector< uint8_t > & checksum)
inline
Parameters
checksumthe value of this attribute is derived from the certificate by taking the first three bytes of the SHA - 1 hash of the certificate object's CKA_VALUE attribute

Definition at line 226 of file p11_object.h.

◆ set_copyable()

void Botan::PKCS11::StorageObjectProperties::set_copyable ( bool value)
inlineinherited
Parameters
valueif true the object can be copied using C_CopyObject

Definition at line 185 of file p11_object.h.

void add_bool(AttributeType attribute, bool value)

◆ set_destroyable()

void Botan::PKCS11::StorageObjectProperties::set_destroyable ( bool value)
inlineinherited
Parameters
valueif true the object can be destroyed using C_DestroyObject

Definition at line 188 of file p11_object.h.

◆ set_end_date()

void Botan::PKCS11::CertificateProperties::set_end_date ( Date date)
inline
Parameters
dateend date for the certificate

Definition at line 236 of file p11_object.h.

236 {
237 add_binary(AttributeType::EndDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
238 }
CK_DATE Date
Definition p11.h:829

◆ set_label()

void Botan::PKCS11::StorageObjectProperties::set_label ( std::string_view label)
inlineinherited
Parameters
labeldescription of the object (RFC2279 string)

Definition at line 170 of file p11_object.h.

void add_string(AttributeType attribute, std::string_view value)

◆ set_modifiable()

void Botan::PKCS11::StorageObjectProperties::set_modifiable ( bool value)
inlineinherited
Parameters
valueif true the object can be modified, otherwise it is read-only

Definition at line 182 of file p11_object.h.

◆ set_private()

void Botan::PKCS11::StorageObjectProperties::set_private ( bool value)
inlineinherited
Parameters
valueif true the object is a private object; otherwise the object is a public object When private, a user may not access the object until the user has been authenticated to the token

Definition at line 179 of file p11_object.h.

◆ set_public_key_info()

void Botan::PKCS11::CertificateProperties::set_public_key_info ( const std::vector< uint8_t > & pubkey_info)
inline
Parameters
pubkey_infoDER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate

Definition at line 241 of file p11_object.h.

◆ set_start_date()

void Botan::PKCS11::CertificateProperties::set_start_date ( Date date)
inline
Parameters
datestart date for the certificate

Definition at line 231 of file p11_object.h.

231 {
232 add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
233 }

◆ set_token()

void Botan::PKCS11::StorageObjectProperties::set_token ( bool value)
inlineinherited
Parameters
valueif true the object is a token object; otherwise the object is a session object

Definition at line 173 of file p11_object.h.

◆ set_trusted()

void Botan::PKCS11::CertificateProperties::set_trusted ( bool value)
inline
Parameters
valuethe certificate can be trusted for the application that it was created (can only be set to true by SO user)

Definition at line 215 of file p11_object.h.


The documentation for this class was generated from the following files: