Botan 3.5.0
Crypto and TLS for C&
p11_slot.cpp
Go to the documentation of this file.
1/*
2* PKCS#11 Slot
3* (C) 2016 Daniel Neus, Sirrix AG
4* (C) 2016 Philipp Weber, Sirrix AG
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/p11_types.h>
10
11namespace Botan::PKCS11 {
12
13Slot::Slot(Module& module, SlotId slot_id) : m_module(module), m_slot_id(slot_id) {}
14
16 SlotInfo slot_info = {};
17 m_module.get()->C_GetSlotInfo(m_slot_id, &slot_info);
18 return slot_info;
19}
20
21std::vector<MechanismType> Slot::get_mechanism_list() const {
22 std::vector<MechanismType> mechanism_list;
23 m_module.get()->C_GetMechanismList(m_slot_id, mechanism_list);
24 return mechanism_list;
25}
26
28 MechanismInfo mechanism_info = {};
29 m_module.get()->C_GetMechanismInfo(m_slot_id, mechanism_type, &mechanism_info);
30 return mechanism_info;
31}
32
33std::vector<SlotId> Slot::get_available_slots(Module& module, bool token_present) {
34 std::vector<SlotId> slot_vec;
35 module->C_GetSlotList(token_present, slot_vec);
36 return slot_vec;
37}
38
40 TokenInfo token_info;
41 m_module.get()->C_GetTokenInfo(m_slot_id, &token_info);
42 return token_info;
43}
44
45void Slot::initialize(std::string_view label, const secure_string& so_pin) const {
46 m_module.get()->C_InitToken(m_slot_id, so_pin, label);
47}
48} // namespace Botan::PKCS11
MechanismInfo get_mechanism_info(MechanismType mechanism_type) const
Obtains information about a particular mechanism possibly supported by a slot (C_GetMechanismInfo)
Definition p11_slot.cpp:27
SlotInfo get_slot_info() const
Definition p11_slot.cpp:15
Slot(Module &module, SlotId slot_id)
Definition p11_slot.cpp:13
std::vector< MechanismType > get_mechanism_list() const
Obtains a list of mechanism types supported by the slot (C_GetMechanismList)
Definition p11_slot.cpp:21
TokenInfo get_token_info() const
Obtains information about a particular token in the system (C_GetTokenInfo)
Definition p11_slot.cpp:39
static std::vector< SlotId > get_available_slots(Module &module, bool token_present)
Definition p11_slot.cpp:33
void initialize(std::string_view label, const secure_string &so_pin) const
Definition p11_slot.cpp:45
CK_SLOT_ID SlotId
Definition p11.h:815
secure_vector< uint8_t > secure_string
Definition p11.h:59