Botan  2.7.0
Crypto and TLS for C++11
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_slot.h>
10 
11 namespace Botan {
12 
13 namespace PKCS11 {
14 
15 Slot::Slot(Module& module, SlotId slot_id)
16  : m_module(module), m_slot_id(slot_id)
17  {}
18 
20  {
21  SlotInfo slot_info = {};
22  m_module.get()->C_GetSlotInfo(m_slot_id, &slot_info);
23  return slot_info;
24  }
25 
26 std::vector<MechanismType> Slot::get_mechanism_list() const
27  {
28  std::vector<MechanismType> mechanism_list;
29  m_module.get()->C_GetMechanismList(m_slot_id, mechanism_list);
30  return mechanism_list;
31  }
32 
34  {
35  MechanismInfo mechanism_info = {};
36  m_module.get()->C_GetMechanismInfo(m_slot_id, mechanism_type, &mechanism_info);
37  return mechanism_info;
38  }
39 
40 std::vector<SlotId> Slot::get_available_slots(Module& module, bool token_present)
41  {
42  std::vector<SlotId> slot_vec;
43  module->C_GetSlotList(token_present, slot_vec);
44  return slot_vec;
45  }
46 
48  {
49  TokenInfo token_info;
50  m_module.get()->C_GetTokenInfo(m_slot_id, &token_info);
51  return token_info;
52  }
53 
54 void Slot::initialize(const std::string& label, const secure_string& so_pin) const
55  {
56  m_module.get()->C_InitToken(m_slot_id, so_pin, label);
57  }
58 }
59 
60 }
Module & module() const
Definition: p11_slot.h:32
std::vector< MechanismType > get_mechanism_list() const
Obtains a list of mechanism types supported by the slot (C_GetMechanismList)
Definition: p11_slot.cpp:26
SlotInfo get_slot_info() const
Definition: p11_slot.cpp:19
void initialize(const std::string &label, const secure_string &so_pin) const
Definition: p11_slot.cpp:54
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:33
TokenInfo get_token_info() const
Obtains information about a particular token in the system (C_GetTokenInfo)
Definition: p11_slot.cpp:47
bool C_GetSlotList(Bbool token_present, SlotId *slot_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:114
static std::vector< SlotId > get_available_slots(Module &module, bool token_present)
Definition: p11_slot.cpp:40
Slot(Module &module, SlotId slot_id)
Definition: p11_slot.cpp:15
Definition: alg_id.cpp:13
CK_SLOT_ID SlotId
Definition: p11.h:835
MechanismType
Definition: p11.h:335
secure_vector< uint8_t > secure_string
Definition: p11.h:61