Botan 3.14.1
Crypto and TLS for C&
Botan::PKCS11::DomainParameterProperties Class Referencefinal

Common attributes of domain parameter. More...

#include <p11_object.h>

Inheritance diagram for Botan::PKCS11::DomainParameterProperties:
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<std::integral T>
void add_numeric (AttributeType attribute, T value)
void add_string (AttributeType attribute, std::string_view value)
const std::vector< Attribute > & attributes () const
size_t count () const
Attribute * data () const
BOTAN_FUTURE_EXPLICIT DomainParameterProperties (KeyType key_type)
KeyType key_type () const
ObjectClass object_class () const
void set_copyable (bool value)
void set_destroyable (bool value)
void set_label (std::string_view label)
void set_modifiable (bool value)
void set_private (bool value)
void set_token (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 domain parameter.

Definition at line 473 of file p11_object.h.

Constructor & Destructor Documentation

◆ DomainParameterProperties()

Botan::PKCS11::DomainParameterProperties::DomainParameterProperties ( KeyType key_type)
Parameters
key_typetype of key the domain parameters can be used to generate

Definition at line 148 of file p11_object.cpp.

148 :
150 add_numeric(AttributeType::KeyType, static_cast<CK_ULONG>(m_key_type));
151}
void add_numeric(AttributeType attribute, T value)
Definition p11_object.h:98
BOTAN_FUTURE_EXPLICIT StorageObjectProperties(ObjectClass object_class)
unsigned long int CK_ULONG
Definition pkcs11.h:20

References Botan::PKCS11::AttributeContainer::add_numeric(), key_type(), Botan::PKCS11::KeyType, and Botan::PKCS11::StorageObjectProperties::StorageObjectProperties().

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 44 of file p11_object.cpp.

44 {
45 bool exists = false;
46 // check if the attribute has been added already
47 for(auto& existing_attribute : m_attributes) {
48 if(existing_attribute.type == static_cast<CK_ATTRIBUTE_TYPE>(attribute)) {
49 // remove old entries
50 m_strings.remove_if(
51 [&existing_attribute](std::string_view data) { return data.data() == existing_attribute.pValue; });
52
53 m_numerics.remove_if([&existing_attribute](const Ulong& data) { return &data == existing_attribute.pValue; });
54
55 m_bools.remove_if([&existing_attribute](const Bbool& data) { return &data == existing_attribute.pValue; });
56
57 m_vectors.remove_if([&existing_attribute](const secure_vector<uint8_t>& data) {
58 return data.data() == existing_attribute.pValue;
59 });
60
61 existing_attribute.pValue = const_cast<uint8_t*>(value);
62 existing_attribute.ulValueLen = size;
63 exists = true;
64 break;
65 }
66 }
67
68 if(!exists) {
69 m_attributes.push_back(Attribute{static_cast<CK_ATTRIBUTE_TYPE>(attribute), const_cast<uint8_t*>(value), size});
70 }
71}
CK_ATTRIBUTE Attribute
Definition p11.h:1213
CK_ULONG Ulong
Definition p11.h:1204
CK_BBOOL Bbool
Definition p11.h:1202
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128
CK_ULONG CK_ATTRIBUTE_TYPE
Definition pkcs11.h:44

References data().

Referenced by add_binary(), add_bool(), and 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 80 of file p11_object.h.

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

References add_binary().

◆ 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 34 of file p11_object.cpp.

34 {
35 m_vectors.push_back(secure_vector<uint8_t>(value, value + length));
36 add_attribute(attribute, reinterpret_cast<const uint8_t*>(m_vectors.back().data()), checked_ulong_cast(length));
37}
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.
Ulong checked_ulong_cast(size_t v)
Definition p11.h:1228

References add_attribute(), and Botan::PKCS11::checked_ulong_cast().

Referenced by add_binary(), Botan::PKCS11::Object::search(), Botan::PKCS11::Object::search(), Botan::PKCS11::CertificateProperties::set_check_value(), Botan::PKCS11::SecretKeyProperties::set_check_value(), Botan::PKCS11::CertificateProperties::set_end_date(), Botan::PKCS11::KeyProperties::set_end_date(), Botan::PKCS11::KeyProperties::set_id(), Botan::PKCS11::DataObjectProperties::set_object_id(), Botan::PKCS11::CertificateProperties::set_public_key_info(), Botan::PKCS11::PrivateKeyProperties::set_public_key_info(), Botan::PKCS11::PublicKeyProperties::set_public_key_info(), Botan::PKCS11::CertificateProperties::set_start_date(), Botan::PKCS11::KeyProperties::set_start_date(), Botan::PKCS11::PrivateKeyProperties::set_subject(), Botan::PKCS11::PublicKeyProperties::set_subject(), and Botan::PKCS11::DataObjectProperties::set_value().

◆ 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 39 of file p11_object.cpp.

39 {
40 m_bools.push_back(value ? True : False);
41 add_attribute(attribute, &m_bools.back(), sizeof(Bbool));
42}
const Bbool True
Definition p11.h:1225
const Bbool False
Definition p11.h:1226

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

