Botan 3.3.0
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)
 
std::vector< MechanismTypeget_mechanism_list () const
 Obtains a list of mechanism types supported by the slot (C_GetMechanismList)
 
SlotInfo get_slot_info () const
 
TokenInfo get_token_info () const
 Obtains information about a particular token in the system (C_GetTokenInfo)
 
void initialize (std::string_view 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 74 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 13 of file p11_slot.cpp.

13: m_module(module), m_slot_id(slot_id) {}
Module & module() const
Definition p11_types.h:83
SlotId slot_id() const
Definition p11_types.h:86

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 33 of file p11_slot.cpp.

33 {
34 std::vector<SlotId> slot_vec;
35 module->C_GetSlotList(token_present, slot_vec);
36 return slot_vec;
37}

◆ 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 27 of file p11_slot.cpp.

27 {
28 MechanismInfo mechanism_info = {};
29 m_module.get()->C_GetMechanismInfo(m_slot_id, mechanism_type, &mechanism_info);
30 return mechanism_info;
31}
CK_MECHANISM_INFO MechanismInfo
Definition p11.h:818

◆ 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 21 of file p11_slot.cpp.

21 {
22 std::vector<MechanismType> mechanism_list;
23 m_module.get()->C_GetMechanismList(m_slot_id, mechanism_list);
24 return mechanism_list;
25}

◆ get_slot_info()

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

Definition at line 15 of file p11_slot.cpp.

15 {
16 SlotInfo slot_info = {};
17 m_module.get()->C_GetSlotInfo(m_slot_id, &slot_info);
18 return slot_info;
19}
CK_SLOT_INFO SlotInfo
Definition p11.h:815

◆ 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 39 of file p11_slot.cpp.

39 {
40 TokenInfo token_info;
41 m_module.get()->C_GetTokenInfo(m_slot_id, &token_info);
42 return token_info;
43}
CK_TOKEN_INFO TokenInfo
Definition p11.h:816

◆ initialize()

void Botan::PKCS11::Slot::initialize ( std::string_view 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 45 of file p11_slot.cpp.

45 {
46 m_module.get()->C_InitToken(m_slot_id, so_pin, label);
47}

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 83 of file p11_types.h.

83{ return m_module; }

◆ slot_id()

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

Definition at line 86 of file p11_types.h.

86{ return m_slot_id; }

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


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