Adding routine for pressing button to test required user presence.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2022-09-06 16:24:21 +02:00
parent 9cbe6d9c33
commit 9bf20175be
2 changed files with 11 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
#include "u2f.h"
#include "files.h"
#include "file.h"
#include "usb.h"
#include "random.h"
#include "mbedtls/ecdsa.h"
#include "mbedtls/x509_crt.h"
@@ -186,6 +187,15 @@ void init_fido() {
scan_all();
}
bool wait_button_pressed() {
uint32_t val = EV_PRESS_BUTTON;
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);
return val == EV_BUTTON_TIMEOUT;
}
typedef struct cmd
{
uint8_t ins;