Botan 3.2.0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::PKCS11::SecretKeyProperties Class Referencefinal

Common attributes of all secret (symmetric) keys. More...

#include <p11_object.h>

Inheritance diagram for Botan::PKCS11::SecretKeyProperties:
Botan::PKCS11::KeyProperties 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)
 
void add_string (AttributeType attribute, std::string_view value)
 
const std::vector< Attribute > & attributes () const
 
size_t count () const
 
Attributedata () const
 
KeyType key_type () const
 
ObjectClass object_class () const
 
 SecretKeyProperties (KeyType key_type)
 
void set_allowed_mechanisms (const std::vector< MechanismType > &)
 
void set_always_authenticate (bool value)
 
void set_check_value (const std::vector< uint8_t > &checksum)
 
void set_copyable (bool value)
 
void set_decrypt (bool value)
 
void set_derive (bool value)
 
void set_destroyable (bool value)
 
void set_encrypt (bool value)
 
void set_end_date (Date date)
 
void set_extractable (bool value)
 
void set_id (const std::vector< uint8_t > &id)
 
void set_label (std::string_view label)
 
void set_modifiable (bool value)
 
void set_private (bool value)
 
void set_sensitive (bool value)
 
void set_sign (bool value)
 
void set_start_date (Date date)
 
void set_token (bool value)
 
void set_trusted (bool value)
 
void set_unwrap (bool value)
 
void set_unwrap_template (const AttributeContainer &)
 
void set_verify (bool value)
 
void set_wrap (bool value)
 
void set_wrap_template (const AttributeContainer &)
 
void set_wrap_with_trusted (bool value)
 

Detailed Description

Common attributes of all secret (symmetric) keys.

Definition at line 386 of file p11_object.h.

Constructor & Destructor Documentation

◆ SecretKeyProperties()

Botan::PKCS11::SecretKeyProperties::SecretKeyProperties ( KeyType  key_type)
Parameters
key_typetype of key

Definition at line 139 of file p11_object.cpp.

KeyProperties(ObjectClass object_class, KeyType key_type)

Member Function Documentation

◆ 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}
CK_ULONG Ulong
Definition p11.h:814

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}
CK_BBOOL Bbool
Definition p11.h:812
const Bbool True
Definition p11.h:833
const Bbool False
Definition p11.h:834

References 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));
20 add_attribute(
21 AttributeType::Class, reinterpret_cast<uint8_t*>(&m_numerics.back()), static_cast<Ulong>(sizeof(ObjectClass)));
22}

References Botan::PKCS11::Class.

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

◆ 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));
26 add_attribute(
27 attribute, reinterpret_cast<const uint8_t*>(m_strings.back().data()), static_cast<Ulong>(value.size()));
28}

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().

◆ 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()); }
CK_ATTRIBUTE Attribute
Definition p11.h:823

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

◆ key_type()

KeyType Botan::PKCS11::KeyProperties::key_type ( ) const
inlineinherited
Returns
the key type of this key object

Definition at line 287 of file p11_object.h.

287{ return m_key_type; }

◆ object_class()

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

Definition at line 158 of file p11_object.h.

158{ return m_object_class; }

◆ set_allowed_mechanisms()

void Botan::PKCS11::KeyProperties::set_allowed_mechanisms ( const std::vector< MechanismType > &  )
inlineinherited

Sets a list of mechanisms allowed to be used with this key Not implemented

Definition at line 282 of file p11_object.h.

282 {
283 throw Not_Implemented("KeyProperties::set_allowed_mechanisms");
284 }

◆ set_always_authenticate()

void Botan::PKCS11::SecretKeyProperties::set_always_authenticate ( bool  value)
inline
Parameters
valueif true, the user has to supply the PIN for each use (sign or decrypt) with the key

Definition at line 416 of file p11_object.h.

void add_bool(AttributeType attribute, bool value)

◆ set_check_value()

void Botan::PKCS11::SecretKeyProperties::set_check_value ( const std::vector< uint8_t > &  checksum)
inline
Parameters
checksumthe key check value of this key

Definition at line 428 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 186 of file p11_object.h.

◆ set_decrypt()

void Botan::PKCS11::SecretKeyProperties::set_decrypt ( bool  value)
inline
Parameters
valuetrue if the key supports decryption

