Botan 3.0.0-alpha0
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)
14 : m_module(module), m_slot_id(slot_id)
15 {}
16
18 {
19 SlotInfo slot_info = {};
20 m_module.get()->C_GetSlotInfo(m_slot_id, &slot_info);
21 return slot_info;
22 }
23
24std::vector<MechanismType> Slot::get_mechanism_list() const
25 {
26 std::vector<MechanismType> mechanism_list;
27 m_module.get()->C_GetMechanismList(m_slot_id, mechanism_list);
28 return mechanism_list;
29 }
30
32 {
33 MechanismInfo mechanism_info = {};
34 m_module.get()->C_GetMechanismInfo(m_slot_id, mechanism_type, &mechanism_info);
35 return mechanism_info;
36 }
37
38std::vector<SlotId> Slot::get_available_slots(Module& module, bool token_present)
39 {
40 std::vector<SlotId> slot_vec;
41 module->C_GetSlotList(token_present, slot_vec);
42 return slot_vec;
43 }
44
46 {
47 TokenInfo token_info;
48 m_module.get()->C_GetTokenInfo(m_slot_id, &token_info);
49 return token_info;
50 }
51
52void Slot::initialize(const std::string& label, const secure_string& so_pin) const
53 {
54 m_module.get()->C_InitToken(m_slot_id, so_pin, label);
55 }
56}
bool C_GetSlotList(Bbool token_present, SlotId *slot_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:112
Module & module() const
Definition: p11_types.h:86
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:31
void initialize(const std::string &label, const secure_string &so_pin) const
Definition: p11_slot.cpp:52
SlotInfo get_slot_info() const
Definition: p11_slot.cpp:17
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:24
TokenInfo get_token_info() const
Obtains information about a particular token in the system (C_GetTokenInfo)
Definition: p11_slot.cpp:45
static std::vector< SlotId > get_available_slots(Module &module, bool token_present)
Definition: p11_slot.cpp:38
MechanismType
Definition: p11.h:338
secure_vector< uint8_t > secure_string
Definition: p11.h:63
CK_SLOT_ID SlotId
Definition: p11.h:837