From f3407aab5c14170e140fb31a3e921863c1f2a320 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Wed, 26 Aug 2026 13:10:48 +0200 Subject: [PATCH] Fix PIV button handle Signed-off-by: Pol Henarejos --- src/openpgp/piv.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/openpgp/piv.c b/src/openpgp/piv.c index 8e7d4e9..b498bc0 100644 --- a/src/openpgp/piv.c +++ b/src/openpgp/piv.c @@ -35,7 +35,6 @@ #include "mbedtls/constant_time.h" #include "key_container.h" #include "openpgp.h" -#include "button.h" #include "usb.h" #define PIV_ALGO_3DES 0x03 @@ -77,15 +76,12 @@ #define IS_KEY(x) ((IS_ACTIVE((x))) || (IS_RETIRED((x)))) #ifndef ENABLE_EMULATION -extern void execute_tasks(void); - static bool piv_button_wait(void) { - uint32_t event = 0; - button_wait_start(); - while (is_req_button_pending()) { - execute_tasks(); - } - queue_remove_blocking(&usb_to_card_q, &event); + uint32_t event = EV_PRESS_BUTTON; + queue_add_blocking(&card_to_usb_q, &event); + do { + queue_remove_blocking(&usb_to_card_q, &event); + } while (event != EV_BUTTON_PRESSED && event != EV_BUTTON_TIMEOUT && event != EV_BUTTON_CANCELLED); return event != EV_BUTTON_PRESSED; } #endif