LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
yubikeycommands.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_YUBIKEYCOMMANDS_HPP
8#define LOGICALACCESS_YUBIKEYCOMMANDS_HPP
9
11#include <logicalaccess/plugins/cards/yubikey/lla_cards_yubikey_api.hpp>
12#include <logicalaccess/tlv.hpp>
13#include <vector>
14
15namespace logicalaccess
16{
17#define CMD_YUBIKEY "Yubikey"
18
22typedef enum
23{
25 HMAC_SHA1 = 0x01,
29 HMAC_TYPE_TOTP = 0x20
31
35typedef enum
36{
37 PROP_NONE = 0x00,
38 PROP_ONLY_INCREASE = 0x01, /* Enforces that a challenge is always higher than the previous */
39 PROP_REQUIRE_TOUCH = 0x02 /* Require button press to generate OATH codes */
41
45typedef enum
46{
47 SLOT_DUMMY = 0x00,
49 SLOT_NAV = 0x02,
53 SLOT_SWAP = 0x06,
65
67{
73
75{
77 uint8_t digits = 0;
80
81typedef struct s_YubikeyListItem
82{
86
87#define YUBIKEY_TLV_DEVINFO_AVAILABLE_CAPABILITIES_USB 0x01 /* USB Applications and capabilities that are available for use on this YubiKey. */
88#define YUBIKEY_TLV_DEVINFO_SERIAL_NUMBER 0x02 /* Returns the serial number of the YubiKey (if present and visible). */
89#define YUBIKEY_TLV_DEVINFO_ENABLED_CAPABILITIES_USB 0x03 /* Applications that are currently enabled over USB on this YubiKey. */
90#define YUBIKEY_TLV_DEVINFO_FORM_FACTOR 0x04 /* Specifies the form factor of the YubiKey (USB-A, USB-C, Nano, etc.) */
91#define YUBIKEY_TLV_DEVINFO_FIRMWARE_VERSION 0x05 /* The Major.Minor.Patch version number of the firmware running on the YubiKey. */
92#define YUBIKEY_TLV_DEVINFO_AUTOEJECT_TIMEOUT 0x06 /* Timeout in (ms?) before the YubiKey automatically "ejects" itself. */
93#define YUBIKEY_TLV_DEVINFO_CHALLENGE_RESPONSE_TIMEOUT 0x07 /* The period of time (in seconds) after which the OTP challenge-response command should timeout. */
94#define YUBIKEY_TLV_DEVINFO_DEVICE_FLAGS 0x08 /* Device flags that can control device-global behavior. */
95#define YUBIKEY_TLV_DEVINFO_CONFIGURATION_LOCK 0x0A /* Indicates whether or not the YubiKey's configuration has been locked by the user. */
96#define YUBIKEY_TLV_DEVINFO_AVAILABLE_CAPABILITIES_NFC 0x0D /* NFC Applications and capabilities that are available for use on this YubiKey. */
97#define YUBIKEY_TLV_DEVINFO_ENABLED_CAPABILITIES_NFC 0x0E /* Applications that are currently enabled over USB on this YubiKey. */
98
99#define YUBIKEY_TLV_NAME 0x71
100#define YUBIKEY_TLV_NAME_LIST 0x72
101#define YUBIKEY_TLV_KEY 0x73
102#define YUBIKEY_TLV_CHALLENGE 0x74
103#define YUBIKEY_TLV_FULL_RESPONSE 0x75
104#define YUBIKEY_TLV_TRUNCATED_RESPONSE 0x76
105#define YUBIKEY_TLV_HOTP_RESPONSE 0x77
106#define YUBIKEY_TLV_PROPERTY 0x78
107#define YUBIKEY_TLV_VERSION 0x79
108#define YUBIKEY_TLV_IMF 0x7a
109#define YUBIKEY_TLV_ALGORITHM 0x7b
110#define YUBIKEY_TLV_TOUCH_RESPONSE 0x7c
111
115class LLA_CARDS_YUBIKEY_API YubikeyCommands : public Commands
116{
117 public:
118
124 {
125 }
126
131 explicit YubikeyCommands(std::string cmdtype)
132 : Commands(cmdtype)
133 {
134 }
135
141
147
148 /******************************************************
149 * *
150 * === OTP === *
151 * *
152 * All OTP management commands are skipped for now as *
153 * Yubikey Manager app can be used for initial setup. *
154 * *
155 ******************************************************/
156
163 virtual ByteVector otp_getResponse(YubikeySlot slot, const ByteVector& challenge) = 0;
164
170
175 virtual std::vector<TLVPtr> otp_getDeviceInfo() = 0;
176
182 virtual bool otp_queryFIPSMode() = 0;
183
184 /******************************************************
185 * *
186 * === OAUTH == *
187 * *
188 ******************************************************/
189
199 virtual void oath_put(const ByteVector& name, YubikeyHMAC algorithm, uint8_t digits, const ByteVector& key, YubikeyProperty property = PROP_NONE, const ByteVector& imf = ByteVector()) = 0;
200
205 virtual void oath_delete(const ByteVector& name) = 0;
206
216 virtual void oath_setCode(YubikeyHMAC algorithm, const ByteVector& key, const ByteVector& challenge) = 0;
217
222 virtual std::vector<YubikeyListItem> oath_list() = 0;
223
227 virtual void oath_reset() = 0;
228
236 virtual YubikeyCalculateResponse oath_calculate(const ByteVector& name, const ByteVector& challenge, bool truncate = false) = 0;
237
247 virtual ByteVector oath_validate(const ByteVector& challenge, const ByteVector& response) = 0;
248
255 virtual std::vector<YubikeyCalculateResponse> oath_calculateAll(const ByteVector& challenge, bool truncate = false) = 0;
256
262
263 virtual std::shared_ptr<ISO7816Commands> getISO7816Commands() const = 0;
264};
265}
266
267#endif
The base commands class for all card commands.
Definition: commands.hpp:21
The Yubikey commands class.
Definition: yubikeycommands.hpp:116
virtual bool otp_queryFIPSMode()=0
Determines whether or not the device is loaded with FIPS capable firmware, as well as if the key is c...
virtual std::shared_ptr< ISO7816Commands > getISO7816Commands() const =0
virtual ByteVector otp_getResponse(YubikeySlot slot, const ByteVector &challenge)=0
Challenge/Response operation.
virtual YubikeySelectResponse selectYubikeyOATH()=0
Select the Yubikey OATH application.
virtual void oath_reset()=0
Resets the application to just-installed state.
YubikeyCommands()
Constructor.
Definition: yubikeycommands.hpp:122
virtual void oath_setCode(YubikeyHMAC algorithm, const ByteVector &key, const ByteVector &challenge)=0
Configures Authentication. If length 0 is sent, authentication is removed. The key to be set is expec...
virtual std::vector< TLVPtr > otp_getDeviceInfo()=0
Reads configuration and metadata information about the YubiKey. Similar commands exist in other appli...
virtual ByteVector otp_getSerialNumber()=0
Reads the serial number of the YubiKey if it is allowed by the configuration. Note that certain keys,...
YubikeyCommands(std::string cmdtype)
Constructor.
Definition: yubikeycommands.hpp:131
virtual ByteVector selectYubikeyOTP()=0
Select the old Yubikey OTP application.
virtual void oath_put(const ByteVector &name, YubikeyHMAC algorithm, uint8_t digits, const ByteVector &key, YubikeyProperty property=PROP_NONE, const ByteVector &imf=ByteVector())=0
Adds a new (or overwrites) OATH credential.
virtual std::vector< YubikeyCalculateResponse > oath_calculateAll(const ByteVector &challenge, bool truncate=false)=0
Performs CALCULATE for all available credentials, returns name + response for TOTP and just name for ...
virtual ByteVector oath_validate(const ByteVector &challenge, const ByteVector &response)=0
Validates authentication (mutually). The challenge for this comes from the SELECT command....
virtual void oath_delete(const ByteVector &name)=0
Deletes an existing credential.
virtual std::vector< YubikeyListItem > oath_list()=0
Lists configured credentials.
virtual ByteVector oath_sendRemainingInstruction()=0
Gets remaining data if everything didn’t fit in previous response (response code was 61xx).
virtual YubikeyCalculateResponse oath_calculate(const ByteVector &name, const ByteVector &challenge, bool truncate=false)=0
Performs CALCULATE for one named credential.
ISO7816 commands. See http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4....
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
YubikeyProperty
Yubikey properties.
Definition: yubikeycommands.hpp:36
@ PROP_ONLY_INCREASE
Definition: yubikeycommands.hpp:38
@ PROP_NONE
Definition: yubikeycommands.hpp:37
@ PROP_REQUIRE_TOUCH
Definition: yubikeycommands.hpp:39
YubikeySlot
Yubikey slot. Only used for the old slot-based Yubikey API.
Definition: yubikeycommands.hpp:46
@ SLOT_NDEF_1
Definition: yubikeycommands.hpp:54
@ SLOT_NAV
Definition: yubikeycommands.hpp:49
@ SLOT_UPDATE_2
Definition: yubikeycommands.hpp:52
@ SLOT_DEVICE_CONFIGURATION
Definition: yubikeycommands.hpp:57
@ SLOT_SWAP
Definition: yubikeycommands.hpp:53
@ SLOT_SCAN_MAP
Definition: yubikeycommands.hpp:58
@ SLOT_DEVICE_SERIAL
Definition: yubikeycommands.hpp:56
@ SLOT_CONFIG_1
Definition: yubikeycommands.hpp:48
@ SLOT_YUBIKEY_4_CAPABILITIES
Definition: yubikeycommands.hpp:59
@ SLOT_DUMMY
Definition: yubikeycommands.hpp:47
@ SLOT_CHALLENGE_OTP_2
Definition: yubikeycommands.hpp:61
@ SLOT_CHALLENGE_HMAC_2
Definition: yubikeycommands.hpp:63
@ SLOT_CHALLENGE_HMAC_1
Definition: yubikeycommands.hpp:62
@ SLOT_CHALLENGE_OTP_1
Definition: yubikeycommands.hpp:60
@ SLOT_UPDATE_1
Definition: yubikeycommands.hpp:51
@ SLOT_NDEF_2
Definition: yubikeycommands.hpp:55
@ SLOT_CONFIG_2
Definition: yubikeycommands.hpp:50
struct logicalaccess::s_YubikeyCalculateResponse YubikeyCalculateResponse
YubikeyHMAC
The HMAC algorithm.
Definition: yubikeycommands.hpp:23
@ HMAC_TYPE_HOTP
Definition: yubikeycommands.hpp:28
@ HMAC_SHA1
Definition: yubikeycommands.hpp:25
@ HMAC_UNKNOWN
Definition: yubikeycommands.hpp:24
@ HMAC_SHA256
Definition: yubikeycommands.hpp:26
@ HMAC_SHA512
Definition: yubikeycommands.hpp:27
@ HMAC_TYPE_TOTP
Definition: yubikeycommands.hpp:29
struct logicalaccess::s_YubikeySelectResponse YubikeySelectResponse
struct logicalaccess::s_YubikeyListItem YubikeyListItem
Definition: yubikeycommands.hpp:75
uint8_t digits
Definition: yubikeycommands.hpp:77
ByteVector name
Definition: yubikeycommands.hpp:76
ByteVector response
Definition: yubikeycommands.hpp:78
Definition: yubikeycommands.hpp:82
YubikeyHMAC algorithm
Definition: yubikeycommands.hpp:83
ByteVector name
Definition: yubikeycommands.hpp:84
Definition: yubikeycommands.hpp:67
YubikeyHMAC algorithm
Definition: yubikeycommands.hpp:70
ByteVector name
Definition: yubikeycommands.hpp:69
ByteVector challenge
Definition: yubikeycommands.hpp:71
ByteVector version
Definition: yubikeycommands.hpp:68
#define CMD_YUBIKEY
Definition: yubikeycommands.hpp:17