Botan 3.11.0
Crypto and TLS for C&
Botan::PKCS11::Module Class Referencefinal

#include <p11_types.h>

Public Member Functions

Info get_info () const
const Dynamically_Loaded_Librarylibrary ()
std::string_view library_path () const
 Module (const Module &other)=delete
 Module (Module &&other) noexcept
BOTAN_FUTURE_EXPLICIT Module (std::string_view file_path, C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr})
LowLeveloperator-> () const
Moduleoperator= (const Module &other)=delete
Moduleoperator= (Module &&other)=delete
void reload (C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr})
 ~Module () noexcept
 Calls C_Finalize().

Detailed Description

Loads the PKCS#11 shared library Calls C_Initialize on load and C_Finalize on destruction

Definition at line 27 of file p11_types.h.

Constructor & Destructor Documentation

◆ Module() [1/3]

Botan::PKCS11::Module::Module ( std::string_view file_path,
C_InitializeArgs init_args = { nullptr, nullptr, nullptr, nullptr, static_cast<CK_FLAGS>(Flag::OsLockingOk), nullptr} )

Loads the shared library and calls C_Initialize. The latest supported "PKCS 11" interface is used.

Parameters
file_paththe path to the PKCS#11 shared library
init_argsflags to use for C_Initialize

Definition at line 15 of file p11_module.cpp.

15 : 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}
void reload(C_InitializeArgs init_args={ nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr})

References reload().

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

◆ Module() [2/3]

Botan::PKCS11::Module::Module ( Module && other)
defaultnoexcept

References Module().

◆ Module() [3/3]

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

References Module().

◆ ~Module()

Botan::PKCS11::Module::~Module ( )
noexcept

Calls C_Finalize().

Definition at line 24 of file p11_module.cpp.

24 {
25 try {
26 m_low_level->C_Finalize(nullptr, nullptr);
27 } catch(...) {
28 // we are noexcept and must swallow any exception here
29 }
30}

Member Function Documentation

◆ get_info()

Info Botan::PKCS11::Module::get_info ( ) const
inline
Returns
general information about Cryptoki

Definition at line 61 of file p11_types.h.

61 {
62 Info info;
63 m_low_level->C_GetInfo(&info);
64 return info;
65 }
CK_INFO Info
Definition p11.h:1199

◆ library()

const Dynamically_Loaded_Library & Botan::PKCS11::Module::library ( )
inline

Definition at line 69 of file p11_types.h.

69{ return *m_library; }

◆ library_path()

std::string_view Botan::PKCS11::Module::library_path ( ) const
inline

Definition at line 67 of file p11_types.h.

67{ return m_file_path; }

◆ operator->()

LowLevel * Botan::PKCS11::Module::operator-> ( ) const
inline

Definition at line 58 of file p11_types.h.

58{ return m_low_level.get(); }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

References Module().

◆ reload()

void Botan::PKCS11::Module::reload ( C_InitializeArgs init_args = { nullptr, nullptr, nullptr, nullptr, static_cast<CK_FLAGS>(Flag::OsLockingOk), nullptr})

Reloads the module and reinitializes it.

Parameters
init_argsflags to use for C_Initialize

Definition at line 32 of file p11_module.cpp.

32 {
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}
static InterfaceWrapper latest_p11_interface(Dynamically_Loaded_Library &library)

References Botan::PKCS11::InterfaceWrapper::latest_p11_interface().

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


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