17#define CTAP2_CMD_MAKE_CREDENTIAL 0x01
18#define CTAP2_CMD_GET_ASSERTION 0x02
19#define CTAP2_CMD_GET_INFO 0x04
20#define CTAP2_CMD_CLIENT_PIN 0x06
21#define CTAP2_CMD_RESET 0x07
22#define CTAP2_CMD_GET_NEXT_ASSERTION 0x08
23#define CTAP2_CMD_CRED_MANAGEMENT 0x0A
24#define CTAP2_CMD_SELECTION 0x0B
25#define CTAP2_CMD_LARGE_BLOBS 0x0C
26#define CTAP2_CMD_CONFIG 0x0D
29#define CTAP2_CMD_VENDOR_FIRST 0x40
30#define CTAP2_CMD_VENDOR_LAST 0xBF
37#define CTAP1_ERR_INVALID_COMMAND 0x01
38#define CTAP1_ERR_INVALID_PARAMETER 0x02
39#define CTAP1_ERR_INVALID_LENGTH 0x03
40#define CTAP1_ERR_INVALID_SEQ 0x04
41#define CTAP1_ERR_TIMEOUT 0x05
42#define CTAP1_ERR_CHANNEL_BUSY 0x06
43#define CTAP1_ERR_LOCK_REQUIRED 0x0A
44#define CTAP1_ERR_INVALID_CHANNEL 0x0B
45#define CTAP2_ERR_CBOR_UNEXPECTED_TYPE 0x11
46#define CTAP2_ERR_INVALID_CBOR 0x12
47#define CTAP2_ERR_MISSING_PARAMETER 0x14
48#define CTAP2_ERR_LIMIT_EXCEEDED 0x15
49#define CTAP2_ERR_UNSUPPORTED_EXT 0x16
50#define CTAP2_ERR_LARGE_BLOB_STORAGE_FULL 0x18
51#define CTAP2_ERR_CREDENTIAL_EXCLUDED 0x19
52#define CTAP2_ERR_PROCESSING 0x21
53#define CTAP2_ERR_INVALID_CREDENTIAL 0x22
54#define CTAP2_ERR_USER_ACTION_PENDING 0x23
55#define CTAP2_ERR_OPERATION_PENDING 0x24
56#define CTAP2_ERR_NO_OPERATIONS 0x25
57#define CTAP2_ERR_UNSUPPORTED_ALGORITHM 0x26
58#define CTAP2_ERR_OPERATION_DENIED 0x27
59#define CTAP2_ERR_KEY_STORE_FULL 0x28
60#define CTAP2_ERR_NO_OPERATION_PENDING 0x2A
61#define CTAP2_ERR_UNSUPPORTED_OPTION 0x2B
62#define CTAP2_ERR_INVALID_OPTION 0x2C
63#define CTAP2_ERR_KEEPALIVE_CANCEL 0x2D
64#define CTAP2_ERR_NO_CREDENTIALS 0x2E
65#define CTAP2_ERR_USER_ACTION_TIMEOUT 0x2F
66#define CTAP2_ERR_NOT_ALLOWED 0x30
67#define CTAP2_ERR_PIN_INVALID 0x31
68#define CTAP2_ERR_PIN_BLOCKED 0x32
69#define CTAP2_ERR_PIN_AUTH_INVALID 0x33
70#define CTAP2_ERR_PIN_AUTH_BLOCKED 0x34
71#define CTAP2_ERR_PIN_NOT_SET 0x35
72#define CTAP2_ERR_PIN_REQUIRED 0x36
73#define CTAP2_ERR_PIN_POLICY_VIOLATION 0x37
74#define CTAP2_ERR_PIN_TOKEN_EXPIRED 0x38
75#define CTAP2_ERR_REQUEST_TOO_LARGE 0x39
76#define CTAP2_ERR_ACTION_TIMEOUT 0x3A
77#define CTAP2_ERR_UP_REQUIRED 0x3B
78#define CTAP2_ERR_UV_BLOCKED 0x3C
79#define CTAP2_ERR_INTEGRITY_FAILURE 0x3D
80#define CTAP2_ERR_OTHER 0x7F
86#define COSE_ALG_ES256 -7
87#define COSE_ALG_EDDSA -8
88#define COSE_ALG_RS256 -257
89#define COSE_ALG_ECDH_ES_HKDF_256 -25
98#define COSE_KEY_LABEL_KTY 1
99#define COSE_KEY_LABEL_KID 2
100#define COSE_KEY_LABEL_ALG 3
101#define COSE_KEY_LABEL_OPS 4
102#define COSE_KEY_LABEL_BASE_IV 5
103#define COSE_KEY_LABEL_CRV -1
104#define COSE_KEY_LABEL_X -2
105#define COSE_KEY_LABEL_Y -3
106#define COSE_KEY_LABEL_D -4
109#define COSE_KEY_TYPE_OKP 1
110#define COSE_KEY_TYPE_EC2 2
111#define COSE_KEY_TYPE_SYMMETRIC 4
114#define COSE_CRV_P256 1
115#define COSE_CRV_P384 2
116#define COSE_CRV_P521 3
117#define COSE_CRV_X25519 4
118#define COSE_CRV_X448 5
119#define COSE_CRV_ED25519 6
120#define COSE_CRV_ED448 7
128#define CTAP2_INFO_VERSIONS 0x01
129#define CTAP2_INFO_EXTENSIONS 0x02
130#define CTAP2_INFO_AAGUID 0x03
131#define CTAP2_INFO_OPTIONS 0x04
132#define CTAP2_INFO_MAX_MSG_SIZE 0x05
133#define CTAP2_INFO_PIN_UV_AUTH_PROTOCOLS 0x06
134#define CTAP2_INFO_MAX_CRED_COUNT_IN_LIST 0x07
135#define CTAP2_INFO_MAX_CRED_ID_LENGTH 0x08
136#define CTAP2_INFO_TRANSPORTS 0x09
137#define CTAP2_INFO_ALGORITHMS 0x0A
138#define CTAP2_INFO_MAX_SERIALIZED_LARGE_BLOB_ARRAY 0x0B
139#define CTAP2_INFO_MIN_PIN_LENGTH 0x0D
142#define CTAP2_MC_CLIENT_DATA_HASH 0x01
143#define CTAP2_MC_RP 0x02
144#define CTAP2_MC_USER 0x03
145#define CTAP2_MC_PUB_KEY_CRED_PARAMS 0x04
146#define CTAP2_MC_EXCLUDE_LIST 0x05
147#define CTAP2_MC_EXTENSIONS 0x06
148#define CTAP2_MC_OPTIONS 0x07
149#define CTAP2_MC_PIN_UV_AUTH_PARAM 0x08
150#define CTAP2_MC_PIN_UV_AUTH_PROTOCOL 0x09
153#define CTAP2_MC_RESP_FMT 0x01
154#define CTAP2_MC_RESP_AUTH_DATA 0x02
155#define CTAP2_MC_RESP_ATT_STMT 0x03
158#define CTAP2_GA_RP_ID 0x01
159#define CTAP2_GA_CLIENT_DATA_HASH 0x02
160#define CTAP2_GA_ALLOW_LIST 0x03
161#define CTAP2_GA_EXTENSIONS 0x04
162#define CTAP2_GA_OPTIONS 0x05
163#define CTAP2_GA_PIN_UV_AUTH_PARAM 0x06
164#define CTAP2_GA_PIN_UV_AUTH_PROTOCOL 0x07
167#define CTAP2_GA_RESP_CREDENTIAL 0x01
168#define CTAP2_GA_RESP_AUTH_DATA 0x02
169#define CTAP2_GA_RESP_SIGNATURE 0x03
170#define CTAP2_GA_RESP_USER 0x04
171#define CTAP2_GA_RESP_NUMBER_OF_CREDS 0x05
174#define CTAP2_PIN_PROTOCOL 0x01
175#define CTAP2_PIN_SUBCOMMAND 0x02
176#define CTAP2_PIN_KEY_AGREEMENT 0x03
177#define CTAP2_PIN_AUTH 0x04
178#define CTAP2_PIN_NEW_PIN_ENC 0x05
179#define CTAP2_PIN_HASH_ENC 0x06
180#define CTAP2_PIN_PERMISSIONS 0x09
181#define CTAP2_PIN_PERMISSIONS_RPID 0x0A
184#define CTAP2_PIN_RESP_KEY_AGREEMENT 0x01
185#define CTAP2_PIN_RESP_PIN_TOKEN 0x02
186#define CTAP2_PIN_RESP_PIN_RETRIES 0x03
187#define CTAP2_PIN_RESP_POWER_CYCLE_STATE 0x04
188#define CTAP2_PIN_RESP_UV_RETRIES 0x05
191#define CTAP2_CM_SUBCOMMAND 0x01
192#define CTAP2_CM_SUBCOMMAND_PARAMS 0x02
193#define CTAP2_CM_PIN_UV_AUTH_PROTOCOL 0x03
194#define CTAP2_CM_PIN_UV_AUTH_PARAM 0x04
197#define CTAP2_CM_SUB_RP_ID_HASH 0x01
198#define CTAP2_CM_SUB_CREDENTIAL_ID 0x02
201#define CTAP2_CM_RESP_EXISTING_CRED_COUNT 0x01
202#define CTAP2_CM_RESP_REMAINING_CRED_COUNT 0x02
203#define CTAP2_CM_RESP_RP 0x03
204#define CTAP2_CM_RESP_RP_ID_HASH 0x04
205#define CTAP2_CM_RESP_TOTAL_RPS 0x05
206#define CTAP2_CM_RESP_USER 0x06
207#define CTAP2_CM_RESP_CREDENTIAL_ID 0x07
208#define CTAP2_CM_RESP_PUBLIC_KEY 0x08
209#define CTAP2_CM_RESP_TOTAL_CREDENTIALS 0x09
210#define CTAP2_CM_RESP_CRED_PROTECT 0x0A
213#define CTAP2_LB_GET 0x01
214#define CTAP2_LB_SET 0x02
215#define CTAP2_LB_OFFSET 0x03
216#define CTAP2_LB_LENGTH 0x04
217#define CTAP2_LB_PIN_UV_AUTH_PARAM 0x05
218#define CTAP2_LB_PIN_UV_AUTH_PROTOCOL 0x06
219#define CTAP2_LB_RESP_CONFIG 0x01
222#define CTAP2_CONFIG_SUBCOMMAND 0x01
223#define CTAP2_CONFIG_SUBCOMMAND_PARAMS 0x02
224#define CTAP2_CONFIG_PIN_UV_AUTH_PROTOCOL 0x03
225#define CTAP2_CONFIG_PIN_UV_AUTH_PARAM 0x04
228#define CTAP2_CONFIG_SUB_ENABLE_EP 0x01
229#define CTAP2_CONFIG_SUB_TOGGLE_ALWAYS_UV 0x02
230#define CTAP2_CONFIG_SUB_SET_MIN_PIN_LENGTH 0x03
231#define CTAP2_CONFIG_SUB_VENDOR_PROTOTYPE 0xFF
234#define CTAP2_CONFIG_PARAM_NEW_MIN_PIN_LEN 0x01
235#define CTAP2_CONFIG_PARAM_MIN_PIN_RPIDS 0x02
236#define CTAP2_CONFIG_PARAM_FORCE_CHANGE_PIN 0x03
259 uint8_t *response, uint16_t *response_len);
289 uint8_t *response, uint16_t *response_len);
292 uint8_t *response, uint16_t *response_len);
297 uint8_t *response, uint16_t *response_len);
299uint8_t
ctap2_reset(uint8_t *response, uint16_t *response_len);
304 uint8_t *response, uint16_t *response_len);
309 uint8_t *response, uint16_t *response_len);
311uint8_t
ctap2_config(
const uint8_t *params, uint16_t params_len,
312 uint8_t *response, uint16_t *response_len);
uint8_t ctap2_reset(uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorReset (0x07).
uint8_t ctap2_client_pin(const uint8_t *params, uint16_t params_len, uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorClientPIN (0x06).
void ctap2_cancel(void)
Marks current CTAP2 operation as cancelled.
uint8_t ctap2_process_command(const uint8_t *cmd, uint16_t cmd_len, uint8_t *response, uint16_t *response_len)
Dispatches one CTAP2 command and writes response payload.
void ctap2_clear_cancel(void)
Clears the cancel flag. Called when a new CTAPHID channel is opened so a cancel from a previous chann...
bool ctap2_init(void)
Initializes CTAP2 runtime state.
uint8_t ctap2_selection(uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorSelection (0x0B).
bool ctap2_is_cancelled(void)
Returns true if the current CTAP2 operation has been cancelled.
uint8_t ctap2_large_blobs(const uint8_t *params, uint16_t params_len, uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorLargeBlobs (0x0C).
uint8_t ctap2_config(const uint8_t *params, uint16_t params_len, uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorConfig (0x0D).
void ctap2_send_keepalive(uint8_t status)
Sends CTAPHID keepalive for currently active channel.
uint8_t ctap2_get_assertion(const uint8_t *params, uint16_t params_len, uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorGetAssertion (0x02).
uint8_t ctap2_make_credential(const uint8_t *params, uint16_t params_len, uint8_t *response, uint16_t *response_len)
uint8_t ctap2_cred_management(const uint8_t *params, uint16_t params_len, uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorCredentialManagement (0x0A).
uint8_t ctap2_get_next_assertion(uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorGetNextAssertion (0x08).
uint8_t ctap2_get_info(uint8_t *response, uint16_t *response_len)
Handles CTAP2 authenticatorGetInfo (0x04).