Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

Common attributes of all private keys. More...

`#include <p11_object.h>`

Inheritance diagram for Botan::PKCS11::PrivateKeyProperties:

## Public Member Functions
void | add_binary (AttributeType attribute, const uint8_t *value, size_t length)
template<typename TAlloc >
void | add_binary (AttributeType attribute, const std::vector< uint8_t, TAlloc > &binary)
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
| PrivateKeyProperties (KeyType key_type)
void | set_allowed_mechanisms (const std::vector< MechanismType > &)
void | set_always_authenticate (bool value)
void | set_copyable (bool value)
void | set_decrypt (bool value)
void | set_derive (bool value)
void | set_destroyable (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 (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_sensitive (bool value)
void | set_sign (bool value)
void | set_sign_recover (bool value)
void | set_start_date (Date date)
void | set_subject (const std::vector< uint8_t > &subject)
void | set_token (bool value)
void | set_unwrap (bool value)
void | set_unwrap_template (const AttributeContainer &)
void | set_wrap_with_trusted (bool value)

## 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 private keys.

Definition at line 438 of file p11_object.h.

## Constructor & Destructor Documentation

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

Parameters

  key_type | type of key

Definition at line 168 of file p11_object.cpp.

References Botan::PKCS11::PrivateKey.

169 : KeyProperties(ObjectClass::PrivateKey, key_type)
170 {}
Botan::PKCS11::KeyProperties::key_type
KeyType key_type() const
Definition: p11_object.h:364
Botan::PKCS11::ObjectClass::PrivateKey
Botan::PKCS11::KeyProperties::KeyProperties
KeyProperties(ObjectClass object_class, KeyType key_type)
Definition: p11_object.cpp:154

## Member Function Documentation

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

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

47 {
48 bool exists = false;
49 // check if the attribute has been added already
50 for(auto& existing_attribute : m_attributes)
51 {
52 if(existing_attribute.type == static_cast< CK_ATTRIBUTE_TYPE >(attribute))
53 {
54 // remove old entries
55 m_strings.erase(std::remove_if(m_strings.begin(), m_strings.end(), [ &existing_attribute ](const std::string& data)
56 {
57 return data.data() == existing_attribute.pValue;
58 }), m_strings.end());
59
60 m_numerics.erase(std::remove_if(m_numerics.begin(), m_numerics.end(), [ &existing_attribute ](const uint64_t& data)
61 {
62 return &data == existing_attribute.pValue;
63 }), m_numerics.end());
64
65 m_vectors.erase(std::remove_if(m_vectors.begin(),
66 m_vectors.end(), [ &existing_attribute ](const secure_vector<uint8_t>& data)
67 {
68 return data.data() == existing_attribute.pValue;
69 }), m_vectors.end());
70
71 existing_attribute.pValue = const_cast< uint8_t* >(value);
72 existing_attribute.ulValueLen = size;
73 exists = true;
74 break;
75 }
76 }
77
78 if(!exists)
79 {
80 m_attributes.push_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(attribute), const_cast< uint8_t* >(value), size });
81 }
82 }
CK_ATTRIBUTE_TYPE
CK_ULONG CK_ATTRIBUTE_TYPE
Definition: pkcs11t.h:416
Botan::PKCS11::AttributeContainer::data
Attribute * data() const
Definition: p11_object.h:56
Botan::PKCS11::Attribute
CK_ATTRIBUTE Attribute
Definition: p11.h:845
CK_ATTRIBUTE::pValue
CK_VOID_PTR pValue
Definition: pkcs11t.h:566

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

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

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

35 {
36 m_vectors.push_back(secure_vector<uint8_t>(value, value + length));
37 add_attribute(attribute, reinterpret_cast< const uint8_t* >(m_vectors.back().data()), length);
38 }
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:46
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 94 of file p11_object.h.

95 {
96 add_binary(attribute, binary.data(), binary.size());
97 }
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34

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

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

41 {
42 m_numerics.push_back(value ? True : False);
43 add_attribute(attribute, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(Bbool));
44 }
Botan::PKCS11::False
const Bbool False
Definition: p11.h:856
Botan::PKCS11::True
const Bbool True
Definition: p11.h:855
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:46
Botan::PKCS11::Bbool
CK_BBOOL Bbool
Definition: p11.h:834

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

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

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

