From dec2ce145822fd80eab61ba0d0d90c23b3116149 Mon Sep 17 00:00:00 2001 From: Stephane Portron Date: Tue, 9 Jan 2024 10:05:33 +0100 Subject: [PATCH] Cache user presence request type. --- include/u2f_process.h | 1 + src/u2f_processing.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/u2f_process.h b/include/u2f_process.h index 0df70d1..7278e9b 100644 --- a/include/u2f_process.h +++ b/include/u2f_process.h @@ -20,6 +20,7 @@ #define __U2F_PROCESS_H__ typedef struct u2f_data_t { + uint8_t user_presence_request_type; uint8_t challenge_param[32]; uint8_t application_param[32]; uint8_t nonce[CREDENTIAL_NONCE_SIZE]; diff --git a/src/u2f_processing.c b/src/u2f_processing.c index 7975e14..bdc3e7a 100644 --- a/src/u2f_processing.c +++ b/src/u2f_processing.c @@ -400,7 +400,7 @@ static int u2f_prepare_sign_response(void) { } static int u2f_process_user_presence_confirmed(void) { - switch (G_io_apdu_buffer[OFFSET_INS]) { + switch (globals_get_u2f_data()->user_presence_request_type) { case FIDO_INS_ENROLL: return u2f_prepare_enroll_response(); @@ -436,6 +436,7 @@ static unsigned int u2f_callback_confirm(const bagl_element_t *element) { UNUSED(element); uint16_t tx = u2f_process_user_presence_confirmed(); + PRINTF("u2f_callback_confirm %d\n", tx); io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); ui_idle(); return 0; // DO NOT REDISPLAY THE BUTTON @@ -659,6 +660,7 @@ static void u2f_handle_apdu_enroll(unsigned char *flags, unsigned short *tx, uin sizeof(reg_req->application_param)); #ifndef HAVE_NO_USER_PRESENCE_CHECK + globals_get_u2f_data()->user_presence_request_type = G_io_apdu_buffer[OFFSET_INS]; if (G_io_u2f.media == U2F_MEDIA_USB) { u2f_message_set_autoreply_wait_user_presence(&G_io_u2f, true); } @@ -726,6 +728,7 @@ static void u2f_handle_apdu_sign(unsigned char *flags, unsigned short *tx, uint3 sizeof(auth_req_base->application_param)); #ifndef HAVE_NO_USER_PRESENCE_CHECK + globals_get_u2f_data()->user_presence_request_type = G_io_apdu_buffer[OFFSET_INS]; if (G_io_u2f.media == U2F_MEDIA_USB) { u2f_message_set_autoreply_wait_user_presence(&G_io_u2f, true); }