Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache user presence request type. #18

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/u2f_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 4 additions & 1 deletion src/u2f_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Loading