Botan 2.13.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_module.h>
17
18 namespace Botan {
19 namespace PKCS11 {
20
21 /// Represents a PKCS#11 Slot, i.e., a card reader
22 class BOTAN_PUBLIC_API(2,0) Slot final
23 {
24 public:
25 /**
26 * @param module the PKCS#11 module to use
27 * @param slot_id the slot id to use
28 */
29 Slot(Module& module, SlotId slot_id);
30
31 /// @return a reference to the module that is used
32 inline Module& module() const
33 {
34 return m_module;
35 }
36
37 /// @return the slot id
38 inline SlotId slot_id() const
39 {
40 return m_slot_id;
41 }
42
43 /**
44 * Get available slots
45 * @param module the module to use
46 * @param token_present true if only slots with attached tokens should be returned, false for all slots
47 * @return a list of available slots (calls C_GetSlotList)
48 */
49 static std::vector<SlotId> get_available_slots(Module& module, bool token_present);
50
51 /// @return information about the slot (`C_GetSlotInfo`)
52 SlotInfo get_slot_info() const;
53
54 /// Obtains a list of mechanism types supported by the slot (`C_GetMechanismList`)
55 std::vector<MechanismType> get_mechanism_list() const;
56
57 /// Obtains information about a particular mechanism possibly supported by a slot (`C_GetMechanismInfo`)
58 MechanismInfo get_mechanism_info(MechanismType mechanism_type) const;
59
60 /// Obtains information about a particular token in the system (`C_GetTokenInfo`)
61 TokenInfo get_token_info() const;
62
63 /**
64 * Calls `C_InitToken` to initialize the token
65 * @param label the label for the token (must not exceed 32 bytes according to PKCS#11)
66 * @param so_pin the PIN of the security officer
67 */
68 void initialize(const std::string& label, const secure_string& so_pin) const;
69
70 private:
71 const std::reference_wrapper<Module> m_module;
72 const SlotId m_slot_id;
73 };
74
75 }
76 }
77
78 #endif
CK_TOKEN_INFO
Definition: pkcs11t.h:130
CK_SLOT_INFO
Definition: pkcs11t.h:110
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
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:38
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:22
Botan::PKCS11::Slot::module
Module & module() const
Definition: p11_slot.h:32