diff --git a/fido2/ctap.c b/fido2/ctap.c index e3f76a1..585a964 100644 --- a/fido2/ctap.c +++ b/fido2/ctap.c @@ -19,6 +19,7 @@ #include "crypto.h" #include "util.h" #include "log.h" +#include "nfc.h" #include "device.h" #include APP_CONFIG #include "wallet.h" @@ -1759,7 +1760,7 @@ void ctap_init() exit(1); } - if (! device_is_nfc()) + if (device_is_nfc() != NFC_IS_ACTIVE) { ctap_reset_key_agreement(); } diff --git a/fido2/u2f.c b/fido2/u2f.c index e711ea1..0361b25 100644 --- a/fido2/u2f.c +++ b/fido2/u2f.c @@ -238,7 +238,7 @@ static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t c if (control == U2F_AUTHENTICATE_SIGN_NO_USER) up = 0; - if(!device_is_nfc() && up) + if(up) { if (ctap_user_presence_test() == 0) { @@ -286,14 +286,13 @@ static int16_t u2f_register(struct u2f_register_request * req) const uint16_t attest_size = attestation_cert_der_size; - if(!device_is_nfc()) + + if ( ! ctap_user_presence_test()) { - if ( ! ctap_user_presence_test()) - { - return U2F_SW_CONDITIONS_NOT_SATISFIED; - } + return U2F_SW_CONDITIONS_NOT_SATISFIED; } + if ( u2f_new_keypair(&key_handle, req->app, pubkey) == -1) { return U2F_SW_INSUFFICIENT_MEMORY; diff --git a/targets/stm32l432/src/device.c b/targets/stm32l432/src/device.c index f498122..d3d4410 100644 --- a/targets/stm32l432/src/device.c +++ b/targets/stm32l432/src/device.c @@ -491,7 +491,7 @@ static int handle_packets() int ctap_user_presence_test() { int ret; - if (device_is_nfc()) + if (device_is_nfc() == NFC_IS_ACTIVE) { return 1; }