Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

p11_slot.h
Go to the documentation of this file.
1 /*
2 * PKCS#11 Slot
3 * (C) 2016 Daniel Neus
4 * (C) 2016 Philipp Weber
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9 #ifndef BOTAN_P11_SLOT_H__
10 #define BOTAN_P11_SLOT_H__
11
12 #include <string>
13 #include <vector>
14 #include <functional>
15
16 #include <botan/p11.h>
17 #include <botan/p11_module.h>
18
19 namespace Botan {
20 namespace PKCS11 {
21
22 /// Represents a PKCS#11 Slot, i.e., a card reader
23 class BOTAN_DLL Slot final
24 {
25 public:
26 /**
27 * @param module the PKCS#11 module to use
28 * @param slot_id the slot id to use
29 */
30 Slot(Module& module, SlotId slot_id);
31
32 /// @return a reference to the module that is used
33 inline Module& module() const
34 {
35 return m_module;
36 }
37
38 /// @return the slot id
39 inline SlotId slot_id() const
40 {
41 return m_slot_id;
42 }
43
44 /**
45 * Get available slots
46 * @param module the module to use
47 * @param token_present true if only slots with attached tokens should be returned, false for all slots
48 * @return a list of available slots (calls C_GetSlotList)
49 */
50 static std::vector<SlotId> get_available_slots(Module& module, bool token_present);
51
52 /// @return information about the slot (`C_GetSlotInfo`)
53 SlotInfo get_slot_info() const;
54
55 /// Obtains a list of mechanism types supported by the slot (`C_GetMechanismList`)
56 std::vector<MechanismType> get_mechanism_list() const;
57
58 /// Obtains information about a particular mechanism possibly supported by a slot (`C_GetMechanismInfo`)
59 MechanismInfo get_mechanism_info(MechanismType mechanism_type) const;
60
61 /// Obtains information about a particular token in the system (`C_GetTokenInfo`)
62 TokenInfo get_token_info() const;
63
64 /**
65 * Calls `C_InitToken` to initialize the token
66 * @param label the label for the token (must not exceed 32 bytes according to PKCS#11)
67 * @param so_pin the PIN of the security officer
68 */
69 void initialize(const std::string& label, const secure_string& so_pin) const;
70
71 private:
72 const std::reference_wrapper<Module> m_module;
73 const SlotId m_slot_id;
74 };
75
76 }
77 }
78
79 #endif
CK_TOKEN_INFO
Definition: pkcs11t.h:130
CK_SLOT_INFO
Definition: pkcs11t.h:110
Botan::PKCS11::Module
Definition: p11_module.h:25
CK_MECHANISM_INFO
Definition: pkcs11t.h:995
Botan::PKCS11::Slot::slot_id
SlotId slot_id() const
Definition: p11_slot.h:39
Botan
Definition: alg_id.cpp:13
Botan::PKCS11::SlotId
CK_SLOT_ID SlotId
Definition: p11.h:835
Botan::PKCS11::MechanismType
MechanismType
Definition: p11.h:335
Botan::PKCS11::secure_string
secure_vector< uint8_t > secure_string
Definition: p11.h:61
Botan::PKCS11::Slot
Represents a PKCS#11 Slot, i.e., a card reader.
Definition: p11_slot.h:23
Botan::PKCS11::Slot::module
Module & module() const
Definition: p11_slot.h:33