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

Represents a PKCS#11 Slot, i.e., a card reader. More...

#include <p11_slot.h>

Public Member Functions

MechanismInfo get_mechanism_info (MechanismType mechanism_type) const
 Obtains information about a particular mechanism possibly supported by a slot (C_GetMechanismInfo) More...
 
std::vector< MechanismTypeget_mechanism_list () const
 Obtains a list of mechanism types supported by the slot (C_GetMechanismList) More...
 
SlotInfo get_slot_info () const
 
TokenInfo get_token_info () const
 Obtains information about a particular token in the system (C_GetTokenInfo) More...
 
void initialize (const std::string &label, const secure_string &so_pin) const
 
Modulemodule () const
 
 Slot (Module &module, SlotId slot_id)
 
SlotId slot_id () const
 

Static Public Member Functions

static std::vector< SlotIdget_available_slots (Module &module, bool token_present)
 

Detailed Description

Represents a PKCS#11 Slot, i.e., a card reader.

Definition at line 22 of file p11_slot.h.

Constructor & Destructor Documentation

◆ Slot()

Botan::PKCS11::Slot::Slot ( Module module,
SlotId  slot_id 
)
Parameters
modulethe PKCS#11 module to use
slot_idthe slot id to use

Definition at line 15 of file p11_slot.cpp.

16  : m_module(module), m_slot_id(slot_id)
17  {}
Module & module() const
Definition: p11_slot.h:32
SlotId slot_id() const
Definition: p11_slot.h:38

Member Function Documentation

◆ get_available_slots()

std::vector< SlotId > Botan::PKCS11::Slot::get_available_slots ( Module module,
bool  token_present 
)
static

Get available slots

Parameters
modulethe module to use
token_presenttrue if only slots with attached tokens should be returned, false for all slots
Returns
a list of available slots (calls C_GetSlotList)

Definition at line 40 of file p11_slot.cpp.

References Botan::PKCS11::LowLevel::C_GetSlotList(), and module().

41  {
42  std::vector<SlotId> slot_vec;
43  module->C_GetSlotList(token_present, slot_vec);
44  return slot_vec;
45  }
Module & module() const
Definition: p11_slot.h:32
bool C_GetSlotList(Bbool token_present, SlotId *slot_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:114

◆ get_mechanism_info()

MechanismInfo Botan::PKCS11::Slot::get_mechanism_info ( MechanismType  mechanism_type) const

Obtains information about a particular mechanism possibly supported by a slot (C_GetMechanismInfo)

Definition at line 33 of file p11_slot.cpp.

34  {
35  MechanismInfo mechanism_info = {};
36  m_module.get()->C_GetMechanismInfo(m_slot_id, mechanism_type, &mechanism_info);
37  return mechanism_info;
38  }
CK_MECHANISM_INFO MechanismInfo
Definition: p11.h:840

◆ get_mechanism_list()

std::vector< MechanismType > Botan::PKCS11::Slot::get_mechanism_list ( ) const

Obtains a list of mechanism types supported by the slot (C_GetMechanismList)

Definition at line 26 of file p11_slot.cpp.

27  {
28  std::vector<MechanismType> mechanism_list;
29  m_module.get()->C_GetMechanismList(m_slot_id, mechanism_list);
30  return mechanism_list;
31  }

◆ get_slot_info()

SlotInfo Botan::PKCS11::Slot::get_slot_info ( ) const
Returns
information about the slot (C_GetSlotInfo)

Definition at line 19 of file p11_slot.cpp.

20  {
21  SlotInfo slot_info = {};
22  m_module.get()->C_GetSlotInfo(m_slot_id, &slot_info);
23  return slot_info;
24  }
CK_SLOT_INFO SlotInfo
Definition: p11.h:837

◆ get_token_info()

TokenInfo Botan::PKCS11::Slot::get_token_info ( ) const

Obtains information about a particular token in the system (C_GetTokenInfo)

Definition at line 47 of file p11_slot.cpp.

48  {
49  TokenInfo token_info;
50  m_module.get()->C_GetTokenInfo(m_slot_id, &token_info);
51  return token_info;
52  }
CK_TOKEN_INFO TokenInfo
Definition: p11.h:838

◆ initialize()

void Botan::PKCS11::Slot::initialize ( const std::string &  label,
const secure_string so_pin 
) const

Calls C_InitToken to initialize the token

Parameters
labelthe label for the token (must not exceed 32 bytes according to PKCS#11)
so_pinthe PIN of the security officer

Definition at line 54 of file p11_slot.cpp.

Referenced by Botan::PKCS11::initialize_token().

55  {
56  m_module.get()->C_InitToken(m_slot_id, so_pin, label);
57  }

◆ module()

Module& Botan::PKCS11::Slot::module ( ) const
inline
Returns
a reference to the module that is used

Definition at line 32 of file p11_slot.h.

Referenced by get_available_slots().

33  {
34  return m_module;
35  }

◆ slot_id()

SlotId Botan::PKCS11::Slot::slot_id ( ) const
inline
Returns
the slot id

Definition at line 38 of file p11_slot.h.

Referenced by Botan::PKCS11::Session::Session().

39  {
40  return m_slot_id;
41  }

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