Botan 2.19.5 Crypto and TLS for C&

Public Member Functions | Protected Member Functions | List of all members
Botan::PKCS11::PublicKeyProperties Class Reference

Common attributes of all public key objects. More...

`#include <p11_object.h>`

Inheritance diagram for Botan::PKCS11::PublicKeyProperties:

## 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 >
void | add_numeric (AttributeType attribute, T value)
void | add_string (AttributeType attribute, const std::string &value)
const std::vector< Attribute > & | attributes () const
size_t | count () const
Attribute * | data () const
KeyType | key_type () const
ObjectClass | object_class () const
| PublicKeyProperties (KeyType key_type)
void | set_allowed_mechanisms (const std::vector< MechanismType > &)
void | set_copyable (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_id (const std::vector< uint8_t > &id)
void | set_label (const std::string &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_subject (const std::vector< uint8_t > &subject)
void | set_token (bool value)
void | set_trusted (bool value)
void | set_verify (bool value)
void | set_verify_recover (bool value)
void | set_wrap (bool value)
void | set_wrap_template (const AttributeContainer &)

## Protected Member Functions
void | add_attribute (AttributeType attribute, const uint8_t *value, uint32_t size)
| Add an attribute with the given value and size to the attribute collection `m_attributes` More...

## Detailed Description

Common attributes of all public key objects.

Definition at line 366 of file p11_object.h.

## Constructor & Destructor Documentation

## ◆ PublicKeyProperties()

Botan::PKCS11::PublicKeyProperties::PublicKeyProperties | ( | KeyType | key_type | ) |

Parameters

  key_type | type of key

Definition at line 169 of file p11_object.cpp.

170 : KeyProperties(ObjectClass::PublicKey, key_type)
171 {}
Botan::PKCS11::KeyProperties::KeyProperties
KeyProperties(ObjectClass object_class, KeyType key_type)
Definition: p11_object.cpp:161
Botan::PKCS11::KeyProperties::key_type
KeyType key_type() const
Definition: p11_object.h:356
Botan::PKCS11::ObjectClass::PublicKey
@ PublicKey

References Botan::PKCS11::PublicKey.

## Member Function Documentation

## ◆ add_attribute()

void Botan::PKCS11::AttributeContainer::add_attribute | ( | AttributeType | attribute,
|  | const uint8_t * | value,
|  | uint32_t | size
| ) |  |
| protected inherited

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

Definition at line 53 of file p11_object.cpp.

54 {
55 bool exists = false;
56 // check if the attribute has been added already
57 for(auto& existing_attribute : m_attributes)
58 {
59 if(existing_attribute.type == static_cast< CK_ATTRIBUTE_TYPE >(attribute))
60 {
61 // remove old entries
62 m_strings.remove_if([ &existing_attribute ](const std::string& data)
63 {
64 return data.data() == existing_attribute.pValue;
65 });
66
67 m_numerics.remove_if([ &existing_attribute ](const uint64_t& data)
68 {
69 return &data == existing_attribute.pValue;
70 });
71
72 m_vectors.remove_if([ &existing_attribute ](const secure_vector<uint8_t>& data)
73 {
74 return data.data() == existing_attribute.pValue;
75 });
76
77 existing_attribute.pValue = const_cast< uint8_t* >(value);
78 existing_attribute.ulValueLen = size;
79 exists = true;
80 break;
81 }
82 }
83
84 if(!exists)
85 {
86 m_attributes.push_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(attribute), const_cast< uint8_t* >(value), size });
87 }
88 }
Botan::PKCS11::AttributeContainer::data
Attribute * data() const
Definition: p11_object.h:52
Botan::PKCS11::Attribute
CK_ATTRIBUTE Attribute
Definition: p11.h:847
CK_ATTRIBUTE_TYPE
CK_ULONG CK_ATTRIBUTE_TYPE
Definition: pkcs11t.h:416
CK_ATTRIBUTE::pValue
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
| ) |  |
| inline inherited

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

Parameters

  attribute | attribute type
  binary | binary attribute value to add

Definition at line 90 of file p11_object.h.

91 {
92 add_binary(attribute, binary.data(), binary.size());
93 }
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:37

