Commit graph

331 commits

Author SHA1 Message Date
Pol Henarejos
fa6292118d
Major refactor of USB CCID and USB HID interfaces. All interfaces are rewritten.
With this new scheme we ensure that:
- memcpy's are reduced.
- no race conditions are performed.
- critical areas are protected.
- callbacks are executed immediately.
- write's are executed after the positive report is received.
- no usb middle interface anymore.
- CCID and HID are totally independent.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-23 10:02:19 +02:00
Pol Henarejos
0745838e3f
Fix when receiving a packet in the middle of a transmission. RX shall be always processed.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-20 16:39:44 +02:00
Pol Henarejos
e1dd57067e
Fix when a keepalive packet collides with an ongoing transmission.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-20 16:39:08 +02:00
Pol Henarejos
38f0e2cc3a
select_app now invokes U2F or FIDO depending on the message.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-20 14:29:11 +02:00
Pol Henarejos
c1571c02f8
Increase vStack depending on the number of interfaces.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-20 12:43:01 +02:00
Pol Henarejos
d379a39bd6
keepalive should be sent without conditions and without reseting any buffer.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 16:44:58 +02:00
Pol Henarejos
7c76a71f33
Fix emulation build.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 13:18:03 +02:00
Pol Henarejos
93c491d72c
Fix thread cancel in ESP32.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 00:07:19 +02:00
Pol Henarejos
e2bd7fc50f
Add tinycbor to ESP32 build.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 00:06:49 +02:00
Pol Henarejos
11447371fe
Rewritten continuous flow for HID.
HID uses complete_cb to send the next packet and not the value returned by tud_write. Therefore, no other writes can happen in between of a writing packet if fails.

This ensures a proper interface multiplexing and continuous flow.

Also, the read pointer is used to multiplex usb packets.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 00:06:24 +02:00
Pol Henarejos
4e6ebc5c2a
TinyUSB uses interface argument for that driver. Therefore, for vendord driver, interface starts at 0, even the HID interface is used.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 00:03:30 +02:00
Pol Henarejos
8fdd1a2305
Add usb.h declarations.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 00:02:32 +02:00
Pol Henarejos
0f24d17456
thread management is now in usb stuff. It ensures to launch an apdu/cbor thread depending on the processed packet.
It also includes a usb_rx_more to advance the rx pointer. It is useful to multiplex usb packets.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 00:02:15 +02:00
Pol Henarejos
c9df3c22a0
driver_exec_finished_cont_hid() now accepts an itf argument.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-19 00:00:46 +02:00
Pol Henarejos
b3dbee5cd6
Increase vStack of core0 of ESP32.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-18 23:43:54 +02:00
Pol Henarejos
aad1387052
Increase vStack in core1 of ESP32.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-08-18 23:43:32 +02:00
Pol Henarejos
f4ad8e1af2
Fix idVendor, idProduct allocation for Pico Patcher.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-07-15 14:41:08 +02:00
Pol Henarejos
7e8807e054
Fix potential infinite loop when bad ASN1 is processed.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-07-08 10:53:19 +02:00
Pol Henarejos
eca200d2f1
Fix EF.DIR selection.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-28 22:04:52 +02:00
Pol Henarejos
5c11db54ae
BCD must be 2.0 for compatibility with windows.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-27 21:01:22 +02:00
Pol Henarejos
01d1de6074
Upgrade Pico Keys SDK to v6.0
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-22 20:56:03 +02:00
Pol Henarejos
447c68febd
Fix potential overflow.
In practice, it never may happen.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-22 19:03:37 +02:00
Pol Henarejos
2700163e1f
Better use phy opt mask.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-21 22:08:16 +02:00
Pol Henarejos
246ed5cf19
Fix when setting options and taking VIDPID values.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-21 22:07:28 +02:00
Pol Henarejos
f8480291fe
Upgrade to Mbedtls 3.6
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-21 21:29:14 +02:00
Pol Henarejos
a3ff9ba697
Merge pull request #2 from al-heisner/main
Change total flash pages (needed for pico-hsm)
2024-06-21 18:57:51 +02:00
al heisner
e920bff3f4 Change total flash pages (needed for pico-hsm) 2024-06-21 11:41:02 -05:00
Pol Henarejos
218441a45a
Added support for enable/disable Web CCID on the fly.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-19 23:28:55 +02:00
Pol Henarejos
a0e55ebfae
Fix tusb initialization.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-19 22:30:07 +02:00
Pol Henarejos
59597a0a68
Merge branch 'esp32' 2024-06-19 22:01:46 +02:00
Pol Henarejos
d458250887
Add PHY options and PHY_WCID.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-06-19 22:00:55 +02:00
Pol Henarejos
9a607707f0
Merge branch 'main' into esp32
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-05-31 17:12:12 +02:00
Pol Henarejos
e4e43dae04
Build x509 suite always if necessary.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-05-23 18:40:01 +02:00
Pol Henarejos
88071e1172
Some fixes.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-05-05 00:56:51 +02:00
Pol Henarejos
af20b4f894
Merge branch 'main' into esp32
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-28 19:26:08 +02:00
Pol Henarejos
f0074e5367
CCID and WCID structs not used.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-22 23:35:19 +02:00
Pol Henarejos
0535138211
Only T=1 protocol is supported.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-21 22:52:16 +02:00
Pol Henarejos
a5f19a1356
Only T=1 protocol is supported.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-21 22:51:17 +02:00
Pol Henarejos
ef196bf10b
Use new methods search_file() and file_put_data().
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-17 16:36:15 +02:00
Pol Henarejos
fc5f4299cc
Fix emulation build.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-17 11:56:54 +02:00
Pol Henarejos
6f2721aba3
Use persistent memory for storing dynamic VID/PID.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-17 11:42:57 +02:00
Pol Henarejos
cf1e076453
Introducing EF_PHY to store PHY (VIDPID and LED no.).
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-17 11:40:01 +02:00
Pol Henarejos
22d4e62952
Add procedure to compute unique ID at startup.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-17 11:31:11 +02:00
Pol Henarejos
019c5929a2
Remove carriage return \r for better debug.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-17 11:21:10 +02:00
Pol Henarejos
ade730ffb5
Introducing EF_PHY to store PHY (VIDPID and LED no.).
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-16 23:22:11 +02:00
Pol Henarejos
afc71f6942
Moving EF_VP to more generic EF_PHY, which stores PHY aspects from the chip.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-16 16:24:05 +02:00
Pol Henarejos
7b35000e11
Use persistent memory for storing dynamic VID/PID.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-16 16:18:28 +02:00
Pol Henarejos
6f7ab69a9d
Added support for dynamic USB_VID / USB_PID.
It can be changed on runtime without rebuilding or patching.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-16 00:04:23 +02:00
Pol Henarejos
b6b53010cc
Fix build for emulated interface.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-16 00:03:43 +02:00
Pol Henarejos
8d86a8c56b
Add procedure to compute unique ID at startup.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2024-04-15 23:44:51 +02:00