ctap.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2021 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
24 #include <stdint.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
35 #define CTAP_MAX_MSG_SIZE 0x400
36 
43 typedef enum {
44  CTAP2_OK = 0x00,
45  CTAP1_ERR_INVALID_COMMAND = 0x01,
46  CTAP1_ERR_INVALID_PARAMETER = 0x02,
47  CTAP1_ERR_INVALID_LENGTH = 0x03,
48  CTAP1_ERR_INVALID_SEQ = 0x04,
49  CTAP1_ERR_TIMEOUT = 0x05,
50  CTAP1_ERR_CHANNEL_BUSY = 0x06,
51  CTAP1_ERR_LOCK_REQUIRED = 0x0A,
52  CTAP1_ERR_INVALID_CHANNEL = 0x0B,
53  CTAP2_ERR_CBOR_PARSING = 0x10,
54  CTAP2_ERR_CBOR_UNEXPECTED_TYPE = 0x11,
55  CTAP2_ERR_INVALID_CBOR = 0x12,
56  CTAP2_ERR_INVALID_CBOR_TYPE = 0x13,
57  CTAP2_ERR_MISSING_PARAMETER = 0x14,
58  CTAP2_ERR_LIMIT_EXCEEDED = 0x15,
59  CTAP2_ERR_UNSUPPORTED_EXTENSION = 0x16,
60  CTAP2_ERR_TOO_MANY_ELEMENTS = 0x17,
61  CTAP2_ERR_EXTENSION_NOT_SUPPORTED = 0x18,
62  CTAP2_ERR_CREDENTIAL_EXCLUDED = 0x19,
63  CTAP2_ERR_CREDENTIAL_NOT_VALID = 0x20,
64  CTAP2_ERR_PROCESSING = 0x21,
65  CTAP2_ERR_INVALID_CREDENTIAL = 0x22,
66  CTAP2_ERR_USER_ACTION_PENDING = 0x23,
67  CTAP2_ERR_OPERATION_PENDING = 0x24,
68  CTAP2_ERR_NO_OPERATIONS = 0x25,
69  CTAP2_ERR_UNSUPPORTED_ALGORITHM = 0x26,
70  CTAP2_ERR_OPERATION_DENIED = 0x27,
71  CTAP2_ERR_KEY_STORE_FULL = 0x28,
72  CTAP2_ERR_NOT_BUSY = 0x29,
73  CTAP2_ERR_NO_OPERATION_PENDING = 0x2A,
74  CTAP2_ERR_UNSUPPORTED_OPTION = 0x2B,
75  CTAP2_ERR_INVALID_OPTION = 0x2C,
76  CTAP2_ERR_KEEPALIVE_CANCEL = 0x2D,
77  CTAP2_ERR_NO_CREDENTIALS = 0x2E,
78  CTAP2_ERR_USER_ACTION_TIMEOUT = 0x2F,
79  CTAP2_ERR_NOT_ALLOWED = 0x30,
80  CTAP2_ERR_PIN_INVALID = 0x31,
81  CTAP2_ERR_PIN_BLOCKED = 0x32,
82  CTAP2_ERR_PIN_AUTH_INVALID = 0x33,
83  CTAP2_ERR_PIN_AUTH_BLOCKED = 0x34,
84  CTAP2_ERR_PIN_NOT_SET = 0x35,
85  CTAP2_ERR_PIN_REQUIRED = 0x36,
86  CTAP2_ERR_PIN_POLICY_VIOLATION = 0x37,
87  CTAP2_ERR_PIN_TOKEN_EXPIRED = 0x38,
88  CTAP2_ERR_REQUEST_TOO_LARGE = 0x39,
89  CTAP2_ERR_ACTION_TIMEOUT = 0x3A,
90  CTAP2_ERR_UP_REQUIRED = 0x3B,
91  CTAP1_ERR_OTHER = 0x7F,
92  CTAP2_ERR_SPEC_LAST = 0xDF,
93  CTAP2_ERR_EXTENSION_FIRST = 0xE0,
94  CTAP2_ERR_EXTENSION_LAST = 0xEF,
95  CTAP2_ERR_VENDOR_FIRST = 0xF0,
96  CTAP2_ERR_VENDOR_LAST = 0xFF
105 typedef enum {
106  CTAP_MAKE_CREDENTIAL = 0x01,
107  CTAP_GET_ASSERTION = 0x02,
108  CTAP_GET_INFO = 0x04,
109  CTAP_CLIENT_PIN = 0x06,
110  CTAP_RESET = 0x07,
111  CTAP_GET_NEXT_ASSERTION = 0x08
112 } ctap_method_t;
120 typedef struct {
121  uint8_t *buf;
122  size_t len;
123  uint8_t method;
124 } ctap_req_t;
125 
131 typedef struct {
133  uint8_t data[CTAP_MAX_MSG_SIZE];
134  size_t len;
135 } ctap_resp_t;
136 
143 
156 
168 
180 
191 
202 
214 
225 
226 #ifdef __cplusplus
227 }
228 #endif
ctap_status_code_t fido2_ctap_get_next_assertion(ctap_resp_t *resp)
GetNextAssertion method.
ctap_status_code_t fido2_ctap_make_credential(ctap_req_t *req, ctap_resp_t *resp)
MakeCredential method.
#define CTAP_MAX_MSG_SIZE
CTAP max message size.
Definition: ctap.h:35
ctap_method_t
CTAP methods.
Definition: ctap.h:105
ctap_status_code_t fido2_ctap_init(void)
Initialize ctap.
ctap_status_code_t fido2_ctap_get_info(ctap_resp_t *resp)
GetInfo method.
ctap_status_code_t fido2_ctap_handle_request(ctap_req_t *req, ctap_resp_t *resp)
Handle CBOR encoded ctap request.
ctap_status_code_t fido2_ctap_reset(ctap_resp_t *resp)
Reset method.
ctap_status_code_t fido2_ctap_get_assertion(ctap_req_t *req, ctap_resp_t *resp)
GetAssertion method.
ctap_status_code_t
CTAP status codes.
Definition: ctap.h:43
ctap_status_code_t fido2_ctap_client_pin(ctap_req_t *req, ctap_resp_t *resp)
ClientPIN method.
CTAP request struct.
Definition: ctap.h:120
uint8_t * buf
Buffer holding CBOR encoded data.
Definition: ctap.h:121
uint8_t method
CTAP method identitifer.
Definition: ctap.h:123
size_t len
Length of buf.
Definition: ctap.h:122
CTAP response struct.
Definition: ctap.h:131
ctap_status_code_t status
response status
Definition: ctap.h:132
size_t len
length of response data
Definition: ctap.h:134