Skip to content

Commit

Permalink
src: Improve ctap2_handle_cmd_cancel command processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chapron committed Nov 17, 2023
1 parent 961d914 commit 3da0d3e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion include/ctap2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 1 addition & 8 deletions src/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/ctap2_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 3da0d3e

Please sign in to comment.