CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
usb_descriptors.h
Go to the documentation of this file.
1// USB Descriptors for CDC Badge
2// Composite Device: CDC + optional FIDO HID + optional Keyboard HID + optional CCID
3
4#pragma once
5
6#include <stdint.h>
7extern "C" {
8#include "tusb.h"
9}
10
11// USB Device IDs
12// When CCID is enabled, use Gemalto VID/PID for libccid whitelist compatibility
13// (Same approach as pico-openpgp, Rugart, and other DIY OpenPGP cards)
14#define USB_VID_GEMALTO 0x08E6 // Gemalto
15#define USB_PID_GEMALTO 0x4433 // GemPC433 (libccid whitelisted)
16#define USB_VID_ESPRESSIF 0x303A // Espressif Systems
17#define USB_PID_BADGE 0xBADE // CDC Badge custom PID
18// OnlyKey OTP IDs, whitelisted by KeePassXC for HMAC-SHA1 challenge-response
19// (keepassxreboot/keepassxc commit e4326fb: yk_open_key_vid_pid(0x1d50, {0x60fc})).
20// mod_otphid presents these so KeePassXC/ykinfo recognize the OTP HID interface.
21#define USB_VID_ONLYKEY 0x1D50 // OpenMoko / Great Scott Gadgets (OnlyKey)
22#define USB_PID_ONLYKEY 0x60FC // OnlyKey
23#define USB_BCD 0x0200
24
25// String Descriptor Indices (fixed strings only, module strings are dynamic)
26enum {
32 STR_MSC, // Mass-storage interface name (when MSC active)
33 STR_DYNAMIC_BASE // Module interface names start here
34};
35
36// Endpoint Numbers
37// CDC always uses: 0x81 (notif), 0x02 (out), 0x82 (in)
38#define EP_CDC_NOTIF 0x81 // CDC Notification IN
39#define EP_CDC_OUT 0x02 // CDC Data OUT
40#define EP_CDC_IN 0x82 // CDC Data IN
41
42// Endpoint Sizes
43#define EP_CDC_NOTIF_SIZE 8
44#define EP_CDC_SIZE 64
45#define EP_FIDO_SIZE 64 // CTAPHID packets are 64 bytes
46#define EP_KEYBOARD_SIZE 8 // Keyboard reports are 8 bytes
47#define EP_CCID_SIZE 64 // CCID SmartCard packets
48
49// HID Report ID
50#define REPORT_ID_KEYBOARD 1 // Keyboard uses Report ID 1
51
52// CCID SmartCard Descriptor (54 bytes class descriptor + endpoints)
53// CCID Class Descriptor Macro (from legacy)
54#define TUD_CCID_DESC_LEN 54
55#define TUD_CCID_TOTAL_LEN (9 + TUD_CCID_DESC_LEN + 7 + 7) // Interface + Class + 2x Endpoint
56
57#define TUD_CCID_DESCRIPTOR(_itfnum, _stridx, _epout, _epin, _epsize) \
58 /* Interface */ \
59 9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_SMART_CARD, 0, 0, _stridx, \
60 /* CCID Class Descriptor (54 bytes) */ \
61 TUD_CCID_DESC_LEN, 0x21, /* bDescriptorType: CCID Functional */ \
62 0x10, 0x01, /* bcdCCID: CCID 1.1 */ \
63 0x00, /* bMaxSlotIndex: 1 slot */ \
64 0x07, /* bVoltageSupport: 5V, 3V, 1.8V */ \
65 0x02, 0x00, 0x00, 0x00, /* dwProtocols: T=1 */ \
66 0xA0, 0x0F, 0x00, 0x00, /* dwDefaultClock: 4000 kHz */ \
67 0xA0, 0x0F, 0x00, 0x00, /* dwMaximumClock: 4000 kHz */ \
68 0x00, /* bNumClockSupported */ \
69 0x00, 0x2A, 0x00, 0x00, /* dwDataRate: 10752 bps */ \
70 0x00, 0x2A, 0x00, 0x00, /* dwMaxDataRate: 10752 bps */ \
71 0x00, /* bNumDataRatesSupported */ \
72 0xFE, 0x00, 0x00, 0x00, /* dwMaxIFSD: 254 */ \
73 0x00, 0x00, 0x00, 0x00, /* dwSynchProtocols: none */ \
74 0x00, 0x00, 0x00, 0x00, /* dwMechanical: none */ \
75 0xFE, 0x00, 0x04, 0x00, /* dwFeatures: auto config/activation/voltage/clock/baud/negotiation/PPS, extended APDU */ \
76 0x0F, 0x01, 0x00, 0x00, /* dwMaxCCIDMessageLength: 271 */ \
77 0xFF, /* bClassGetResponse */ \
78 0xFF, /* bClassEnvelope */ \
79 0x00, 0x00, /* wLcdLayout: none */ \
80 0x00, /* bPINSupport: none */ \
81 0x01, /* bMaxCCIDBusySlots: 1 */ \
82 /* Bulk OUT Endpoint */ \
83 7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0, \
84 /* Bulk IN Endpoint */ \
85 7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0
@ STR_PRODUCT
@ STR_MANUFACTURER
@ STR_MSC
@ STR_DYNAMIC_BASE
@ STR_CDC
@ STR_LANGID
@ STR_SERIAL