Botan  2.13.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::PKCS11::Module Class Referencefinal

#include <p11_module.h>

Public Member Functions

Info get_info () const
 
 Module (const std::string &file_path, C_InitializeArgs init_args={nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr})
 
 Module (Module &&other)=default
 
 Module (const Module &other)=delete
 
LowLeveloperator-> () const
 
Moduleoperator= (Module &&other)=delete
 
Moduleoperator= (const 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() More...
 

Detailed Description

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

Definition at line 25 of file p11_module.h.

Constructor & Destructor Documentation

Botan::PKCS11::Module::Module ( const std::string &  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

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.

References reload().

16  : m_file_path(file_path)
17  {
18  if(file_path.empty())
19  throw Invalid_Argument("PKCS11 no module path specified");
20  reload(init_args);
21  }
void reload(C_InitializeArgs init_args={nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr})
Definition: p11_module.cpp:35
Botan::PKCS11::Module::Module ( Module &&  other)
default
Botan::PKCS11::Module::Module ( const Module other)
delete
Botan::PKCS11::Module::~Module ( )
noexcept

Calls C_Finalize()

Definition at line 23 of file p11_module.cpp.

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

Member Function Documentation

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

Definition at line 58 of file p11_module.h.

59  {
60  Info info;
61  m_low_level->C_GetInfo(&info);
62  return info;
63  }
CK_INFO Info
Definition: p11.h:833
LowLevel* Botan::PKCS11::Module::operator-> ( ) const
inline

Definition at line 52 of file p11_module.h.

53  {
54  return m_low_level.get();
55  }
Module& Botan::PKCS11::Module::operator= ( Module &&  other)
delete
Module& Botan::PKCS11::Module::operator= ( const Module other)
delete
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 35 of file p11_module.cpp.

References Botan::PKCS11::LowLevel::C_GetFunctionList().

Referenced by Module().

36  {
37  if(m_low_level)
38  {
39  m_low_level->C_Finalize(nullptr);
40  }
41 
42  m_library.reset(new Dynamically_Loaded_Library(m_file_path));
43  LowLevel::C_GetFunctionList(*m_library, &m_func_list);
44  m_low_level.reset(new LowLevel(m_func_list));
45 
46  m_low_level->C_Initialize(&init_args);
47  }
static bool C_GetFunctionList(Dynamically_Loaded_Library &pkcs11_module, FunctionListPtr *function_list_ptr_ptr, ReturnValue *return_value=ThrowException)
Definition: p11.cpp:102

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