mirror of
https://github.com/polhenarejos/pico-fido
synced 2026-06-04 03:53:01 +02:00
Add cancel button event.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Submodule pico-keys-sdk updated: eb26a96d3b...49edef1d3f
@@ -35,7 +35,7 @@ int cbor_reset(void) {
|
||||
return CTAP2_ERR_NOT_ALLOWED;
|
||||
}
|
||||
#endif
|
||||
if (wait_button_pressed() == true) {
|
||||
if (wait_button_pressed() > 0) {
|
||||
return CTAP2_ERR_USER_ACTION_TIMEOUT;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,9 +20,16 @@
|
||||
#include "ctap2_cbor.h"
|
||||
#include "ctap.h"
|
||||
|
||||
extern char *rp_id, *user_name, *display_name;
|
||||
|
||||
int cbor_selection(void) {
|
||||
if (wait_button_pressed() == true) {
|
||||
rp_id = user_name = display_name = NULL;
|
||||
int ret = wait_button_pressed() ;
|
||||
if (ret == 1) {
|
||||
return CTAP2_ERR_USER_ACTION_TIMEOUT;
|
||||
}
|
||||
else if (ret == 2) {
|
||||
return CTAP2_ERR_OPERATION_DENIED;
|
||||
}
|
||||
return CTAP2_OK;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ int cmd_authenticate(void) {
|
||||
if (req->keyHandleLen < KEY_HANDLE_LEN) {
|
||||
return SW_INCORRECT_PARAMS();
|
||||
}
|
||||
if (P1(apdu) == CTAP_AUTH_ENFORCE && wait_button_pressed() == true) {
|
||||
if (P1(apdu) == CTAP_AUTH_ENFORCE && wait_button_pressed() > 0) {
|
||||
return SW_CONDITIONS_NOT_SATISFIED();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ int cmd_register(void) {
|
||||
if (apdu.nc != CTAP_APPID_SIZE + CTAP_CHAL_SIZE) {
|
||||
return SW_WRONG_LENGTH();
|
||||
}
|
||||
if (wait_button_pressed() == true) {
|
||||
if (wait_button_pressed() > 0) {
|
||||
return SW_CONDITIONS_NOT_SATISFIED();
|
||||
}
|
||||
if (memcmp(req->appId, bogus_firefox,
|
||||
|
||||
@@ -498,22 +498,28 @@ void init_fido(void) {
|
||||
needs_power_cycle = false;
|
||||
}
|
||||
|
||||
bool wait_button_pressed(void) {
|
||||
int wait_button_pressed(void) {
|
||||
uint32_t val = EV_PRESS_BUTTON;
|
||||
#if defined(PICO_PLATFORM) || defined(ESP_PLATFORM)
|
||||
queue_try_add(&card_to_usb_q, &val);
|
||||
do {
|
||||
queue_remove_blocking(&usb_to_card_q, &val);
|
||||
} while (val != EV_BUTTON_PRESSED && val != EV_BUTTON_TIMEOUT);
|
||||
} while (val != EV_BUTTON_PRESSED && val != EV_BUTTON_TIMEOUT && val != EV_BUTTON_CANCELLED);
|
||||
#endif
|
||||
return val == EV_BUTTON_TIMEOUT;
|
||||
if (val == EV_BUTTON_TIMEOUT) {
|
||||
return 1;
|
||||
}
|
||||
else if (val == EV_BUTTON_CANCELLED) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t user_present_time_limit = 0;
|
||||
|
||||
bool check_user_presence(void) {
|
||||
if (user_present_time_limit == 0 || user_present_time_limit + TRANSPORT_TIME_LIMIT < board_millis()) {
|
||||
if (wait_button_pressed() == true) { //timeout
|
||||
if (wait_button_pressed() > 0) { //timeout
|
||||
return false;
|
||||
}
|
||||
//user_present_time_limit = board_millis();
|
||||
|
||||
@@ -41,7 +41,7 @@ extern int derive_key(const uint8_t *app_id,
|
||||
int,
|
||||
mbedtls_ecp_keypair *key);
|
||||
extern int verify_key(const uint8_t *appId, const uint8_t *keyHandle, mbedtls_ecp_keypair *);
|
||||
extern bool wait_button_pressed(void);
|
||||
extern int wait_button_pressed(void);
|
||||
extern void init_fido(void);
|
||||
extern void init_otp(void);
|
||||
extern void scan_all(void);
|
||||
|
||||
Reference in New Issue
Block a user