Loading...
Searching...
No Matches
ctap_cbor.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
22#ifndef FIDO2_CTAP_CTAP_CBOR_H
23#define FIDO2_CTAP_CTAP_CBOR_H
24
25#include "fido2/ctap/ctap.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
34#define CTAP_CBOR_INFO_MAP_SZ 0x06
35
39#define CTAP_CBOR_ATTESTATION_MAP_SZ 0x03
40
44#define CTAP_CBOR_ATTESTATION_STMT_MAP_SZ 0x02
45
49#define CTAP_CBOR_CRED_DESC_MAP_SZ 0x02
50
54#define CTAP_CBOR_PIN_TOKEN_MAP_SZ 0x01
55
59#define CTAP_CBOR_USER_ENTITY_MAP_SZ 0x01
60
64#define CTAP_CBOR_COSE_KEY_MAP_SZ 0x05
65
69#define CTAP_CBOR_KEY_AGREEMENT_MAP_SZ 0x01
70
74#define CTAP_CBOR_RETRIES_MAP_SZ 0x01
75
79#define CTAP_CBOR_ATT_STMT_AUTH_DATA_SZ 0x134
80
84#define CTAP_CBOR_MAP_MAX_KEY_LEN 0x10
85
89#define CTAP_CBOR_MAX_CREDENTIAL_TYPE_LEN 0x10
90
95#define CTAP_CBOR_STR_PACKED "packed"
96#define CTAP_CBOR_STR_ALG "alg"
97#define CTAP_CBOR_STR_SIG "sig"
98#define CTAP_CBOR_STR_ID "id"
99#define CTAP_CBOR_STR_TYPE "type"
100#define CTAP_CBOR_STR_PUBLIC_KEY "public-key"
101#define CTAP_CBOR_STR_USER_VERIFIED "uv"
102#define CTAP_CBOR_STR_USER_PRESENT "up"
103#define CTAP_CBOR_STR_RESIDENT_KEY "rk"
104#define CTAP_CBOR_STR_NAME "name"
105#define CTAP_CBOR_STR_ICON "icon"
106#define CTAP_CBOR_DISPLAY_NAME "displayName"
114#define CTAP_CBOR_CP_RESP_KEY_AGREEMENT 0x01
115#define CTAP_CBOR_CP_PIN_TOKEN_RESP 0x02
116#define CTAP_CBOR_CP_RETRIES_RESP 0x03
124#define CTAP_CBOR_MC_REQ_CLIENT_DATA_HASH 0x01
125#define CTAP_CBOR_MC_REQ_RP 0x02
126#define CTAP_CBOR_MC_REQ_USER 0x03
127#define CTAP_CBOR_MC_REQ_PUB_KEY_CRED_PARAMS 0x04
128#define CTAP_CBOR_MC_REQ_EXCLUDE_LIST 0x05
129#define CTAP_CBOR_MC_REQ_EXTENSIONS 0x06
130#define CTAP_CBOR_MC_REQ_OPTIONS 0x07
131#define CTAP_CBOR_MC_REQ_PIN_AUTH 0x08
132#define CTAP_CBOR_MC_REQ_PIN_PROTOCOL 0x09
140#define CTAP_CBOR_GET_INFO_RESP_VERSIONS 0x01
141#define CTAP_CBOR_GET_INFO_RESP_EXTENSIONS 0x02
142#define CTAP_CBOR_GET_INFO_RESP_AAGUID 0x03
143#define CTAP_CBOR_GET_INFO_RESP_OPTIONS 0x04
144#define CTAP_CBOR_GET_INFO_RESP_MAX_MSG_SIZE 0x05
145#define CTAP_CBOR_GET_INFO_RESP_PIN_PROTOCOLS 0x06
152#define CTAP_CBOR_VERSION_STRING_FIDO_PRE "FIDO_2_1_PRE"
153#define CTAP_CBOR_VERSION_STRING_FIDO "FIDO_2_0"
154#define CTAP_CBOR_VERSION_STRING_U2F_V2 "U2F_V2"
162#define CTAP_CBOR_MC_RESP_FMT 0x01
163#define CTAP_CBOR_MC_RESP_AUTH_DATA 0x02
164#define CTAP_CBOR_MC_RESP_ATT_STMT 0x03
172#define CTAP_CBOR_GA_REQ_RP_ID 0x01
173#define CTAP_CBOR_GA_REQ_CLIENT_DATA_HASH 0x02
174#define CTAP_CBOR_GA_REQ_ALLOW_LIST 0x03
175#define CTAP_CBOR_GA_REQ_EXTENSIONS 0x04
176#define CTAP_CBOR_GA_REQ_OPTIONS 0x05
177#define CTAP_CBOR_GA_REQ_PIN_AUTH 0x06
178#define CTAP_CBOR_GA_REQ_PIN_PROTOCOL 0x07
186#define CTAP_CBOR_GA_RESP_CREDENTIAL 0x01
187#define CTAP_CBOR_GA_RESP_AUTH_DATA 0x02
188#define CTAP_CBOR_GA_RESP_SIGNATURE 0x03
189#define CTAP_CBOR_GA_RESP_USER 0x04
190#define CTAP_CBOR_GA_RESP_NUMBER_OF_CREDENTIALS 0x05
198#define CTAP_CBOR_CP_REQ_PIN_PROTOCOL 0x01
199#define CTAP_CBOR_CP_REQ_SUB_COMMAND 0x02
200#define CTAP_CBOR_CP_REQ_KEY_AGREEMENT 0x03
201#define CTAP_CBOR_CP_REQ_PIN_AUTH 0x04
202#define CTAP_CBOR_CP_REQ_NEW_PIN_ENC 0x05
203#define CTAP_CBOR_CP_REQ_PIN_HASH_ENC 0x06
218 const uint8_t *req_raw, size_t len);
219
232 const uint8_t *req_raw, size_t len);
233
257 const uint8_t *req_raw, size_t len);
270 const uint8_t *client_data_hash,
272
286 const uint8_t *client_data_hash,
288 uint8_t valid_cred_count);
297
306int fido2_ctap_cbor_encode_pin_token(uint8_t *token, size_t len);
307
315int fido2_ctap_cbor_encode_retries(uint8_t tries_left);
316
324size_t fido2_ctap_cbor_get_buffer_size(const uint8_t *buf);
325
332void fido2_ctap_cbor_init_encoder(uint8_t *buf, size_t len);
333
334#ifdef __cplusplus
335}
336#endif
337#endif /* FIDO2_CTAP_CTAP_CBOR_H */
Internal FIDO2 CTAP defines, structures and function declarations.
int fido2_ctap_cbor_encode_retries(uint8_t tries_left)
Encode PIN tries left.
int fido2_ctap_cbor_parse_make_credential_req(ctap_make_credential_req_t *req, const uint8_t *req_raw, size_t len)
Parse MakeCredential method.
int fido2_ctap_cbor_encode_key_agreement(const ctap_public_key_cose_t *key)
Encode key agreement.
size_t fido2_ctap_cbor_get_buffer_size(const uint8_t *buf)
Get size of CBOR encoded data.
int fido2_ctap_cbor_parse_get_assertion_req(ctap_get_assertion_req_t *req, const uint8_t *req_raw, size_t len)
Parse GetAssertion method.
int fido2_ctap_cbor_encode_info(const ctap_info_t *info)
Encode CBOR info map.
int fido2_ctap_cbor_parse_client_pin_req(ctap_client_pin_req_t *req, const uint8_t *req_raw, size_t len)
Parse ClientPIN method.
int 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.
int 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.
int fido2_ctap_cbor_encode_pin_token(uint8_t *token, size_t len)
Encode encrypted pin token.
void fido2_ctap_cbor_init_encoder(uint8_t *buf, size_t len)
Initialize CBOR encoder.
CTAP authenticator data header struct.
Definition ctap.h:607
CTAP authenticator data struct.
Definition ctap.h:616
CTAP client pin request struct.
Definition ctap.h:569
CTAP get assertion request struct.
Definition ctap.h:553
CTAP info struct.
Definition ctap.h:624
CTAP make credential request struct.
Definition ctap.h:535
CTAP cose key struct.
Definition ctap.h:465
CTAP resident key struct.
Definition ctap.h:497