23 {
24 m_numerics.push_back(static_cast< uint64_t >(object_class));
25 add_attribute(AttributeType::Class, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(ObjectClass));
26 }
Botan::PKCS11::ObjectClass
ObjectClass
Definition: p11.h:678
Botan::PKCS11::AttributeType::Class
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:46
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 112 of file p11_object.h.

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

113 {
114 static_assert(std::is_integral<T>::value, "Numeric value required.");
115 m_numerics.push_back(static_cast< uint64_t >(value));
116 add_attribute(attribute, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(T));
117 }
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:46

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

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

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

29 {
30 m_strings.push_back(value);
31 add_attribute(attribute, reinterpret_cast< const uint8_t* >(m_strings.back().data()), value.size());
32 }
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:46

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

Returns
  the attributes this container contains

Definition at line 50 of file p11_object.h.

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

51 {
52 return m_attributes;
53 }

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

Returns
  the number of attributes in this container

Definition at line 62 of file p11_object.h.

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

63 {
64 return m_attributes.size();
65 }

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

Returns
  raw attribute data

Definition at line 56 of file p11_object.h.

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

57 {
58 return const_cast< Attribute* >(m_attributes.data());
59 }
Botan::PKCS11::Attribute
CK_ATTRIBUTE Attribute
Definition: p11.h:845

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

Returns
  the key type of this key object

Definition at line 364 of file p11_object.h.

365 {
366 return m_key_type;
367 }

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

Returns
  the object class of this object

Definition at line 183 of file p11_object.h.

184 {
185 return m_object_class;
186 }

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

359 {
360 throw Exception("Not implemented (KeyProperties::set_allowed_mechanisms)");
361 }

void Botan::PKCS11::PrivateKeyProperties::set_always_authenticate | ( | bool | value | ) |
| inline

Parameters

  value | If true, the user has to supply the PIN for each use (sign or decrypt) with the key

Definition at line 493 of file p11_object.h.

References Botan::PKCS11::AlwaysAuthenticate.

494 {
495 add_bool(AttributeType::AlwaysAuthenticate, value);
496 }
Botan::PKCS11::AttributeType::AlwaysAuthenticate
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

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

References Botan::PKCS11::Copyable.

228 {
229 add_bool(AttributeType::Copyable, value);
230 }
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40
Botan::PKCS11::AttributeType::Copyable

void Botan::PKCS11::PrivateKeyProperties::set_decrypt | ( | bool | value | ) |
| inline

Parameters

  value | true if the key supports decryption

Definition at line 457 of file p11_object.h.

References Botan::PKCS11::Decrypt.

458 {
459 add_bool(AttributeType::Decrypt, value);
460 }
Botan::PKCS11::AttributeType::Decrypt
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

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

References Botan::PKCS11::Derive.

350 {
351 add_bool(AttributeType::Derive, value);
352 }
Botan::PKCS11::AttributeType::Derive
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

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

References Botan::PKCS11::Destroyable.

234 {
235 add_bool(AttributeType::Destroyable, value);
236 }
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40
Botan::PKCS11::AttributeType::Destroyable

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

Parameters

  date | end date for the key

Definition at line 343 of file p11_object.h.

References Botan::PKCS11::EndDate.