## ◆ 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

  attribute | attribute type
  value | binary attribute value to add
  length | size of the binary attribute value in bytes

Definition at line 37 of file p11_object.cpp.

38 {
39 m_vectors.push_back(secure_vector<uint8_t>(value, value + length));
40 add_attribute(attribute,
41 reinterpret_cast<const uint8_t*>(m_vectors.back().data()),
42 static_cast<uint32_t>(length));
43 }
Botan::PKCS11::AttributeContainer::add_attribute
void add_attribute(AttributeType attribute, const uint8_t *value, uint32_t size)
Add an attribute with the given value and size to the attribute collection m_attributes
Definition: p11_object.cpp:53

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

Referenced by 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

  attribute | attribute type
  value | boolean value to add

Definition at line 45 of file p11_object.cpp.

46 {
47 m_numerics.push_back(value ? True : False);
48 add_attribute(attribute,
49 reinterpret_cast<uint8_t*>(&m_numerics.back()),
50 sizeof(Bbool));
51 }
Botan::PKCS11::Bbool
CK_BBOOL Bbool
Definition: p11.h:836
Botan::PKCS11::True
const Bbool True
Definition: p11.h:857
Botan::PKCS11::False
const Bbool False
Definition: p11.h:858

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_class | class attribute to add

Definition at line 21 of file p11_object.cpp.

22 {
23 m_numerics.emplace_back(static_cast< uint64_t >(object_class));
24 add_attribute(AttributeType::Class,
25 reinterpret_cast< uint8_t* >(&m_numerics.back()),
26 static_cast<uint32_t>(sizeof(ObjectClass)));
27 }
Botan::PKCS11::AttributeType::Class
@ Class
Botan::PKCS11::ObjectClass
ObjectClass
Definition: p11.h:681

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

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

## ◆ add_numeric()

template<typename T >

void Botan::PKCS11::AttributeContainer::add_numeric | ( | AttributeType | attribute,
|  | T | value
| ) |  |
| inline inherited

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

Parameters

  attribute | attribute type
  value | numeric value to add

Definition at line 108 of file p11_object.h.

109 {
110 static_assert(std::is_integral<T>::value, "Numeric value required.");
111 m_numerics.push_back(static_cast< uint64_t >(value));
112 add_attribute(attribute, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(T));
113 }
T
fe T
Definition: ge.cpp:37

References T.

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

## ◆ add_string()

void Botan::PKCS11::AttributeContainer::add_string | ( | AttributeType | attribute,
|  | const std::string & | value
| ) |  |
| inherited

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

Parameters

  attribute | attribute type
  value | string value to add

Definition at line 29 of file p11_object.cpp.

30 {
31 m_strings.push_back(value);
32 add_attribute(attribute,
33 reinterpret_cast<const uint8_t*>(m_strings.back().data()),
34 static_cast<uint32_t>(value.size()));
35 }

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

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

## ◆ attributes()

const std::vector< Attribute > & Botan::PKCS11::AttributeContainer::attributes | ( |  | ) | const
| inline inherited

Returns
  the attributes this container contains

Definition at line 46 of file p11_object.h.

47 {
48 return m_attributes;
49 }

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

## ◆ count()

size_t Botan::PKCS11::AttributeContainer::count | ( |  | ) | const
| inline inherited

Returns
  the number of attributes in this container

Definition at line 58 of file p11_object.h.

59 {
60 return m_attributes.size();
61 }

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

## ◆ data()

Attribute * Botan::PKCS11::AttributeContainer::data | ( |  | ) | const
| inline inherited

Returns
  raw attribute data

Definition at line 52 of file p11_object.h.

53 {
54 return const_cast< Attribute* >(m_attributes.data());
55 }

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

## ◆ key_type()

KeyType Botan::PKCS11::KeyProperties::key_type | ( |  | ) | const
| inline inherited

Returns
  the key type of this key object

Definition at line 356 of file p11_object.h.

357 {
358 return m_key_type;
359 }

## ◆ object_class()

ObjectClass Botan::PKCS11::ObjectProperties::object_class | ( |  | ) | const
| inline inherited

Returns
  the object class of this object

Definition at line 175 of file p11_object.h.

