ctap_cbor.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 
21 #include "fido2/ctap/ctap.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
30 #define CTAP_CBOR_INFO_MAP_SZ 0x06
31 
35 #define CTAP_CBOR_ATTESTATION_MAP_SZ 0x03
36 
40 #define CTAP_CBOR_ATTESTATION_STMT_MAP_SZ 0x02
41 
45 #define CTAP_CBOR_CRED_DESC_MAP_SZ 0x02
46 
50 #define CTAP_CBOR_PIN_TOKEN_MAP_SZ 0x01
51 
55 #define CTAP_CBOR_USER_ENTITY_MAP_SZ 0x01
56 
60 #define CTAP_CBOR_COSE_KEY_MAP_SZ 0x05
61 
65 #define CTAP_CBOR_KEY_AGREEMENT_MAP_SZ 0x01
66 
70 #define CTAP_CBOR_RETRIES_MAP_SZ 0x01
71 
75 #define CTAP_CBOR_ATT_STMT_AUTH_DATA_SZ 0x134
76 
80 #define CTAP_CBOR_MAP_MAX_KEY_LEN 0x10
81 
85 #define CTAP_CBOR_MAX_CREDENTIAL_TYPE_LEN 0x10
86 
91 #define CTAP_CBOR_STR_PACKED "packed"
92 #define CTAP_CBOR_STR_ALG "alg"
93 #define CTAP_CBOR_STR_SIG "sig"
94 #define CTAP_CBOR_STR_ID "id"
95 #define CTAP_CBOR_STR_TYPE "type"
96 #define CTAP_CBOR_STR_PUBLIC_KEY "public-key"
97 #define CTAP_CBOR_STR_USER_VERIFIED "uv"
98 #define CTAP_CBOR_STR_USER_PRESENT "up"
99 #define CTAP_CBOR_STR_RESIDENT_KEY "rk"
100 #define CTAP_CBOR_STR_NAME "name"
101 #define CTAP_CBOR_STR_ICON "icon"
102 #define CTAP_CBOR_DISPLAY_NAME "displayName"
110 #define CTAP_CBOR_CP_RESP_KEY_AGREEMENT 0x01
111 #define CTAP_CBOR_CP_PIN_TOKEN_RESP 0x02
112 #define CTAP_CBOR_CP_RETRIES_RESP 0x03
120 #define CTAP_CBOR_MC_REQ_CLIENT_DATA_HASH 0x01
121 #define CTAP_CBOR_MC_REQ_RP 0x02
122 #define CTAP_CBOR_MC_REQ_USER 0x03
123 #define CTAP_CBOR_MC_REQ_PUB_KEY_CRED_PARAMS 0x04
124 #define CTAP_CBOR_MC_REQ_EXCLUDE_LIST 0x05
125 #define CTAP_CBOR_MC_REQ_EXTENSIONS 0x06
126 #define CTAP_CBOR_MC_REQ_OPTIONS 0x07
127 #define CTAP_CBOR_MC_REQ_PIN_AUTH 0x08
128 #define CTAP_CBOR_MC_REQ_PIN_PROTOCOL 0x09
136 #define CTAP_CBOR_GET_INFO_RESP_VERSIONS 0x01
137 #define CTAP_CBOR_GET_INFO_RESP_EXTENSIONS 0x02
138 #define CTAP_CBOR_GET_INFO_RESP_AAGUID 0x03
139 #define CTAP_CBOR_GET_INFO_RESP_OPTIONS 0x04
140 #define CTAP_CBOR_GET_INFO_RESP_MAX_MSG_SIZE 0x05
141 #define CTAP_CBOR_GET_INFO_RESP_PIN_PROTOCOLS 0x06
148 #define CTAP_CBOR_VERSION_STRING_FIDO_PRE "FIDO_2_1_PRE"
149 #define CTAP_CBOR_VERSION_STRING_FIDO "FIDO_2_0"
150 #define CTAP_CBOR_VERSION_STRING_U2F_V2 "U2F_V2"
158 #define CTAP_CBOR_MC_RESP_FMT 0x01
159 #define CTAP_CBOR_MC_RESP_AUTH_DATA 0x02
160 #define CTAP_CBOR_MC_RESP_ATT_STMT 0x03
168 #define CTAP_CBOR_GA_REQ_RP_ID 0x01
169 #define CTAP_CBOR_GA_REQ_CLIENT_DATA_HASH 0x02
170 #define CTAP_CBOR_GA_REQ_ALLOW_LIST 0x03
171 #define CTAP_CBOR_GA_REQ_EXTENSIONS 0x04
172 #define CTAP_CBOR_GA_REQ_OPTIONS 0x05
173 #define CTAP_CBOR_GA_REQ_PIN_AUTH 0x06
174 #define CTAP_CBOR_GA_REQ_PIN_PROTOCOL 0x07
182 #define CTAP_CBOR_GA_RESP_CREDENTIAL 0x01
183 #define CTAP_CBOR_GA_RESP_AUTH_DATA 0x02
184 #define CTAP_CBOR_GA_RESP_SIGNATURE 0x03
185 #define CTAP_CBOR_GA_RESP_USER 0x04
186 #define CTAP_CBOR_GA_RESP_NUMBER_OF_CREDENTIALS 0x05
194 #define CTAP_CBOR_CP_REQ_PIN_PROTOCOL 0x01
195 #define CTAP_CBOR_CP_REQ_SUB_COMMAND 0x02
196 #define CTAP_CBOR_CP_REQ_KEY_AGREEMENT 0x03
197 #define CTAP_CBOR_CP_REQ_PIN_AUTH 0x04
198 #define CTAP_CBOR_CP_REQ_NEW_PIN_ENC 0x05
199 #define CTAP_CBOR_CP_REQ_PIN_HASH_ENC 0x06
214  const uint8_t *req_raw, size_t len);
215 
228  const uint8_t *req_raw, size_t len);
229 
253  const uint8_t *req_raw, size_t len);
266  const uint8_t *client_data_hash,
267  ctap_resident_key_t *rk);
268 
282  const uint8_t *client_data_hash,
284  uint8_t valid_cred_count);
293 
303 
312 
320 size_t fido2_ctap_cbor_get_buffer_size(const uint8_t *buf);
321 
328 void fido2_ctap_cbor_init_encoder(uint8_t *buf, size_t len);
329 
330 #ifdef __cplusplus
331 }
332 #endif
Internal FIDO2 CTAP defines, structures and function declarations.
ctap_status_code_t fido2_ctap_cbor_encode_attestation_object(const ctap_auth_data_t *auth_data, const uint8_t *client_data_hash, ctap_resident_key_t *rk)
Encode attestation object.
ctap_status_code_t fido2_ctap_cbor_encode_assertion_object(const ctap_auth_data_header_t *auth_data, const uint8_t *client_data_hash, ctap_resident_key_t *rk, uint8_t valid_cred_count)
Encode assertion object.
ctap_status_code_t fido2_ctap_cbor_encode_info(const ctap_info_t *info)
Encode CBOR info map.
ctap_status_code_t fido2_ctap_cbor_parse_make_credential_req(ctap_make_credential_req_t *req, const uint8_t *req_raw, size_t len)
Parse MakeCredential method.
ctap_status_code_t fido2_ctap_cbor_encode_key_agreement(const ctap_public_key_cose_t *key)
Encode key agreement.
ctap_status_code_t fido2_ctap_cbor_encode_pin_token(uint8_t *token, size_t len)
Encode encrypted pin token.
ctap_status_code_t fido2_ctap_cbor_parse_client_pin_req(ctap_client_pin_req_t *req, const uint8_t *req_raw, size_t len)
Parse ClientPIN method.
size_t fido2_ctap_cbor_get_buffer_size(const uint8_t *buf)
Get size of CBOR encoded data.
ctap_status_code_t fido2_ctap_cbor_parse_get_assertion_req(ctap_get_assertion_req_t *req, const uint8_t *req_raw, size_t len)
Parse GetAssertion method.
ctap_status_code_t fido2_ctap_cbor_encode_retries(uint8_t tries_left)
Encode PIN tries left.
void fido2_ctap_cbor_init_encoder(uint8_t *buf, size_t len)
Initialize CBOR encoder.
ctap_status_code_t
CTAP status codes.
Definition: ctap.h:43
CTAP authenticator data header struct.
Definition: ctap.h:592
CTAP authenticator data struct.
Definition: ctap.h:601
CTAP client pin request struct.
Definition: ctap.h:554
CTAP get assertion request struct.
Definition: ctap.h:538
CTAP info struct.
Definition: ctap.h:609
CTAP make credential request struct.
Definition: ctap.h:520
CTAP cose key struct.
Definition: ctap.h:450
CTAP resident key struct.
Definition: ctap.h:482