Definition at line 398 of file p11_object.h.

◆ set_derive()

void Botan::PKCS11::KeyProperties::set_derive ( bool  value)
inlineinherited
Parameters
valuetrue if key supports key derivation (i.e., if other keys can be derived from this one)

Definition at line 276 of file p11_object.h.

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

◆ set_encrypt()

void Botan::PKCS11::SecretKeyProperties::set_encrypt ( bool  value)
inline
Parameters
valuetrue if the key supports encryption

Definition at line 395 of file p11_object.h.

◆ set_end_date()

void Botan::PKCS11::KeyProperties::set_end_date ( Date  date)
inlineinherited
Parameters
dateend date for the key

Definition at line 271 of file p11_object.h.

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

◆ set_extractable()

void Botan::PKCS11::SecretKeyProperties::set_extractable ( bool  value)
inline
Parameters
valuetrue if the key is extractable and can be wrapped

Definition at line 410 of file p11_object.h.

◆ set_id()

void Botan::PKCS11::KeyProperties::set_id ( const std::vector< uint8_t > &  id)
inlineinherited
Parameters
idkey identifier for key

Definition at line 263 of file p11_object.h.

◆ set_label()

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

Definition at line 171 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 183 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 180 of file p11_object.h.

◆ set_sensitive()

void Botan::PKCS11::SecretKeyProperties::set_sensitive ( bool  value)
inline
Parameters
valuetrue if the key is sensitive

Definition at line 392 of file p11_object.h.

◆ set_sign()

void Botan::PKCS11::SecretKeyProperties::set_sign ( bool  value)
inline
Parameters
valuetrue if the key supports signatures where the signature is an appendix to the data

Definition at line 401 of file p11_object.h.

◆ set_start_date()

void Botan::PKCS11::KeyProperties::set_start_date ( Date  date)
inlineinherited
Parameters
datestart date for the key

Definition at line 266 of file p11_object.h.

266 {
267 add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
268 }

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

◆ set_trusted()

void Botan::PKCS11::SecretKeyProperties::set_trusted ( bool  value)
inline
Parameters
valuethe key can be trusted for the application that it was created. The wrapping key can be used to wrap keys with CKA_WRAP_WITH_TRUSTED set to CK_TRUE

Definition at line 425 of file p11_object.h.

◆ set_unwrap()

void Botan::PKCS11::SecretKeyProperties::set_unwrap ( bool  value)
inline
Parameters
valuetrue if the key supports unwrapping (i.e., can be used to unwrap other keys)

Definition at line 407 of file p11_object.h.

◆ set_unwrap_template()

void Botan::PKCS11::SecretKeyProperties::set_unwrap_template ( const AttributeContainer )
inline

For wrapping keys The attribute template to apply to any keys unwrapped using this wrapping key Any user supplied template is applied after this template as if the object has already been created Not Implemented

Definition at line 448 of file p11_object.h.

448 {
449 throw Not_Implemented("SecretKeyProperties::set_unwrap_template");
450 }

◆ set_verify()

void Botan::PKCS11::SecretKeyProperties::set_verify ( bool  value)
inline
Parameters
valuetrue if the key supports verification where the signature is an appendix to the data

Definition at line 404 of file p11_object.h.

◆ set_wrap()

void Botan::PKCS11::SecretKeyProperties::set_wrap ( bool  value)
inline
Parameters
valuetrue if the key supports wrapping (i.e., can be used to wrap other keys)

Definition at line 419 of file p11_object.h.

◆ set_wrap_template()

void Botan::PKCS11::SecretKeyProperties::set_wrap_template ( const AttributeContainer )
inline

For wrapping keys The attribute template to match against any keys wrapped using this wrapping key. Keys that do not match cannot be wrapped Not implemented

Definition at line 438 of file p11_object.h.

438 {
439 throw Not_Implemented("SecretKeyProperties::set_wrap_template");
440 }

◆ set_wrap_with_trusted()

void Botan::PKCS11::SecretKeyProperties::set_wrap_with_trusted ( bool  value)
inline
Parameters
valuetrue if the key can only be wrapped with a wrapping key that has CKA_TRUSTED set to CK_TRUE

Definition at line 413 of file p11_object.h.


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