-
Notifications
You must be signed in to change notification settings - Fork 6
/
info.h
118 lines (106 loc) · 5.7 KB
/
info.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Copyright (c) 2018-2022 Yubico AB. All rights reserved.
* Copyright (c) 2022 Felix Gohla, Konrad Hanff, Tobias Kantusch,
* Quentin Kuth, Felix Roth. All rights reserved.
*
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
#pragma once
#include <stdint.h>
#include "utils.h"
// FIDO versions
#define FIDO_VERSION_U2F_V2 BITFIELD(0)
#define FIDO_VERSION_FIDO_2_0 BITFIELD(1)
#define FIDO_VERSION_FIDO_2_1 BITFIELD(2)
#define FIDO_VERSION_FIDO_2_1_PRE BITFIELD(3)
typedef uint8_t fido_cbor_version_t;
// FIDO extensions
#define FIDO_EXTENSION_CRED_PROTECT BITFIELD(0)
#define FIDO_EXTENSION_CRED_BLOB BITFIELD(1)
#define FIDO_EXTENSION_LARGE_BLOB_KEY BITFIELD(2)
#define FIDO_EXTENSION_MIN_PIN_LENGTH BITFIELD(3)
#define FIDO_EXTENSION_HMAC_SECRET BITFIELD(4)
typedef uint8_t fido_cbor_extension_t;
// FIDO transports
#define FIDO_TRANSPORT_USB BITFIELD(0)
#define FIDO_TRANSPORT_NFC BITFIELD(1)
#define FIDO_TRANSPORT_BLE BITFIELD(2)
#define FIDO_TRANSPORT_INTERNAL BITFIELD(3)
typedef uint8_t fido_cbor_transport_t;
// FIDO options
#define FIDO_OPTION_PLAT BITFIELD( 0)
#define FIDO_OPTION_RK BITFIELD( 1)
#define FIDO_OPTION_CLIENT_PIN BITFIELD( 2)
#define FIDO_OPTION_UP BITFIELD( 3)
#define FIDO_OPTION_UV BITFIELD( 4)
#define FIDO_OPTION_PIN_UV_AUTH_TOKEN BITFIELD( 5)
#define FIDO_OPTION_NO_MC_GA_PERMISSIONS_WITH_CLIENT_PIN BITFIELD( 6)
#define FIDO_OPTION_LARGE_BLOBS BITFIELD( 7)
#define FIDO_OPTION_EP BITFIELD( 8)
#define FIDO_OPTION_BIO_ENROLL BITFIELD( 9)
#define FIDO_OPTION_USER_VERIFICATION_MGMT_PREVIEW BITFIELD(10)
#define FIDO_OPTION_UV_BIO_ENROLL BITFIELD(11)
#define FIDO_OPTION_AUTHNR_CONFIG BITFIELD(12)
#define FIDO_OPTION_UV_ACFG BITFIELD(13)
#define FIDO_OPTION_CRED_MGMT BITFIELD(14)
#define FIDO_OPTION_CREDENTIAL_MANAGEMENT_PREVIEW BITFIELD(15)
#define FIDO_OPTION_SET_MIN_PIN_LENGTH BITFIELD(16)
#define FIDO_OPTION_MAKE_CRED_UV_NOT_RQD BITFIELD(17)
#define FIDO_OPTION_ALWAYS_UV BITFIELD(18)
typedef uint32_t fido_cbor_options_t;
// FIDO pin protocols
#define FIDO_PIN_PROTOCOL_1 BITFIELD(0)
#define FIDO_PIN_PROTOCOL_2 BITFIELD(1)
typedef uint8_t fido_cbor_pin_protocol_t;
// FIDO credential generation algorithms
// TODO: There are a lot of possibly supported algorithms
// See https://www.w3.org/TR/webauthn-2/#dictdef-publickeycredentialparameters
#define FIDO_CREDENTIAL_GENERATION_ES256 BITFIELD(0)
#define FIDO_CREDENTIAL_GENERATION_EdDSA BITFIELD(1)
#define FIDO_CREDENTIAL_GENERATION_ES384 BITFIELD(2)
#define FIDO_CREDENTIAL_GENERATION_ES512 BITFIELD(3)
#define FIDO_CREDENTIAL_GENERATION_ES256K BITFIELD(4)
#define FIDO_CREDENTIAL_GENERATION_PS256 BITFIELD(5)
#define FIDO_CREDENTIAL_GENERATION_RS256 BITFIELD(6)
typedef uint8_t fido_cbor_algorithm_t;
// According to the Webauthn Standard: https://w3c.github.io/webauthn/#typedefdef-cosealgorithmidentifier
// For COSE identifiers see https://www.iana.org/assignments/cose/cose.xhtml#algorithms
// EdDSA with Ed25519 as curve.
#define COSE_ALGORITHM_EdDSA (-8)
// P-256 curve.
#define COSE_ALGORITHM_ES256 (-7)
// P-384 curve.
#define COSE_ALGORITHM_ES384 (-35)
// P-512 curve.
#define COSE_ALGORITHM_ES512 (-36)
// secp256k1 curve.
#define COSE_ALGORITHM_ES256K (-47)
// RSA-PSS.
#define COSE_ALGORITHM_PS256 (-37)
// RSA-PKCS.
#define COSE_ALGORITHM_RS256 (-257)
// See https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#authenticatorGetInfo
typedef struct fido_cbor_info {
fido_cbor_version_t versions; /* list of supported versions */
fido_cbor_extension_t extensions; /* list of supported extensions */
fido_cbor_transport_t transports; /* list of supported transports */
unsigned char aaguid[16]; /* aaguid */
fido_cbor_options_t options; /* list of supported options */
uint64_t maxmsgsize; /* maximum message size */
// TODO: How to support authenticator preference?
fido_cbor_pin_protocol_t protocols; /* supported pin protocols */
// TODO: How to support authenticator preference?
fido_cbor_algorithm_t algorithms; /* list of supported algorithms */
uint64_t maxcredcntlst; /* max credentials in list */
uint64_t maxcredidlen; /* max credential ID length */
uint64_t fwversion; /* firmware version */
uint64_t maxcredbloblen; /* max credBlob length */
uint64_t maxlargeblob; /* max largeBlob array length */
} fido_cbor_info_t;
/**
* @brief Resets a CBOR info object.
*
* @param ci The info to reset.
*/
void fido_cbor_info_reset(fido_cbor_info_t *ci);