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_DYNAMIC_BASE // Module interface names start here
33};
34
35// Endpoint Numbers
36// CDC always uses: 0x81 (notif), 0x02 (out), 0x82 (in)
37#define EP_CDC_NOTIF 0x81 // CDC Notification IN
38#define EP_CDC_OUT 0x02 // CDC Data OUT
39#define EP_CDC_IN 0x82 // CDC Data IN
40
41// Endpoint Sizes
42#define EP_CDC_NOTIF_SIZE 8
43#define EP_CDC_SIZE 64
44#define EP_FIDO_SIZE 64 // CTAPHID packets are 64 bytes
45#define EP_KEYBOARD_SIZE 8 // Keyboard reports are 8 bytes
46#define EP_CCID_SIZE 64 // CCID SmartCard packets
47
48// HID Report ID
49#define REPORT_ID_KEYBOARD 1 // Keyboard uses Report ID 1
50
51// CCID SmartCard Descriptor (54 bytes class descriptor + endpoints)
52// CCID Class Descriptor Macro (from legacy)
53#define TUD_CCID_DESC_LEN 54
54#define TUD_CCID_TOTAL_LEN (9 + TUD_CCID_DESC_LEN + 7 + 7) // Interface + Class + 2x Endpoint
55
56#define TUD_CCID_DESCRIPTOR(_itfnum, _stridx, _epout, _epin, _epsize) \
57 /* Interface */ \
58 9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_SMART_CARD, 0, 0, _stridx, \
59 /* CCID Class Descriptor (54 bytes) */ \
60 TUD_CCID_DESC_LEN, 0x21, /* bDescriptorType: CCID Functional */ \
61 0x10, 0x01, /* bcdCCID: CCID 1.1 */ \
62 0x00, /* bMaxSlotIndex: 1 slot */ \
63 0x07, /* bVoltageSupport: 5V, 3V, 1.8V */ \
64 0x02, 0x00, 0x00, 0x00, /* dwProtocols: T=1 */ \
65 0xA0, 0x0F, 0x00, 0x00, /* dwDefaultClock: 4000 kHz */ \
66 0xA0, 0x0F, 0x00, 0x00, /* dwMaximumClock: 4000 kHz */ \
67 0x00, /* bNumClockSupported */ \
68 0x00, 0x2A, 0x00, 0x00, /* dwDataRate: 10752 bps */ \
69 0x00, 0x2A, 0x00, 0x00, /* dwMaxDataRate: 10752 bps */ \
70 0x00, /* bNumDataRatesSupported */ \
71 0xFE, 0x00, 0x00, 0x00, /* dwMaxIFSD: 254 */ \
72 0x00, 0x00, 0x00, 0x00, /* dwSynchProtocols: none */ \
73 0x00, 0x00, 0x00, 0x00, /* dwMechanical: none */ \
74 0xFE, 0x00, 0x04, 0x00, /* dwFeatures: auto config/activation/voltage/clock/baud/negotiation/PPS, extended APDU */ \
75 0x0F, 0x01, 0x00, 0x00, /* dwMaxCCIDMessageLength: 271 */ \
76 0xFF, /* bClassGetResponse */ \
77 0xFF, /* bClassEnvelope */ \
78 0x00, 0x00, /* wLcdLayout: none */ \
79 0x00, /* bPINSupport: none */ \
80 0x01, /* bMaxCCIDBusySlots: 1 */ \
81 /* Bulk OUT Endpoint */ \
82 7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0, \
83 /* Bulk IN Endpoint */ \
84 7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0
@ STR_PRODUCT
@ STR_MANUFACTURER
@ STR_DYNAMIC_BASE
@ STR_CDC
@ STR_LANGID
@ STR_SERIAL