Referenced by Botan::PKCS11::PrivateKeyProperties::set_always_authenticate(), Botan::PKCS11::SecretKeyProperties::set_always_authenticate(), Botan::PKCS11::StorageObjectProperties::set_copyable(), Botan::PKCS11::PrivateKeyProperties::set_decrypt(), Botan::PKCS11::SecretKeyProperties::set_decrypt(), Botan::PKCS11::KeyProperties::set_derive(), Botan::PKCS11::StorageObjectProperties::set_destroyable(), Botan::PKCS11::PublicKeyProperties::set_encrypt(), Botan::PKCS11::SecretKeyProperties::set_encrypt(), Botan::PKCS11::PrivateKeyProperties::set_extractable(), Botan::PKCS11::SecretKeyProperties::set_extractable(), Botan::PKCS11::StorageObjectProperties::set_modifiable(), Botan::PKCS11::StorageObjectProperties::set_private(), Botan::PKCS11::PrivateKeyProperties::set_sensitive(), Botan::PKCS11::SecretKeyProperties::set_sensitive(), Botan::PKCS11::PrivateKeyProperties::set_sign(), Botan::PKCS11::SecretKeyProperties::set_sign(), Botan::PKCS11::PrivateKeyProperties::set_sign_recover(), Botan::PKCS11::StorageObjectProperties::set_token(), Botan::PKCS11::CertificateProperties::set_trusted(), Botan::PKCS11::PublicKeyProperties::set_trusted(), Botan::PKCS11::SecretKeyProperties::set_trusted(), Botan::PKCS11::PrivateKeyProperties::set_unwrap(), Botan::PKCS11::SecretKeyProperties::set_unwrap(), Botan::PKCS11::PublicKeyProperties::set_verify(), Botan::PKCS11::SecretKeyProperties::set_verify(), Botan::PKCS11::PublicKeyProperties::set_verify_recover(), Botan::PKCS11::PublicKeyProperties::set_wrap(), Botan::PKCS11::SecretKeyProperties::set_wrap(), Botan::PKCS11::PrivateKeyProperties::set_wrap_with_trusted(), and Botan::PKCS11::SecretKeyProperties::set_wrap_with_trusted().

◆ 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 19 of file p11_object.cpp.

19 {
20 add_ulong(AttributeType::Class, static_cast<CK_OBJECT_CLASS>(object_class));
21}
CK_ULONG CK_OBJECT_CLASS
Definition pkcs11.h:63

References Botan::PKCS11::Class.

Referenced by AttributeContainer().

◆ add_numeric()

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

Add a numeric attribute (e.g. CKA_MODULUS_BITS / AttributeType::ModulusBits). The value is always passed to the module as a CK_ULONG.

Parameters
attributeattribute type
valuenumeric value to add

Definition at line 98 of file p11_object.h.

98 {
99 if(!std::in_range<Ulong>(value)) {
100 throw Invalid_Argument("PKCS #11 numeric attribute value exceeds CK_ULONG range");
101 }
102 add_ulong(attribute, static_cast<Ulong>(value));
103 }

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

◆ 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 28 of file p11_object.cpp.

28 {
29 m_strings.push_back(std::string(value));
31 attribute, reinterpret_cast<const uint8_t*>(m_strings.back().data()), checked_ulong_cast(value.size()));
32}

References add_attribute(), and Botan::PKCS11::checked_ulong_cast().

Referenced by Botan::PKCS11::Object::search(), Botan::PKCS11::Object::search(), Botan::PKCS11::DataObjectProperties::set_application(), and Botan::PKCS11::StorageObjectProperties::set_label().

◆ attributes()

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

Definition at line 45 of file p11_object.h.

45{ return m_attributes; }

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

◆ count()

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

Definition at line 51 of file p11_object.h.

51{ 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 48 of file p11_object.h.

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

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

◆ key_type()

KeyType Botan::PKCS11::DomainParameterProperties::key_type ( ) const
inline
Returns
the key type

Definition at line 479 of file p11_object.h.

479{ return m_key_type; }

Referenced by DomainParameterProperties().

◆ object_class()

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

Definition at line 167 of file p11_object.h.

167{ return m_object_class; }

Referenced by Botan::PKCS11::KeyProperties::KeyProperties(), ObjectProperties(), and Botan::PKCS11::StorageObjectProperties::StorageObjectProperties().

◆ 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 195 of file p11_object.h.

void add_bool(AttributeType attribute, bool value)

References Botan::PKCS11::AttributeContainer::add_bool(), and Botan::PKCS11::Copyable.

◆ 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 198 of file p11_object.h.

References Botan::PKCS11::AttributeContainer::add_bool(), and Botan::PKCS11::Destroyable.

◆ set_label()

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

Definition at line 180 of file p11_object.h.

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

References Botan::PKCS11::AttributeContainer::add_string(), and Botan::PKCS11::Label.

◆ 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 192 of file p11_object.h.

References Botan::PKCS11::AttributeContainer::add_bool(), and Botan::PKCS11::Modifiable.

◆ 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 189 of file p11_object.h.

References Botan::PKCS11::AttributeContainer::add_bool(), and Botan::PKCS11::Private.

◆ 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 183 of file p11_object.h.

References Botan::PKCS11::AttributeContainer::add_bool(), and Botan::PKCS11::Token.


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