Botan 2.19.1
Crypto and TLS for C&
p11_module.cpp
Go to the documentation of this file.
1/*
2* PKCS#11 Module
3* (C) 2016 Daniel Neus, Sirrix AG
4* (C) 2016 Philipp Weber, Sirrix AG
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/p11_types.h>
10#include <botan/dyn_load.h>
11
12namespace Botan {
13
14namespace PKCS11 {
15
16Module::Module(Module&&) = default;
17
18Module::Module(const std::string& file_path, C_InitializeArgs init_args)
19 : m_file_path(file_path)
20 {
21 if(file_path.empty())
22 throw Invalid_Argument("PKCS11 no module path specified");
23 reload(init_args);
24 }
25
27 {
28 try
29 {
30 m_low_level->C_Finalize(nullptr, nullptr);
31 }
32 catch(...)
33 {
34 // we are noexcept and must swallow any exception here
35 }
36 }
37
39 {
40 if(m_low_level)
41 {
42 m_low_level->C_Finalize(nullptr);
43 }
44
45 m_library.reset(new Dynamically_Loaded_Library(m_file_path));
46 LowLevel::C_GetFunctionList(*m_library, &m_func_list);
47 m_low_level.reset(new LowLevel(m_func_list));
48
49 m_low_level->C_Initialize(&init_args);
50 }
51
52}
53}
Provides access to all PKCS#11 functions.
Definition: p11.h:904
static bool C_GetFunctionList(Dynamically_Loaded_Library &pkcs11_module, FunctionListPtr *function_list_ptr_ptr, ReturnValue *return_value=ThrowException)
Definition: p11.cpp:103
~Module() noexcept
Calls C_Finalize()
Definition: p11_module.cpp:26
Module(const std::string &file_path, C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr })
Definition: p11_module.cpp:18
void reload(C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr })
Definition: p11_module.cpp:38
Definition: alg_id.cpp:13