|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <cstdint>#include <cstddef>Go to the source code of this file.
Classes | |
| struct | cdc::mod_fido2::ctaphid_channel_t |
Namespaces | |
| namespace | cdc |
| namespace | cdc::mod_fido2 |
Macros | |
| #define | CTAPHID_PACKET_SIZE 64 |
| #define | CTAPHID_INIT_DATA 57 |
| #define | CTAPHID_CONT_DATA 59 |
| #define | CTAPHID_MAX_MSG_SIZE 2048 |
| #define | CTAPHID_BROADCAST_CID 0xFFFFFFFF |
| #define | CTAPHID_PING 0x01 |
| #define | CTAPHID_MSG 0x03 |
| #define | CTAPHID_LOCK 0x04 |
| #define | CTAPHID_INIT 0x06 |
| #define | CTAPHID_WINK 0x08 |
| #define | CTAPHID_CBOR 0x10 |
| #define | CTAPHID_CANCEL 0x11 |
| #define | CTAPHID_KEEPALIVE 0x3B |
| #define | CTAPHID_ERROR 0x3F |
| #define | CTAPHID_ERR_INVALID_CMD 0x01 |
| #define | CTAPHID_ERR_INVALID_PAR 0x02 |
| #define | CTAPHID_ERR_INVALID_LEN 0x03 |
| #define | CTAPHID_ERR_INVALID_SEQ 0x04 |
| #define | CTAPHID_ERR_MSG_TIMEOUT 0x05 |
| #define | CTAPHID_ERR_CHANNEL_BUSY 0x06 |
| #define | CTAPHID_ERR_LOCK_REQUIRED 0x0A |
| #define | CTAPHID_ERR_INVALID_CHANNEL 0x0B |
| #define | CTAPHID_ERR_OTHER 0x7F |
| #define | CTAPHID_VENDOR_FIRST 0x40 |
| #define | CTAPHID_VENDOR_LAST 0x7F |
| #define | CTAPHID_STATUS_PROCESSING 0x01 |
| #define | CTAPHID_STATUS_UPNEEDED 0x02 |
| #define | CTAPHID_CAP_WINK 0x01 |
| #define | CTAPHID_CAP_CBOR 0x04 |
Functions | |
| bool | ctaphid_init (void) |
| Initializes CTAPHID transport state and synchronization primitives. | |
| bool | ctaphid_process_packet (const uint8_t *packet) |
| Processes one incoming 64-byte CTAPHID packet. | |
| bool | ctaphid_has_response (void) |
| Indicates whether any channel has a response queued for host retrieval. | |
| bool | ctaphid_get_response_packet (uint8_t *packet) |
| Retrieves the next response HID packet from a per-channel response queue. | |
| void | ctaphid_send_keepalive (uint32_t cid, uint8_t status) |
| Sends a CTAPHID KEEPALIVE packet immediately over USB. | |
| void | ctaphid_send_error (uint32_t cid, uint8_t error) |
| Queues a CTAPHID ERROR response for the given channel. | |
| void | ctaphid_check_timeout (void) |
| Expires active channels whose message assembly timeout elapsed. | |
| uint32_t | ctaphid_get_current_cid (void) |
| Returns the channel identifier of the currently processed request. | |
| bool | ctaphid_is_busy (void) |
| Reports whether any CTAPHID channel currently has an active transaction. | |
| void | ctaphid_get_cmd_counts (uint32_t *cbor_count, uint32_t *msg_count) |
| Returns cumulative counters for CTAPHID CBOR and MSG commands. | |
| void | ctaphid_reset_cmd_counts (void) |
| Resets CTAPHID command counters. | |
| #define CTAPHID_BROADCAST_CID 0xFFFFFFFF |
Definition at line 18 of file ctaphid.h.
Referenced by allocate_cid(), ctaphid_send_error(), and handle_init().
| #define CTAPHID_CANCEL 0x11 |
Definition at line 27 of file ctaphid.h.
Referenced by process_complete_message().
| #define CTAPHID_CAP_CBOR 0x04 |
Definition at line 52 of file ctaphid.h.
Referenced by handle_init().
| #define CTAPHID_CAP_WINK 0x01 |
Definition at line 51 of file ctaphid.h.
Referenced by handle_init().
| #define CTAPHID_CBOR 0x10 |
Definition at line 26 of file ctaphid.h.
Referenced by handle_cbor(), prepare_response(), and process_complete_message().
| #define CTAPHID_CONT_DATA 59 |
Definition at line 15 of file ctaphid.h.
Referenced by build_cont_packet(), ctaphid_get_response_packet(), and ctaphid_process_packet().
| #define CTAPHID_ERR_CHANNEL_BUSY 0x06 |
Definition at line 37 of file ctaphid.h.
Referenced by ctaphid_process_packet().
| #define CTAPHID_ERR_INVALID_CHANNEL 0x0B |
Definition at line 39 of file ctaphid.h.
Referenced by ctaphid_process_packet(), and handle_cbor().
| #define CTAPHID_ERR_INVALID_CMD 0x01 |
Definition at line 32 of file ctaphid.h.
Referenced by process_complete_message().
| #define CTAPHID_ERR_INVALID_LEN 0x03 |
Definition at line 34 of file ctaphid.h.
Referenced by ctaphid_process_packet(), handle_cbor(), and handle_init().
| #define CTAPHID_ERR_INVALID_SEQ 0x04 |
Definition at line 35 of file ctaphid.h.
Referenced by ctaphid_process_packet().
| #define CTAPHID_ERR_MSG_TIMEOUT 0x05 |
Definition at line 36 of file ctaphid.h.
Referenced by ctaphid_check_timeout().
| #define CTAPHID_ERR_OTHER 0x7F |
Definition at line 40 of file ctaphid.h.
Referenced by handle_init().
| #define CTAPHID_ERROR 0x3F |
Definition at line 29 of file ctaphid.h.
Referenced by ctaphid_send_error().
| #define CTAPHID_INIT 0x06 |
Definition at line 24 of file ctaphid.h.
Referenced by ctaphid_process_packet(), handle_init(), and process_complete_message().
| #define CTAPHID_INIT_DATA 57 |
Definition at line 14 of file ctaphid.h.
Referenced by build_init_packet(), ctaphid_get_response_packet(), and ctaphid_process_packet().
| #define CTAPHID_KEEPALIVE 0x3B |
Definition at line 28 of file ctaphid.h.
Referenced by ctaphid_send_keepalive().
| #define CTAPHID_MAX_MSG_SIZE 2048 |
Definition at line 16 of file ctaphid.h.
Referenced by ctaphid_process_packet(), and init_channel_slot().
| #define CTAPHID_MSG 0x03 |
Definition at line 22 of file ctaphid.h.
Referenced by process_complete_message().
| #define CTAPHID_PACKET_SIZE 64 |
Definition at line 13 of file ctaphid.h.
Referenced by build_cont_packet(), build_init_packet(), ctaphid_send_keepalive(), cdc::mod_fido2::fido2_usb_read(), cdc::mod_fido2::fido2_usb_write(), cdc::mod_fido2::onFidoSetReport(), and cdc::mod_fido2::Fido2Module::start().
| #define CTAPHID_PING 0x01 |
Definition at line 21 of file ctaphid.h.
Referenced by handle_ping(), and process_complete_message().
| #define CTAPHID_STATUS_PROCESSING 0x01 |
Definition at line 47 of file ctaphid.h.
Referenced by cdc::mod_fido2::create_credential_and_respond().
| #define CTAPHID_STATUS_UPNEEDED 0x02 |
Definition at line 48 of file ctaphid.h.
Referenced by cdc::mod_fido2::fido2_ui_user_presence_callback(), and wait_for_user_presence().
| #define CTAPHID_VENDOR_FIRST 0x40 |
Definition at line 43 of file ctaphid.h.
Referenced by process_complete_message().
| #define CTAPHID_VENDOR_LAST 0x7F |
Definition at line 44 of file ctaphid.h.
Referenced by process_complete_message().
| #define CTAPHID_WINK 0x08 |
Definition at line 25 of file ctaphid.h.
Referenced by handle_wink(), and process_complete_message().
| void ctaphid_check_timeout | ( | void | ) |
Expires active channels whose message assembly timeout elapsed.
Definition at line 730 of file ctaphid.cpp.
References CTAPHID_ERR_MSG_TIMEOUT, CTAPHID_MAX_CHANNELS, CTAPHID_MSG_TIMEOUT_MS, ctaphid_send_error(), g_ctaphid, LOG_W, and TAG.
Referenced by fido2_task().
| void ctaphid_get_cmd_counts | ( | uint32_t * | cbor_count, |
| uint32_t * | msg_count ) |
Returns cumulative counters for CTAPHID CBOR and MSG commands.
| cbor_count | Optional destination for CBOR command count. |
| msg_count | Optional destination for MSG/U2F command count. |
Definition at line 456 of file ctaphid.cpp.
References g_ctaphid.
| uint32_t ctaphid_get_current_cid | ( | void | ) |
Returns the channel identifier of the currently processed request.
Definition at line 753 of file ctaphid.cpp.
References g_ctaphid.
Referenced by ctap2_send_keepalive(), cdc::mod_fido2::fido2_ui_user_presence_callback(), and wait_for_user_presence().
| bool ctaphid_get_response_packet | ( | uint8_t * | packet | ) |
Retrieves the next response HID packet from a per-channel response queue.
| packet | Destination buffer for the response packet. |
Definition at line 634 of file ctaphid.cpp.
References build_cont_packet(), build_init_packet(), cancelled, ctap2_is_cancelled(), CTAPHID_CONT_DATA, CTAPHID_INIT_DATA, g_ctaphid, LOG_W, pick_next_response_channel(), and TAG.
Referenced by fido2_task().
| bool ctaphid_has_response | ( | void | ) |
Indicates whether any channel has a response queued for host retrieval.
Definition at line 607 of file ctaphid.cpp.
References CTAPHID_MAX_CHANNELS, and g_ctaphid.
Referenced by fido2_task().
| bool ctaphid_init | ( | void | ) |
Initializes CTAPHID transport state and synchronization primitives.
Definition at line 434 of file ctaphid.cpp.
References g_ctaphid, LOG_E, LOG_I, and TAG.
Referenced by fido2_init().
| bool ctaphid_is_busy | ( | void | ) |
Reports whether any CTAPHID channel currently has an active transaction.
Definition at line 761 of file ctaphid.cpp.
References CTAPHID_MAX_CHANNELS, and g_ctaphid.
| bool ctaphid_process_packet | ( | const uint8_t * | packet | ) |
Processes one incoming 64-byte CTAPHID packet.
| packet | HID packet buffer. |
Definition at line 474 of file ctaphid.cpp.
References CTAPHID_CONT_DATA, CTAPHID_DEBUG_PACKETS, CTAPHID_ERR_CHANNEL_BUSY, CTAPHID_ERR_INVALID_CHANNEL, CTAPHID_ERR_INVALID_LEN, CTAPHID_ERR_INVALID_SEQ, CTAPHID_INIT, CTAPHID_INIT_DATA, CTAPHID_MAX_MSG_SIZE, CTAPHID_RATE_LIMIT_MAX_CMDS, CTAPHID_RATE_LIMIT_WINDOW_MS, ctaphid_send_error(), find_channel(), g_ctaphid, LOG_D, LOG_W, process_complete_message(), and TAG.
Referenced by fido2_task().
| void ctaphid_reset_cmd_counts | ( | void | ) |
| void ctaphid_send_error | ( | uint32_t | cid, |
| uint8_t | error ) |
Queues a CTAPHID ERROR response for the given channel.
| cid | Channel identifier. |
| error | CTAPHID error code. |
Definition at line 703 of file ctaphid.cpp.
References alloc_channel(), CTAPHID_BROADCAST_CID, CTAPHID_ERROR, CTAPHID_MAX_CHANNELS, find_channel(), g_ctaphid, LOG_W, prepare_response_on(), and TAG.
Referenced by ctaphid_check_timeout(), ctaphid_process_packet(), handle_cbor(), handle_init(), and process_complete_message().
| void ctaphid_send_keepalive | ( | uint32_t | cid, |
| uint8_t | status ) |
Sends a CTAPHID KEEPALIVE packet immediately over USB.
| cid | Channel identifier. |
| status | CTAPHID keepalive status byte. |
Definition at line 689 of file ctaphid.cpp.
References build_init_packet(), CTAPHID_KEEPALIVE, CTAPHID_PACKET_SIZE, and fido2_usb_write().
Referenced by ctap2_send_keepalive(), cdc::mod_fido2::fido2_ui_user_presence_callback(), and wait_for_user_presence().