From 9c226f854b4044000f3453e7b39cba8888923ece Mon Sep 17 00:00:00 2001 From: Lucas PASCAL Date: Tue, 21 May 2024 16:15:33 +0200 Subject: [PATCH] [tmp] --- lib_stusb_impl/u2f_impl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_stusb_impl/u2f_impl.c b/lib_stusb_impl/u2f_impl.c index 634ae9a5e..c6a87aec7 100644 --- a/lib_stusb_impl/u2f_impl.c +++ b/lib_stusb_impl/u2f_impl.c @@ -280,6 +280,18 @@ int u2f_get_cmd_msg_data_length(const uint8_t *buffer, uint16_t length) return 0; } + if (length == APDU_MIN_HEADER + 2) { + // Short encoding, with either: + // - both Lc (==0) and Le, or + // - Lc == 1 and 1B of data, no Le + if (buffer[4] == 0 || buffer[4] == 1) { + return buffer[4]; + } + else { + return -1; + } + } + if (length < APDU_MIN_HEADER + 3) { // Short encoding or bad length // We don't support short encoding