176 {
177 return m_object_class;
178 }

## ◆ set_allowed_mechanisms()

void Botan::PKCS11::KeyProperties::set_allowed_mechanisms | ( | const std::vector< MechanismType > & |  | ) |
| inline inherited

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

Definition at line 350 of file p11_object.h.

351 {
352 throw Not_Implemented("KeyProperties::set_allowed_mechanisms");
353 }

## ◆ set_copyable()

void Botan::PKCS11::StorageObjectProperties::set_copyable | ( | bool | value | ) |
| inline inherited

Parameters

  value | if true the object can be copied using C_CopyObject

Definition at line 219 of file p11_object.h.

220 {
221 add_bool(AttributeType::Copyable, value);
222 }
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:45
Botan::PKCS11::AttributeType::Copyable
@ Copyable

References Botan::PKCS11::Copyable.

## ◆ set_derive()

void Botan::PKCS11::KeyProperties::set_derive | ( | bool | value | ) |
| inline inherited

Parameters

  value | true if key supports key derivation (i.e., if other keys can be derived from this one)

Definition at line 341 of file p11_object.h.

342 {
343 add_bool(AttributeType::Derive, value);
344 }
Botan::PKCS11::AttributeType::Derive
@ Derive

References Botan::PKCS11::Derive.

## ◆ set_destroyable()

void Botan::PKCS11::StorageObjectProperties::set_destroyable | ( | bool | value | ) |
| inline inherited

Parameters

  value | if true the object can be destroyed using C_DestroyObject

Definition at line 225 of file p11_object.h.

226 {
227 add_bool(AttributeType::Destroyable, value);
228 }
Botan::PKCS11::AttributeType::Destroyable
@ Destroyable

References Botan::PKCS11::Destroyable.

## ◆ set_encrypt()

void Botan::PKCS11::PublicKeyProperties::set_encrypt | ( | bool | value | ) |
| inline

Parameters

  value | true if the key supports encryption

Definition at line 379 of file p11_object.h.

380 {
381 add_bool(AttributeType::Encrypt, value);
382 }
Botan::PKCS11::AttributeType::Encrypt
@ Encrypt

References Botan::PKCS11::Encrypt.

## ◆ set_end_date()

void Botan::PKCS11::KeyProperties::set_end_date | ( | Date | date | ) |
| inline inherited

Parameters

  date | end date for the key

Definition at line 335 of file p11_object.h.

