Botan 3.0.0-alpha0
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 
modulethe PKCS#11 module to use
slot_idthe slot id to use

Definition at line 13 of file p11_slot.cpp.

14 : m_module(module), m_slot_id(slot_id)
15 {}
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 

Get available slots

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

Definition at line 38 of file p11_slot.cpp.

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

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

32 {
33 MechanismInfo mechanism_info = {};
34 m_module.get()->C_GetMechanismInfo(m_slot_id, mechanism_type, &mechanism_info);
35 return mechanism_info;
36 }
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 24 of file p11_slot.cpp.

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

◆ get_slot_info()

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

Definition at line 17 of file p11_slot.cpp.

18 {
19 SlotInfo slot_info = {};
20 m_module.get()->C_GetSlotInfo(m_slot_id, &slot_info);
21 return slot_info;
22 }
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 45 of file p11_slot.cpp.

46 {
47 TokenInfo token_info;
48 m_module.get()->C_GetTokenInfo(m_slot_id, &token_info);
49 return token_info;
50 }
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

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

Definition at line 52 of file p11_slot.cpp.

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

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

◆ module()

Module & Botan::PKCS11::Slot::module ( ) const
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
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: