Embedded SDK
Embedded SDK
u2f_transport.h
Go to the documentation of this file.
1 
2 /*******************************************************************************
3  * Ledger Nano S - Secure firmware
4  * (c) 2022 Ledger
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  ********************************************************************************/
18 
19 #ifndef __U2F_TRANSPORT_H__
20 
21 #define __U2F_TRANSPORT_H__
22 
23 #include "u2f_service.h"
24 
25 // Shared commands
26 #define U2F_CMD_PING 0x81
27 #define U2F_CMD_MSG 0x83
28 #define CTAP2_CMD_CBOR 0x90 // FIDO2
29 #define CTAP2_CMD_CANCEL 0x91 // FIDO2
30 
31 // USB only commands
32 #define U2F_CMD_INIT 0x86
33 #define U2F_CMD_LOCK 0x84
34 #define U2F_CMD_WINK 0x88
35 
36 // BLE only commands
37 #define U2F_CMD_KEEPALIVE 0x82
38 #define KEEPALIVE_REASON_PROCESSING 0x01
39 #define KEEPALIVE_REASON_TUP_NEEDED 0x02
40 
41 #define U2F_STATUS_ERROR 0xBF
42 #define CTAP2_STATUS_KEEPALIVE 0xBB // FIDO2
43 
44 // Shared errors
45 #define ERROR_NONE 0x00
46 #define ERROR_INVALID_CMD 0x01
47 #define ERROR_INVALID_PAR 0x02
48 #define ERROR_INVALID_LEN 0x03
49 #define ERROR_INVALID_SEQ 0x04
50 #define ERROR_MSG_TIMEOUT 0x05
51 #define ERROR_OTHER 0x7f
52 // USB only errors
53 #define ERROR_CHANNEL_BUSY 0x06
54 #define ERROR_LOCK_REQUIRED 0x0a
55 #define ERROR_INVALID_CID 0x0b
56 // CTAP2 errors
57 #define ERROR_CBOR_UNEXPECTED_TYPE 0x11
58 #define ERROR_INVALID_CBOR 0x12
59 #define ERROR_MISSING_PARAMETER 0x14
60 #define ERROR_LIMIT_EXCEEDED 0x15
61 #define ERROR_UNSUPPORTED_EXTENSION 0x16
62 #define ERROR_CREDENTIAL_EXCLUDED 0x19
63 #define ERROR_PROCESSING 0x21
64 #define ERROR_INVALID_CREDENTIAL 0x22
65 #define ERROR_USER_ACTION_PENDING 0x23
66 #define ERROR_OPERATION_PENDING 0x24
67 #define ERROR_NO_OPERATIONS 0x25
68 #define ERROR_UNSUPPORTED_ALGORITHM 0x26
69 #define ERROR_OPERATION_DENIED 0x27
70 #define ERROR_KEY_STORE_FULL 0x28
71 #define ERROR_NO_OPERATION_PENDING 0x2A
72 #define ERROR_UNSUPPORTED_OPTION 0x2B
73 #define ERROR_INVALID_OPTION 0x2C
74 #define ERROR_KEEPALIVE_CANCEL 0x2D
75 #define ERROR_NO_CREDENTIALS 0x2E
76 #define ERROR_USER_ACTION_TIMEOUT 0x2F
77 #define ERROR_NOT_ALLOWED 0x30
78 #define ERROR_PIN_INVALID 0x31
79 #define ERROR_PIN_BLOCKED 0x32
80 #define ERROR_PIN_AUTH_INVALID 0x33
81 #define ERROR_PIN_AUTH_BLOCKED 0x34
82 #define ERROR_PIN_NOT_SET 0x35
83 #define ERROR_PIN_REQUIRED 0x36
84 #define ERROR_PIN_POLICY_VIOLATION 0x37
85 #define ERROR_PIN_TOKEN_EXPIRED 0x38
86 #define ERROR_REQUEST_TOO_LARGE 0x39
87 #define ERROR_ACTION_TIMEOUT 0x3A
88 #define ERROR_UP_REQUIRED 0x3B
89 // Proprietary errors
90 #define ERROR_PROP_UNKNOWN_COMMAND 0x80
91 #define ERROR_PROP_COMMAND_TOO_LONG 0x81
92 #define ERROR_PROP_INVALID_CONTINUATION 0x82
93 #define ERROR_PROP_UNEXPECTED_CONTINUATION 0x83
94 #define ERROR_PROP_CONTINUATION_OVERFLOW 0x84
95 #define ERROR_PROP_MESSAGE_TOO_SHORT 0x85
96 #define ERROR_PROP_UNCONSISTENT_MSG_LENGTH 0x86
97 #define ERROR_PROP_UNSUPPORTED_MSG_APDU 0x87
98 #define ERROR_PROP_INVALID_DATA_LENGTH_APDU 0x88
99 #define ERROR_PROP_INTERNAL_ERROR_APDU 0x89
100 #define ERROR_PROP_INVALID_PARAMETERS_APDU 0x8A
101 #define ERROR_PROP_INVALID_DATA_APDU 0x8B
102 #define ERROR_PROP_DEVICE_NOT_SETUP 0x8C
103 #define ERROR_PROP_MEDIA_MIXED 0x8D
104 #define ERROR_PROP_RPID_MEDIA_DENIED 0x8E
105 
113  uint8_t *message_buffer,
114  uint16_t message_buffer_length);
115 
120 
125  uint8_t *buffer,
126  uint16_t size,
127  u2f_transport_media_t media);
128 
133 
138 
143 
144 #endif
u2f_transport_media_t
Definition: u2f_service.h:47
void u2f_transport_sent(u2f_service_t *service, u2f_transport_media_t media)
bool u2f_is_channel_forbidden(uint8_t *channel)
void u2f_transport_init(u2f_service_t *service, uint8_t *message_buffer, uint16_t message_buffer_length)
bool u2f_is_channel_broadcast(uint8_t *channel)
void u2f_transport_received(u2f_service_t *service, uint8_t *buffer, uint16_t size, u2f_transport_media_t media)
void u2f_transport_ctap2_send_keepalive(u2f_service_t *service, uint8_t reason)
unsigned short uint16_t
Definition: usbd_conf.h:54
unsigned char uint8_t
Definition: usbd_conf.h:53