diff --git a/include/ctap2.h b/include/ctap2.h index 9878cb3c..b79db1f8 100644 --- a/include/ctap2.h +++ b/include/ctap2.h @@ -167,7 +167,6 @@ typedef enum ctap2_ux_state_e { CTAP2_UX_STATE_MULTIPLE_ASSERTION, CTAP2_UX_STATE_NO_ASSERTION, CTAP2_UX_STATE_RESET, - CTAP2_UX_STATE_CANCELLED = 0xff } ctap2_ux_state_t; bool ctap2_check_rpid_filter(const char *rpId, uint32_t rpIdLen); diff --git a/src/app_main.c b/src/app_main.c index 38703129..fb28ed96 100644 --- a/src/app_main.c +++ b/src/app_main.c @@ -32,14 +32,7 @@ * Override app_ticker_event_callback io_event() dummy implementation */ void app_ticker_event_callback(void) { - if (ctap2UxState == CTAP2_UX_STATE_CANCELLED) { - ctap2UxState = CTAP2_UX_STATE_NONE; -#ifdef HAVE_BAGL - ux_stack_pop(); - ux_stack_push(); -#endif - ui_idle(); - } else if (ctap2UxState != CTAP2_UX_STATE_NONE) { + if (ctap2UxState != CTAP2_UX_STATE_NONE) { u2f_transport_ctap2_send_keepalive(&G_io_u2f, KEEPALIVE_REASON_TUP_NEEDED); } } diff --git a/src/ctap2_processing.c b/src/ctap2_processing.c index ae7c6bdb..cc9085d2 100644 --- a/src/ctap2_processing.c +++ b/src/ctap2_processing.c @@ -132,11 +132,20 @@ void ctap2_handle_cmd_cancel(u2f_service_t *service, uint8_t *buffer, uint16_t l UNUSED(length); PRINTF("ctap2_cmd_cancel %d\n", ctap2UxState); - if ((ctap2UxState != CTAP2_UX_STATE_NONE) && (ctap2UxState != CTAP2_UX_STATE_CANCELLED)) { + if (ctap2UxState != CTAP2_UX_STATE_NONE) { PRINTF("Cancel pending UI\n"); - ctap2UxState = CTAP2_UX_STATE_CANCELLED; - ui_idle(); + ctap2UxState = CTAP2_UX_STATE_NONE; + + // Answer as fast as possible as Chrome expect a fast answer and in case + // it didn't comes fast enough, it won't be sent back if the user + // eventually choose again this authenticator. send_cbor_error(service, ERROR_KEEPALIVE_CANCEL); + +#ifdef HAVE_BAGL + ux_stack_pop(); + ux_stack_push(); +#endif + ui_idle(); } }