aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/prov/pkcs11/p11_slot.cpp
blob: 95a0fad509ef52af3a92004518d29ae7a3c688ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* PKCS#11 Slot
* (C) 2016 Daniel Neus, Sirrix AG
* (C) 2016 Philipp Weber, Sirrix AG
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include <botan/p11_slot.h>

namespace Botan {

namespace PKCS11 {

Slot::Slot(Module& module, SlotId slot_id)
   : m_module(module), m_slot_id(slot_id)
   {}

SlotInfo Slot::get_slot_info() const
   {
   SlotInfo slot_info = {};
   m_module.get()->C_GetSlotInfo(m_slot_id, &slot_info);
   return slot_info;
   }

std::vector<MechanismType> Slot::get_mechanism_list() const
   {
   std::vector<MechanismType> mechanism_list;
   m_module.get()->C_GetMechanismList(m_slot_id, mechanism_list);
   return mechanism_list;
   }

MechanismInfo Slot::get_mechanism_info(MechanismType mechanism_type) const
   {
   MechanismInfo mechanism_info = {};
   m_module.get()->C_GetMechanismInfo(m_slot_id, mechanism_type, &mechanism_info);
   return mechanism_info;
   }

std::vector<SlotId> Slot::get_available_slots(Module& module, bool token_present)
   {
   std::vector<SlotId> slot_vec;
   module->C_GetSlotList(token_present, slot_vec);
   return slot_vec;
   }

TokenInfo Slot::get_token_info() const
   {
   TokenInfo token_info;
   m_module.get()->C_GetTokenInfo(m_slot_id, &token_info);
   return token_info;
   }

void Slot::initialize(const std::string& label, const secure_string& so_pin) const
   {
   m_module.get()->C_InitToken(m_slot_id, so_pin, label);
   }
}

}