9 #include <botan/p11_object.h>
24 m_numerics.push_back(static_cast< uint64_t >(object_class));
30 m_strings.push_back(value);
31 add_attribute(attribute, reinterpret_cast< const uint8_t* >(m_strings.back().data()), value.size());
37 add_attribute(attribute, reinterpret_cast< const uint8_t* >(m_vectors.back().data()), length);
42 m_numerics.push_back(value ?
True :
False);
43 add_attribute(attribute, reinterpret_cast< uint8_t* >(&m_numerics.back()),
sizeof(
Bbool));
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(),
68 return data.data() == existing_attribute.
pValue;
71 existing_attribute.pValue =
const_cast< uint8_t*
>(value);
72 existing_attribute.ulValueLen = size;
87 : m_session(session), m_search_terminated(false)
90 search_template.size());
97 if(m_search_terminated ==
false)
110 std::vector<ObjectHandle> result(max_count);
111 Ulong objectCount = 0;
113 if(objectCount < max_count)
115 result.resize(objectCount);
123 m_search_terminated =
true;
189 : m_session(session),
m_handle(handle)
200 std::map<AttributeType, secure_vector<uint8_t>> attribute_map = { { attribute,
secure_vector<uint8_t>() } };
202 return attribute_map.at(attribute);
207 std::map<AttributeType, secure_vector<uint8_t>> attribute_map = { { attribute, value } };
221 return copied_handle;
Common attributes of all objects.
~ObjectFinder() BOTAN_NOEXCEPT
Terminates a search for token and session objects (calls C_FindObjectsFinal)
void finish()
Finishes the search operation manually to allow a new ObjectFinder to exist.
bool C_FindObjectsFinal(SessionHandle session, ReturnValue *return_value=ThrowException) const
ObjectFinder(Session &session, const std::vector< Attribute > &search_template)
AttributeContainer()=default
CK_ULONG CK_ATTRIBUTE_TYPE
Object(Session &session, ObjectHandle handle)
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
DomainParameterProperties(KeyType key_type)
std::vector< T, secure_allocator< T >> secure_vector
SecretKeyProperties(KeyType key_type)
void add_class(ObjectClass object_class)
void destroy() const
Destroys the object.
StorageObjectProperties(ObjectClass object_class)
const std::reference_wrapper< Session > m_session
void add_bool(AttributeType attribute, bool value)
CertificateProperties(CertificateType cert_type)
secure_vector< uint8_t > get_attribute_value(AttributeType attribute) const
bool C_FindObjectsInit(SessionHandle session, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
void set_attribute_value(AttributeType attribute, const secure_vector< uint8_t > &value) const
Sets the given value for the attribute (using C_SetAttributeValue)
CK_OBJECT_HANDLE ObjectHandle
bool C_FindObjects(SessionHandle session, ObjectHandle *object_ptr, Ulong max_object_count, Ulong *object_count_ptr, ReturnValue *return_value=ThrowException) const
Common attributes of all storage objects.
bool C_GetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
bool C_DestroyObject(SessionHandle session, ObjectHandle object, ReturnValue *return_value=ThrowException) const
PublicKeyProperties(KeyType key_type)
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 ...
PrivateKeyProperties(KeyType key_type)
bool C_SetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
ObjectProperties(ObjectClass object_class)
void add_numeric(AttributeType attribute, T value)
Common attributes of all key objects.
Helper class to build the Attribute / CK_ATTRIBUTE structures.
KeyProperties(ObjectClass object_class, KeyType key_type)
bool C_CopyObject(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ObjectHandle *new_object_ptr, ReturnValue *return_value=ThrowException) const
void add_string(AttributeType attribute, const std::string &value)
std::vector< ObjectHandle > find(std::uint32_t max_count=100) const
Represents a PKCS#11 session.
ObjectHandle copy(const AttributeContainer &modified_attributes) const