From f8590ba8c7df70a70a5c3d99d2b59b8889efe030 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 23 Sep 2022 18:07:27 +0200 Subject: [PATCH] Added CTAPHID_CANCEL support. Signed-off-by: Pol Henarejos --- src/usb/hid/hid.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/usb/hid/hid.c b/src/usb/hid/hid.c index e37b2e0..888b66b 100644 --- a/src/usb/hid/hid.c +++ b/src/usb/hid/hid.c @@ -146,6 +146,7 @@ uint32_t lock = 0; uint8_t thread_type = 0; //1 is APDU, 2 is CBOR extern void cbor_thread(); +extern bool cancel_button; int driver_process_usb_nopacket() { if (last_packet_time > 0 && last_packet_time+500 < board_millis()) { @@ -295,6 +296,12 @@ int driver_process_usb_packet(uint16_t read) { if (apdu_sent < 0) return ctap_error(-apdu_sent); } + else if (ctap_req->init.cmd == CTAPHID_CANCEL) { + ctap_error(0x2D); + msg_packet.len = msg_packet.current_len = 0; + last_packet_time = 0; + cancel_button = true; + } else { if (msg_packet.len == 0) return ctap_error(CTAP1_ERR_INVALID_CMD);