Botan  2.4.0
Crypto and TLS for C++11
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_module.h>
10 
11 namespace Botan {
12 
13 namespace PKCS11 {
14 
15 Module::Module(const std::string& file_path, C_InitializeArgs init_args)
16  : m_file_path(file_path)
17  {
18  reload(init_args);
19  }
20 
22  {
23  try
24  {
25  m_low_level->C_Finalize(nullptr, nullptr);
26  }
27  catch(...)
28  {
29  // we are noexcept and must swallow any exception here
30  }
31  }
32 
34  {
35  if(m_low_level)
36  {
37  m_low_level->C_Finalize(nullptr);
38  }
39 
40  m_library.reset(new Dynamically_Loaded_Library(m_file_path));
41  LowLevel::C_GetFunctionList(*m_library, &m_func_list);
42  m_low_level.reset(new LowLevel(m_func_list));
43 
44  m_low_level->C_Initialize(&init_args);
45  }
46 
47 }
48 }
#define BOTAN_NOEXCEPT
Definition: compiler.h:154
static bool C_GetFunctionList(Dynamically_Loaded_Library &pkcs11_module, FunctionListPtr *function_list_ptr_ptr, ReturnValue *return_value=ThrowException)
Definition: p11.cpp:102
Provides access to all PKCS#11 functions.
Definition: p11.h:901
Definition: alg_id.cpp:13
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:15
void reload(C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr })
Definition: p11_module.cpp:33
~Module() BOTAN_NOEXCEPT
Calls C_Finalize()
Definition: p11_module.cpp:21