344 {
345 add_binary(AttributeType::EndDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
346 }
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34
Botan::PKCS11::AttributeType::EndDate
Botan::PKCS11::Date
CK_DATE Date
Definition: p11.h:851

void Botan::PKCS11::PrivateKeyProperties::set_extractable | ( | bool | value | ) |
| inline

Parameters

  value | true if the key is extractable and can be wrapped

Definition at line 481 of file p11_object.h.

References Botan::PKCS11::Extractable.

482 {
483 add_bool(AttributeType::Extractable, value);
484 }
Botan::PKCS11::AttributeType::Extractable
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

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

Parameters

  id | key identifier for key

Definition at line 331 of file p11_object.h.

References Botan::PKCS11::Id.

332 {
333 add_binary(AttributeType::Id, id);
334 }
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34
Botan::PKCS11::AttributeType::Id

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

Parameters

  label | description of the object (RFC2279 string)

Definition at line 200 of file p11_object.h.

References Botan::PKCS11::Label.

201 {
202 add_string(AttributeType::Label, label);
203 }
Botan::PKCS11::AttributeType::Label
Botan::PKCS11::AttributeContainer::add_string
void add_string(AttributeType attribute, const std::string &value)
Definition: p11_object.cpp:28

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

References Botan::PKCS11::Modifiable.

222 {
223 add_bool(AttributeType::Modifiable, value);
224 }
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40
Botan::PKCS11::AttributeType::Modifiable

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

References Botan::PKCS11::Private.

216 {
217 add_bool(AttributeType::Private, value);
218 }
Botan::PKCS11::AttributeType::Private
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

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

References Botan::PKCS11::PublicKeyInfo.

511 {
512 add_binary(AttributeType::PublicKeyInfo, pubkey_info);
513 }
Botan::PKCS11::AttributeType::PublicKeyInfo
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34

void Botan::PKCS11::PrivateKeyProperties::set_sensitive | ( | bool | value | ) |
| inline

Parameters

  value | true if the key is sensitive

Definition at line 451 of file p11_object.h.

References Botan::PKCS11::Sensitive.

452 {
453 add_bool(AttributeType::Sensitive, value);
454 }
Botan::PKCS11::AttributeType::Sensitive
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

void Botan::PKCS11::PrivateKeyProperties::set_sign | ( | bool | value | ) |
| inline

Parameters

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

Definition at line 463 of file p11_object.h.

References Botan::PKCS11::Sign.

464 {
465 add_bool(AttributeType::Sign, value);
466 }
Botan::PKCS11::AttributeType::Sign
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

void Botan::PKCS11::PrivateKeyProperties::set_sign_recover | ( | bool | value | ) |
| inline

Parameters

  value | true if the key supports signatures where the data can be recovered from the signature

Definition at line 469 of file p11_object.h.

References Botan::PKCS11::SignRecover.

470 {
471 add_bool(AttributeType::SignRecover, value);
472 }
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40
Botan::PKCS11::AttributeType::SignRecover

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

Parameters

  date | start date for the key

Definition at line 337 of file p11_object.h.

References Botan::PKCS11::StartDate.

338 {
339 add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
340 }
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34
Botan::PKCS11::Date
CK_DATE Date
Definition: p11.h:851
Botan::PKCS11::AttributeType::StartDate

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

Parameters

  subject | DER-encoding of the key subject name

Definition at line 445 of file p11_object.h.

References Botan::PKCS11::Subject.

446 {
447 add_binary(AttributeType::Subject, subject);
448 }
Botan::PKCS11::AttributeType::Subject
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34

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

References Botan::PKCS11::Token.

207 {
208 add_bool(AttributeType::Token, value);
209 }
Botan::PKCS11::AttributeType::Token
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

void Botan::PKCS11::PrivateKeyProperties::set_unwrap | ( | bool | value | ) |
| inline

Parameters

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

Definition at line 475 of file p11_object.h.

References Botan::PKCS11::Unwrap.

476 {
477 add_bool(AttributeType::Unwrap, value);
478 }
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40
Botan::PKCS11::AttributeType::Unwrap

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

505 {
506 throw Exception("Not implemented (PrivateKeyProperties::set_unwrap_template)");
507 }

void Botan::PKCS11::PrivateKeyProperties::set_wrap_with_trusted | ( | bool | value | ) |
| inline

Parameters

  value | true if the key can only be wrapped with a wrapping key that has `CKA_TRUSTED` set to `CK_TRUE`

Definition at line 487 of file p11_object.h.

References Botan::PKCS11::WrapWithTrusted.

488 {
489 add_bool(AttributeType::WrapWithTrusted, value);
490 }
Botan::PKCS11::AttributeType::WrapWithTrusted
Botan::PKCS11::AttributeContainer::add_bool
void add_bool(AttributeType attribute, bool value)
Definition: p11_object.cpp:40

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