336 {
337 add_binary(AttributeType::EndDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
338 }
Botan::PKCS11::AttributeType::EndDate
@ EndDate
Botan::PKCS11::Date
CK_DATE Date
Definition: p11.h:853

References Botan::PKCS11::EndDate.

## ◆ set_id()

void Botan::PKCS11::KeyProperties::set_id | ( | const std::vector< uint8_t > & | id | ) |
| inline inherited

Parameters

  id | key identifier for key

Definition at line 323 of file p11_object.h.

324 {
325 add_binary(AttributeType::Id, id);
326 }
Botan::PKCS11::AttributeType::Id
@ Id

References Botan::PKCS11::Id.

## ◆ set_label()

void Botan::PKCS11::StorageObjectProperties::set_label | ( | const std::string & | label | ) |
| inline inherited

Parameters

  label | description of the object (RFC2279 string)

Definition at line 192 of file p11_object.h.

193 {
194 add_string(AttributeType::Label, label);
195 }
Botan::PKCS11::AttributeContainer::add_string
void add_string(AttributeType attribute, const std::string &value)
Definition: p11_object.cpp:29
Botan::PKCS11::AttributeType::Label
@ Label

References Botan::PKCS11::Label.

## ◆ set_modifiable()

void Botan::PKCS11::StorageObjectProperties::set_modifiable | ( | bool | value | ) |
| inline inherited

Parameters

  value | if true the object can be modified, otherwise it is read-only

Definition at line 213 of file p11_object.h.

214 {
215 add_bool(AttributeType::Modifiable, value);
216 }
Botan::PKCS11::AttributeType::Modifiable
@ Modifiable

References Botan::PKCS11::Modifiable.

## ◆ set_private()

void Botan::PKCS11::StorageObjectProperties::set_private | ( | bool | value | ) |
| inline inherited

Parameters

  value | if 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 207 of file p11_object.h.

208 {
209 add_bool(AttributeType::Private, value);
210 }
Botan::PKCS11::AttributeType::Private
@ Private

References Botan::PKCS11::Private.

## ◆ set_public_key_info()

void Botan::PKCS11::PublicKeyProperties::set_public_key_info | ( | const std::vector< uint8_t > & | pubkey_info | ) |
| inline

Parameters

  pubkey_info | DER-encoding of the SubjectPublicKeyInfo for this public key

Definition at line 423 of file p11_object.h.

424 {
425 add_binary(AttributeType::PublicKeyInfo, pubkey_info);
426 }
Botan::PKCS11::AttributeType::PublicKeyInfo
@ PublicKeyInfo

References Botan::PKCS11::PublicKeyInfo.

## ◆ set_start_date()

void Botan::PKCS11::KeyProperties::set_start_date | ( | Date | date | ) |
| inline inherited

Parameters

  date | start date for the key

Definition at line 329 of file p11_object.h.

330 {
331 add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
332 }
Botan::PKCS11::AttributeType::StartDate
@ StartDate

References Botan::PKCS11::StartDate.

## ◆ set_subject()

void Botan::PKCS11::PublicKeyProperties::set_subject | ( | const std::vector< uint8_t > & | subject | ) |
| inline

Parameters

  subject | DER-encoding of the key subject name

Definition at line 373 of file p11_object.h.

374 {
375 add_binary(AttributeType::Subject, subject);
376 }
Botan::PKCS11::AttributeType::Subject
@ Subject

References Botan::PKCS11::Subject.

## ◆ set_token()

void Botan::PKCS11::StorageObjectProperties::set_token | ( | bool | value | ) |
| inline inherited

Parameters

  value | if true the object is a token object; otherwise the object is a session object

Definition at line 198 of file p11_object.h.

199 {
200 add_bool(AttributeType::Token, value);
201 }
Botan::PKCS11::AttributeType::Token
@ Token

References Botan::PKCS11::Token.

## ◆ set_trusted()

void Botan::PKCS11::PublicKeyProperties::set_trusted | ( | bool | value | ) |
| inline

Parameters

  value | true if the 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 406 of file p11_object.h.

407 {
408 add_bool(AttributeType::Trusted, value);
409 }
Botan::PKCS11::AttributeType::Trusted
@ Trusted

References Botan::PKCS11::Trusted.

## ◆ set_verify()

void Botan::PKCS11::PublicKeyProperties::set_verify | ( | bool | value | ) |
| inline

Parameters

  value | true if the key supports verification where the signature is an appendix to the data

Definition at line 385 of file p11_object.h.

386 {
387 add_bool(AttributeType::Verify, value);
388 }
Botan::PKCS11::AttributeType::Verify
@ Verify

References Botan::PKCS11::Verify.

## ◆ set_verify_recover()

void Botan::PKCS11::PublicKeyProperties::set_verify_recover | ( | bool | value | ) |
| inline

Parameters

  value | true if the key supports verification where the data is recovered from the signature

Definition at line 391 of file p11_object.h.

392 {
393 add_bool(AttributeType::VerifyRecover, value);
394 }
Botan::PKCS11::AttributeType::VerifyRecover
@ VerifyRecover

References Botan::PKCS11::VerifyRecover.

## ◆ set_wrap()

void Botan::PKCS11::PublicKeyProperties::set_wrap | ( | bool | value | ) |
| inline

Parameters

  value | true if the key supports wrapping (i.e., can be used to wrap other keys)

Definition at line 397 of file p11_object.h.

398 {
399 add_bool(AttributeType::Wrap, value);
400 }
Botan::PKCS11::AttributeType::Wrap
@ Wrap

References Botan::PKCS11::Wrap.

## ◆ set_wrap_template()

void Botan::PKCS11::PublicKeyProperties::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 417 of file p11_object.h.

418 {
419 throw Not_Implemented("PublicKeyProperties::set_wrap_template");
420 }

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

- src/lib/prov/pkcs11/p11_object.h
- src/lib/prov/pkcs11/p11_object.cpp