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 | List of all members
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. More...
Module & | module () const
| ObjectFinder (Session &session, const std::vector< Attribute > &search_template)
| ObjectFinder (const ObjectFinder &other)=default
| ObjectFinder (ObjectFinder &&other)=default
ObjectFinder & | operator= (const ObjectFinder &other)=default
ObjectFinder & | operator= (ObjectFinder &&other)=default
| ~ObjectFinder () BOTAN_NOEXCEPT
| Terminates a search for token and session objects (calls C_FindObjectsFinal) More...

## Detailed Description

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

Definition at line 131 of file p11_object.h.

## Constructor & Destructor Documentation

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

  session | the session to use for the search
  search_template | the search_template as a vector of `Attribute`

Definition at line 86 of file p11_object.cpp.

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

87 : m_session(session), m_search_terminated(false)
88 {
89 module()->C_FindObjectsInit(m_session.get().handle(), const_cast< Attribute* >(search_template.data()),
90 search_template.size());
91 }
Botan::PKCS11::ObjectFinder::module
Module & module() const
Definition: p11_object.h:165
Botan::PKCS11::LowLevel::C_FindObjectsInit
bool C_FindObjectsInit(SessionHandle session, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:359
Botan::PKCS11::Attribute
CK_ATTRIBUTE Attribute
Definition: p11.h:845

Botan::PKCS11::ObjectFinder::ObjectFinder | ( | const ObjectFinder & | other | ) |
| default

Botan::PKCS11::ObjectFinder::ObjectFinder | ( | ObjectFinder && | other | ) |
| default

Botan::PKCS11::ObjectFinder::~ObjectFinder | ( |  | ) |

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

Definition at line 93 of file p11_object.cpp.

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

94 {
95 try
96 {
97 if(m_search_terminated == false)
98 {
99 module()->C_FindObjectsFinal(m_session.get().handle(), nullptr);
100 }
101 }
102 catch(...)
103 {
104 // ignore error during noexcept function
105 }
106 }
Botan::PKCS11::ObjectFinder::module
Module & module() const
Definition: p11_object.h:165
Botan::PKCS11::LowLevel::C_FindObjectsFinal
bool C_FindObjectsFinal(SessionHandle session, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:377

## Member Function Documentation

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_count | maximum amount of object handles to retrieve. Default = 100

Returns
  the result of the search as a vector of `ObjectHandle`

Definition at line 108 of file p11_object.cpp.

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

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

109 {
110 std::vector<ObjectHandle> result(max_count);
111 Ulong objectCount = 0;
112 module()->C_FindObjects(m_session.get().handle(), result.data(), max_count, &objectCount);
113 if(objectCount < max_count)
114 {
115 result.resize(objectCount);
116 }
117 return result;
118 }
Botan::PKCS11::ObjectFinder::module
Module & module() const
Definition: p11_object.h:165
Botan::PKCS11::Ulong
CK_ULONG Ulong
Definition: p11.h:836
Botan::PKCS11::LowLevel::C_FindObjects
bool C_FindObjects(SessionHandle session, ObjectHandle *object_ptr, Ulong max_object_count, Ulong *object_count_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:367

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

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

Definition at line 120 of file p11_object.cpp.

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

121 {
122 module()->C_FindObjectsFinal(m_session.get().handle());
123 m_search_terminated = true;
124 }
Botan::PKCS11::ObjectFinder::module
Module & module() const
Definition: p11_object.h:165
Botan::PKCS11::LowLevel::C_FindObjectsFinal
bool C_FindObjectsFinal(SessionHandle session, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:377

Module& Botan::PKCS11::ObjectFinder::module | ( |  | ) | const
| inline

Returns
  the module this `ObjectFinder` belongs to

Definition at line 165 of file p11_object.h.

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

166 {
167 return m_session.get().module();
168 }

ObjectFinder& Botan::PKCS11::ObjectFinder::operator= | ( | const ObjectFinder & | other | ) |
| default

ObjectFinder& Botan::PKCS11::ObjectFinder::operator= | ( | ObjectFinder && | other | ) |
| default

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