Botan 3.11.0
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
11#include <botan/internal/dyn_load.h>
12
13namespace Botan::PKCS11 {
14
15Module::Module(std::string_view file_path, C_InitializeArgs init_args) : m_file_path(file_path) {
16 if(file_path.empty()) {
17 throw Invalid_Argument("PKCS11 no module path specified");
18 }
19 reload(init_args);
20}
21
22Module::Module(Module&& other) noexcept = default;
23
24Module::~Module() noexcept {
25 try {
26 m_low_level->C_Finalize(nullptr, nullptr);
27 } catch(...) {
28 // we are noexcept and must swallow any exception here
29 }
30}
31
33 if(m_low_level) {
34 m_low_level->C_Finalize(nullptr);
35 }
36 m_library = std::make_unique<Dynamically_Loaded_Library>(m_file_path);
37 m_low_level = std::make_unique<LowLevel>(InterfaceWrapper::latest_p11_interface(*m_library));
38
39 m_low_level->C_Initialize(&init_args);
40}
41
42} // namespace Botan::PKCS11
static InterfaceWrapper latest_p11_interface(Dynamically_Loaded_Library &library)
~Module() noexcept
Calls C_Finalize().
void reload(C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr})
BOTAN_FUTURE_EXPLICIT Module(std::string_view file_path, C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr})
CK_C_INITIALIZE_ARGS C_InitializeArgs
Definition p11.h:1193