mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-20 20:13:50 +01:00
sys/fido2: Fix bug in user presence test
The authenticator did not wait for user presence when user presence tests were enabled, but LED animations were disabled.
This commit is contained in:
parent
2e02363eef
commit
3e3ad836a1
@ -15,8 +15,6 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "ztimer.h"
|
#include "ztimer.h"
|
||||||
|
|
||||||
#include "fido2/ctap.h"
|
#include "fido2/ctap.h"
|
||||||
@ -61,9 +59,7 @@ ctap_status_code_t fido2_ctap_utils_user_presence_test(void)
|
|||||||
|
|
||||||
gpio_irq_enable(_pin);
|
gpio_irq_enable(_pin);
|
||||||
|
|
||||||
if (!IS_ACTIVE(CONFIG_FIDO2_CTAP_DISABLE_LED)) {
|
fido2_ctap_utils_wait_for_user_presence();
|
||||||
fido2_ctap_utils_led_animation();
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = _user_present ? CTAP2_OK : CTAP2_ERR_ACTION_TIMEOUT;
|
ret = _user_present ? CTAP2_OK : CTAP2_ERR_ACTION_TIMEOUT;
|
||||||
|
|
||||||
@ -79,39 +75,43 @@ static void _gpio_cb(void *arg)
|
|||||||
_user_present = true;
|
_user_present = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fido2_ctap_utils_led_animation(void)
|
void fido2_ctap_utils_wait_for_user_presence(void)
|
||||||
{
|
{
|
||||||
uint32_t start = ztimer_now(ZTIMER_MSEC);
|
uint32_t start = ztimer_now(ZTIMER_MSEC);
|
||||||
uint32_t diff = 0;
|
uint32_t diff = 0;
|
||||||
uint32_t delay = 500;
|
uint32_t delay = 500;
|
||||||
|
|
||||||
while (!_user_present && diff < CTAP_UP_TIMEOUT) {
|
while (!_user_present && diff < CTAP_UP_TIMEOUT) {
|
||||||
|
if (!IS_ACTIVE(CONFIG_FIDO2_CTAP_DISABLE_LED)) {
|
||||||
#ifdef LED0_TOGGLE
|
#ifdef LED0_TOGGLE
|
||||||
LED0_TOGGLE;
|
LED0_TOGGLE;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LED1_TOGGLE
|
#ifdef LED1_TOGGLE
|
||||||
LED1_TOGGLE;
|
LED1_TOGGLE;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LED3_TOGGLE
|
|
||||||
LED3_TOGGLE;
|
|
||||||
#endif
|
|
||||||
#ifdef LED2_TOGGLE
|
#ifdef LED2_TOGGLE
|
||||||
LED2_TOGGLE;
|
LED2_TOGGLE;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef LED3_TOGGLE
|
||||||
|
LED3_TOGGLE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
ztimer_sleep(ZTIMER_MSEC, delay);
|
ztimer_sleep(ZTIMER_MSEC, delay);
|
||||||
diff = ztimer_now(ZTIMER_MSEC) - start;
|
diff = ztimer_now(ZTIMER_MSEC) - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IS_ACTIVE(CONFIG_FIDO2_CTAP_DISABLE_LED)) {
|
||||||
#ifdef LED0_TOGGLE
|
#ifdef LED0_TOGGLE
|
||||||
LED0_OFF;
|
LED0_OFF;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LED1_TOGGLE
|
#ifdef LED1_TOGGLE
|
||||||
LED1_OFF;
|
LED1_OFF;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LED3_TOGGLE
|
|
||||||
LED3_OFF;
|
|
||||||
#endif
|
|
||||||
#ifdef LED2_TOGGLE
|
#ifdef LED2_TOGGLE
|
||||||
LED2_OFF;
|
LED2_OFF;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef LED3_TOGGLE
|
||||||
|
LED3_OFF;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* @brief LED animation to indicate that user action is required
|
* @brief LED animation to indicate that user action is required
|
||||||
*/
|
*/
|
||||||
void fido2_ctap_utils_led_animation(void);
|
void fido2_ctap_utils_wait_for_user_presence(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize button to be used for user presence test
|
* @brief Initialize button to be used for user presence test
|
||||||
|
|||||||
@ -26,16 +26,18 @@ CFLAGS += -DCONFIG_FIDO2_CTAP_DISABLE_LED=1
|
|||||||
# compiled natively (x86-64). Therefore we need to clear the flags set by e.g.
|
# compiled natively (x86-64). Therefore we need to clear the flags set by e.g.
|
||||||
# BOARD = nrf52840dk
|
# BOARD = nrf52840dk
|
||||||
fido2-test:
|
fido2-test:
|
||||||
env -i PATH=$(PATH) $(MAKE) -C $(RIOTBASE)/build/pkg/fido2_tests standard-tests
|
env -i PATH=$(PATH) $(MAKE) -C $(PKGDIRBASE)/fido2_tests standard-tests
|
||||||
|
|
||||||
# FIDO2 user presence tests.
|
# FIDO2 user presence tests.
|
||||||
#
|
#
|
||||||
# Make sure to enable user presence tests by uncommenting CFLAGS += -DCONFIG_FIDO2_CTAP_DISABLE_UP=1
|
# Make sure to enable user presence tests by setting CFLAGS += -DCONFIG_FIDO2_CTAP_DISABLE_UP=0.
|
||||||
|
# It is also recommended to set CFLAGS += -DCONFIG_FIDO2_CTAP_DISABLE_LED=0 to have
|
||||||
|
# an indicator that signals when to press the button.
|
||||||
#
|
#
|
||||||
# Use env -i because fido2-test has a depedency (pyscard) that needs to be
|
# Use env -i because fido2-test has a depedency (pyscard) that needs to be
|
||||||
# compiled natively (x86-64). Therefore we need to clear the flags set by e.g.
|
# compiled natively (x86-64). Therefore we need to clear the flags set by e.g.
|
||||||
# BOARD = nrf52840dk
|
# BOARD = nrf52840dk
|
||||||
fido2-test-up:
|
fido2-test-up:
|
||||||
env -i PATH=$(PATH) $(MAKE) -C $(RIOTBASE)/build/pkg/fido2_tests up-tests
|
env -i PATH=$(PATH) $(MAKE) -C $(PKGDIRBASE)/fido2_tests up-tests
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user