Botan 3.14.1
Crypto and TLS for C&
Botan::PKCS11::ObjectFinder Class Referencefinal

Manages calls to C_FindObjects* functions (C_FindObjectsInit -> C_FindObjects -> C_FindObjectsFinal). More...

#include <p11_object.h>

Public Member Functions

std::vector< ObjectHandle > find (std::uint32_t max_count=100) const
void finish ()
 Finishes the search operation manually to allow a new ObjectFinder to exist.
Module & module () const
 ObjectFinder (const ObjectFinder &other)=delete
 ObjectFinder (ObjectFinder &&other) noexcept
 ObjectFinder (Session &session, const std::vector< Attribute > &search_template)
ObjectFinder & operator= (const ObjectFinder &other)=delete
ObjectFinder & operator= (ObjectFinder &&other)=delete
 ~ObjectFinder () noexcept
 Terminates a search for token and session objects (calls C_FindObjectsFinal).

Detailed Description

Manages calls to C_FindObjects* functions (C_FindObjectsInit -> C_FindObjects -> C_FindObjectsFinal).

Definition at line 120 of file p11_object.h.

Constructor & Destructor Documentation

◆ ObjectFinder() [1/3]

Botan::PKCS11::ObjectFinder::ObjectFinder ( Session & session,
const std::vector< Attribute > & search_template )

Initializes a search for token and session objects that match a template (calls C_FindObjectsInit)

Parameters
sessionthe session to use for the search
search_templatethe search_template as a vector of Attribute

Definition at line 75 of file p11_object.cpp.

75 :
76 m_session(session), m_search_terminated(false) {
77 module()->C_FindObjectsInit(m_session.get().handle(),
78 const_cast<Attribute*>(search_template.data()),
79 checked_ulong_cast(search_template.size()));
80}
bool C_FindObjectsInit(SessionHandle session, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:406
Module & module() const
Definition p11_object.h:153
Ulong checked_ulong_cast(size_t v)
Definition p11.h:1228
CK_ATTRIBUTE Attribute
Definition p11.h:1213

References Botan::PKCS11::LowLevel::C_FindObjectsInit(), Botan::PKCS11::checked_ulong_cast(), and module().

Referenced by ObjectFinder(), ObjectFinder(), operator=(), and operator=().

◆ ObjectFinder() [2/3]

Botan::PKCS11::ObjectFinder::ObjectFinder ( const ObjectFinder & other)
delete

References ObjectFinder().

◆ ObjectFinder() [3/3]

Botan::PKCS11::ObjectFinder::ObjectFinder ( ObjectFinder && other)
inlinenoexcept

Definition at line 132 of file p11_object.h.

132 :
133 m_session(other.m_session), m_search_terminated(other.m_search_terminated) {
134 other.m_search_terminated = true;
135 }

References ObjectFinder().

◆ ~ObjectFinder()

Botan::PKCS11::ObjectFinder::~ObjectFinder ( )
noexcept

Terminates a search for token and session objects (calls C_FindObjectsFinal).

Definition at line 82 of file p11_object.cpp.

82 {
83 try {
84 if(!m_search_terminated) {
85 module()->C_FindObjectsFinal(m_session.get().handle(), nullptr);
86 }
87 } catch(...) {
88 // ignore error during noexcept function
89 }
90}
bool C_FindObjectsFinal(SessionHandle session, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:424

References Botan::PKCS11::LowLevel::C_FindObjectsFinal(), and module().

Member Function Documentation

◆ find()

std::vector< ObjectHandle > Botan::PKCS11::ObjectFinder::find ( std::uint32_t max_count = 100) const

Starts or continues a search for token and session objects that match a template, obtaining additional object handles (calls C_FindObjects)

Parameters
max_countmaximum amount of object handles to retrieve. Default = 100
Returns
the result of the search as a vector of ObjectHandle

Definition at line 92 of file p11_object.cpp.

92 {
93 std::vector<ObjectHandle> result(max_count);
94 Ulong objectCount = 0;
95 module()->C_FindObjects(m_session.get().handle(), result.data(), max_count, &objectCount);
96 if(objectCount < max_count) {
97 result.resize(objectCount);
98 }
99 return result;
100}
bool C_FindObjects(SessionHandle session, ObjectHandle *object_ptr, Ulong max_object_count, Ulong *object_count_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:414
CK_ULONG Ulong
Definition p11.h:1204

References Botan::PKCS11::LowLevel::C_FindObjects(), and module().

Referenced by operator=(), and Botan::PKCS11::Object::search().

◆ finish()

void Botan::PKCS11::ObjectFinder::finish ( )

Finishes the search operation manually to allow a new ObjectFinder to exist.

Definition at line 102 of file p11_object.cpp.

102 {
103 module()->C_FindObjectsFinal(m_session.get().handle());
104 m_search_terminated = true;
105}

References Botan::PKCS11::LowLevel::C_FindObjectsFinal(), and module().

Referenced by operator=().

◆ module()

Module & Botan::PKCS11::ObjectFinder::module ( ) const
inline
Returns
the module this ObjectFinder belongs to

Definition at line 153 of file p11_object.h.

153{ return m_session.get().module(); }

References module().

Referenced by find(), finish(), module(), ObjectFinder(), and ~ObjectFinder().

◆ operator=() [1/2]

ObjectFinder & Botan::PKCS11::ObjectFinder::operator= ( const ObjectFinder & other)
delete

References ObjectFinder().

◆ operator=() [2/2]

ObjectFinder & Botan::PKCS11::ObjectFinder::operator= ( ObjectFinder && other)
delete

References find(), finish(), and ObjectFinder().


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