Helper class to build the Attribute / CK_ATTRIBUTE structures.
More...
#include <p11_object.h>
|
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...
|
|
Helper class to build the Attribute / CK_ATTRIBUTE structures.
Definition at line 28 of file p11_object.h.
Botan::PKCS11::AttributeContainer::AttributeContainer |
( |
| ) |
|
|
default |
Botan::PKCS11::AttributeContainer::AttributeContainer |
( |
ObjectClass |
object_class | ) |
|
- Parameters
-
object_class | the class type of this container |
Definition at line 17 of file p11_object.cpp.
References add_class().
void add_class(ObjectClass object_class)
virtual Botan::PKCS11::AttributeContainer::~AttributeContainer |
( |
| ) |
|
|
virtualdefault |
void Botan::PKCS11::AttributeContainer::add_attribute |
( |
AttributeType |
attribute, |
|
|
const uint8_t * |
value, |
|
|
uint32_t |
size |
|
) |
| |
|
protected |
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 data(), and CK_ATTRIBUTE::pValue.
Referenced by add_binary(), add_bool(), add_class(), and add_string().
50 for(
auto& existing_attribute : m_attributes)
52 if(existing_attribute.type == static_cast< CK_ATTRIBUTE_TYPE >(attribute))
55 m_strings.erase(std::remove_if(m_strings.begin(), m_strings.end(), [ &existing_attribute ](
const std::string&
data)
57 return data.data() == existing_attribute.
pValue;
60 m_numerics.erase(std::remove_if(m_numerics.begin(), m_numerics.end(), [ &existing_attribute ](
const uint64_t&
data)
63 }), m_numerics.end());
65 m_vectors.erase(std::remove_if(m_vectors.begin(),
66 m_vectors.end(), [ &existing_attribute ](
const secure_vector<uint8_t>&
data)
68 return data.data() == existing_attribute.
pValue;
71 existing_attribute.pValue =
const_cast< uint8_t*
>(value);
72 existing_attribute.ulValueLen = size;
CK_ULONG CK_ATTRIBUTE_TYPE
void Botan::PKCS11::AttributeContainer::add_binary |
( |
AttributeType |
attribute, |
|
|
const uint8_t * |
value, |
|
|
size_t |
length |
|
) |
| |
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 add_attribute().
Referenced by Botan::PKCS11::Object::search().
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);
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 ...
template<typename TAlloc >
void Botan::PKCS11::AttributeContainer::add_binary |
( |
AttributeType |
attribute, |
|
|
const std::vector< uint8_t, TAlloc > & |
binary |
|
) |
| |
|
inline |
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.
96 add_binary(attribute, binary.data(), binary.size());
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
void Botan::PKCS11::AttributeContainer::add_bool |
( |
AttributeType |
attribute, |
|
|
bool |
value |
|
) |
| |
void Botan::PKCS11::AttributeContainer::add_class |
( |
ObjectClass |
object_class | ) |
|
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 add_attribute(), and Botan::PKCS11::Class.
Referenced by AttributeContainer().
24 m_numerics.push_back(static_cast< uint64_t >(object_class));
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 ...
template<typename T >
void Botan::PKCS11::AttributeContainer::add_numeric |
( |
AttributeType |
attribute, |
|
|
T |
value |
|
) |
| |
|
inline |
void Botan::PKCS11::AttributeContainer::add_string |
( |
AttributeType |
attribute, |
|
|
const std::string & |
value |
|
) |
| |
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 add_attribute().
Referenced by Botan::PKCS11::Object::search().
30 m_strings.push_back(value);
31 add_attribute(attribute, reinterpret_cast< const uint8_t* >(m_strings.back().data()), value.size());
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 ...
const std::vector<Attribute>& Botan::PKCS11::AttributeContainer::attributes |
( |
| ) |
const |
|
inline |
size_t Botan::PKCS11::AttributeContainer::count |
( |
| ) |
const |
|
inline |
Attribute* Botan::PKCS11::AttributeContainer::data |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: