Botan 2.19.1
Crypto and TLS for C&
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_types.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 76 of file p11_types.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_types.h:86
SlotId slot_id() const
Definition: p11_types.h:92

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.

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

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

◆ 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:842

◆ 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:839

◆ 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:840

◆ 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.

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

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

◆ module()

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

Definition at line 86 of file p11_types.h.

87 {
88 return m_module;
89 }

Referenced by get_available_slots().

◆ slot_id()

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

Definition at line 92 of file p11_types.h.

93 {
94 return m_slot_id;
95 }

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


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