9 #ifndef BOTAN_P11_OBJECT_H__
10 #define BOTAN_P11_OBJECT_H__
12 #include <botan/p11.h>
13 #include <botan/p11_session.h>
14 #include <botan/secmem.h>
18 #include <type_traits>
40 #if !defined( _MSC_VER ) || ( _MSC_VER >= 1900 )
58 return const_cast< Attribute*
>(m_attributes.data());
64 return m_attributes.size();
78 void add_string(
AttributeType attribute,
const std::string& value);
86 void add_binary(
AttributeType attribute,
const uint8_t* value,
size_t length);
93 template<
typename TAlloc>
96 add_binary(attribute, binary.data(), binary.size());
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));
121 void add_attribute(
AttributeType attribute,
const uint8_t* value, uint32_t size);
124 std::vector<Attribute> m_attributes;
125 std::list<uint64_t> m_numerics;
126 std::list<std::string> m_strings;
127 std::list<secure_vector<uint8_t>> m_vectors;
146 #if !defined( _MSC_VER ) || ( _MSC_VER >= 1900 )
159 std::vector<ObjectHandle> find(std::uint32_t max_count = 100)
const;
167 return m_session.get().module();
171 const std::reference_wrapper<Session> m_session;
172 bool m_search_terminated;
185 return m_object_class;
331 inline void set_id(
const std::vector<uint8_t>&
id)
360 throw Exception(
"Not implemented (KeyProperties::set_allowed_mechanisms)");
427 throw Exception(
"Not implemented (PublicKeyProperties::set_wrap_template)");
506 throw Exception(
"Not implemented (PrivateKeyProperties::set_unwrap_template)");
606 throw Exception(
"Not implemented (SecretKeyProperties::set_wrap_template)");
617 throw Exception(
"Not implemented (SecretKeyProperties::set_unwrap_template)");
661 virtual ~
Object() =
default;
665 static std::vector<T> search(
Session& session,
const std::vector<Attribute>& search_template);
669 static std::vector<T> search(
Session& session,
const std::string& label);
673 static std::vector<T> search(
Session& session,
const std::vector<uint8_t>&
id);
677 static std::vector<T> search(
Session& session,
const std::string& label,
const std::vector<uint8_t>&
id);
681 static std::vector<T> search(
Session& session);
690 void destroy()
const;
713 return m_session.get().module();
728 std::vector<ObjectHandle> handles = finder.
find();
729 std::vector<T> result;
730 result.reserve(handles.size());
731 for(
const auto&
handle : handles)
733 result.emplace_back(T(session,
handle));
void set_unwrap_template(const AttributeContainer &)
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
Common attributes of all objects.
void set_application(const std::string &value)
void set_end_date(Date date)
void set_verify(bool value)
void set_check_value(const std::vector< uint8_t > &checksum)
void set_object_id(const std::vector< uint8_t > &object_id)
#define CK_INVALID_HANDLE
void set_sign(bool value)
void set_end_date(Date date)
Common attributes of all private keys.
void set_start_date(Date date)
void set_id(const std::vector< uint8_t > &id)
void set_unwrap_template(const AttributeContainer &)
void set_always_authenticate(bool value)
void set_copyable(bool value)
void set_wrap_template(const AttributeContainer &)
void set_wrap_template(const AttributeContainer &)
void set_modifiable(bool value)
Common attributes of all secret (symmetric) keys.
void set_token(bool value)
void set_trusted(bool value)
void set_value(const secure_vector< uint8_t > &value)
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
void set_extractable(bool value)
static std::vector< T > search(Session &session, const std::vector< Attribute > &search_template)
Searches for all objects of the given type that match search_template
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
void set_category(CertificateCategory category)
void set_unwrap(bool value)
void set_trusted(bool value)
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
void set_destroyable(bool value)
std::vector< T, secure_allocator< T >> secure_vector
void set_verify(bool value)
void set_allowed_mechanisms(const std::vector< MechanismType > &)
void set_sign(bool value)
Common attributes of domain parameter.
const std::reference_wrapper< Session > m_session
ObjectHandle handle() const
void set_encrypt(bool value)
void set_decrypt(bool value)
void set_label(const std::string &label)
Session & session() const
CK_OBJECT_HANDLE ObjectHandle
Common attributes of all storage objects.
void set_subject(const std::vector< uint8_t > &subject)
Common attributes of all public key objects.
Common attributes of all data objects.
void set_start_date(Date date)
Common attributes of all certificate objects.
void set_check_value(const std::vector< uint8_t > &checksum)
void set_sensitive(bool value)
void set_sensitive(bool value)
void add_binary(AttributeType attribute, const std::vector< uint8_t, TAlloc > &binary)
void add_numeric(AttributeType attribute, T value)
Common attributes of all key objects.
void set_extractable(bool value)
Helper class to build the Attribute / CK_ATTRIBUTE structures.
void set_wrap(bool value)
void set_sign_recover(bool value)
const std::vector< Attribute > & attributes() const
void set_wrap(bool value)
void set_trusted(bool value)
void set_subject(const std::vector< uint8_t > &subject)
void add_string(AttributeType attribute, const std::string &value)
void set_always_authenticate(bool value)
std::vector< ObjectHandle > find(std::uint32_t max_count=100) const
Represents a PKCS#11 session.
CertificateType cert_type() const
ObjectClass object_class() const
void set_decrypt(bool value)
void set_wrap_with_trusted(bool value)
void set_verify_recover(bool value)
void set_wrap_with_trusted(bool value)
void set_derive(bool value)
void set_encrypt(bool value)
void set_unwrap(bool value)
Manages calls to C_FindObjects* functions (C_FindObjectsInit -> C_FindObjects -> C_FindObjectsFinal) ...
void set_private(bool value)