I'm trying to implement a FIDO2 authenticator with an ESP32-S3.
To get started I used the sample from "libraries/USB/examples/CustomHIDDevice/CustomHIDDevice.ino" - and adjusted the report_descriptor for a FIDO2 device, likes this:
Code: Select all
#define HID_VENDOR_REPORT_SIZE 64
uint8_t HID_ReportDescriptor[] = {HID_USAGE_PAGE_N(HID_USAGE_PAGE_FIDO,2),
HID_USAGE(HID_USAGE_FIDO_U2FHID),
HID_COLLECTION(HID_COLLECTION_APPLICATION),
HID_REPORT_ID(1)
HID_USAGE(HID_USAGE_FIDO_DATA_IN),/* Input */
HID_LOGICAL_MIN(0x00),
HID_LOGICAL_MAX(0xff),
HID_REPORT_SIZE(8),
HID_REPORT_COUNT(HID_VENDOR_REPORT_SIZE),
HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE),
HID_USAGE(HID_USAGE_FIDO_DATA_OUT),/* Output */
HID_LOGICAL_MIN(0x00),
HID_LOGICAL_MAX(0xff),
HID_REPORT_SIZE(8),
HID_REPORT_COUNT(HID_VENDOR_REPORT_SIZE),
HID_OUTPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE),
HID_COLLECTION_END
The code compiles and runs. A webpage like https://webauthn.io even detects my "FIDO2 authenticator" and starts talking with it, but the communication happens with report_id 255 - which in the end means, that the USB stack does not find my device and therefore does not propagate the data to my code.
The debug output shows that the device is (correctly?) setup with report_id 6 ... but communication happens with report_id 255 ...
15:08:53.893 > [ 93][D][USBHID.cpp:65] tinyusb_enable_hid_device(): Device[0] len: 46
15:08:54.123 > [ 335][esp32-hal-psram.c:96] psramInit(): PSRAM enabled
15:08:54.632 > [ 841][D][esp32-hal-tinyusb.c:569] tinyusb_load_enabled_interfaces(): Load Done: if_num: 1, descr_len: 41, if_mask: 0x4
15:08:54.632 > [ 842][fidodevice.cpp:111] begin(): [fidodevice.cpp]
15:08:54.643 > [ 846][fidodevice.cpp:95] setRxBufferSize(): [fidodevice.cpp]
15:08:54.643 > [ 852][main.cpp:213] setup(): [main.cpp] ready to go!
15:08:55.190 > [ 1399][V][USBHID.cpp:287] tud_hid_set_idle_cb(): instance: 0, idle_rate:0
15:08:55.190 > [ 1399][V][USBHID.cpp:263] tud_hid_descriptor_report_cb(): instance: 0
15:08:55.201 > [ 1401][fidodevice.cpp:81] _onGetDescriptor(): [fidodevice.cpp]
15:08:55.201 > [ 1408][D][USBHID.cpp:214] tinyusb_load_enabled_hid_devices(): Loaded HID Desriptor with the following reports:
15:08:55.212 > [ 1417][D][USBHID.cpp:223] tinyusb_load_enabled_hid_devices(): ID: 6, Type: INPUT, Size: 63, Usage: VENDOR
15:08:55.223 > [ 1427][D][USBHID.cpp:223] tinyusb_load_enabled_hid_devices(): ID: 6, Type: OUTPUT, Size: 63, Usage: VENDOR
15:08:55.235 > [ 1437][D][USBHID.cpp:223] tinyusb_load_enabled_hid_devices(): ID: 6, Type: FEATURE, Size: 63, Usage: VENDOR
15:09:10.249 > [ 16458][D][USBHID.cpp:118] tinyusb_on_set_output(): device not found 0
15:09:10.249 > [ 16458][D][USBHID.cpp:118] tinyusb_on_set_output(): device not found 255
15:09:10.260 > [ 16460][D][USBHID.cpp:316] tud_hid_set_report_cb(): instance: 0, report_id: 255, report_type: OUTPUT, bufsize: 62
15:09:10.271 > [ 16470][D][USBHID.cpp:319] tud_hid_set_report_cb(): ff
15:09:10.271 > [ 16475][D][USBHID.cpp:319] tud_hid_set_report_cb(): ff
15:09:10.271 > [ 16480][D][USBHID.cpp:319] tud_hid_set_report_cb(): ff
15:09:10.282 > [ 16485][D][USBHID.cpp:319] tud_hid_set_report_cb(): ff
15:09:10.282 > [ 16490][D][USBHID.cpp:319] tud_hid_set_report_cb(): 86
(I have modified USBHID.cpp to show the received data ... this is actually data sent by the browser for the FIDO2 protocol).
Is this a bug in the USB stack? Or am I missing anything vital here?
Thanks for any hint!