From ab4ebe9da6ac35c159262115a7cf16d70307b797 Mon Sep 17 00:00:00 2001 From: Fan DANG Date: Fri, 13 Dec 2024 13:28:14 +0800 Subject: [PATCH 1/3] allow fetching nfc enable status without an admin pin --- applets/admin/admin.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/applets/admin/admin.c b/applets/admin/admin.c index 186db137..64270c60 100644 --- a/applets/admin/admin.c +++ b/applets/admin/admin.c @@ -223,6 +223,10 @@ int admin_process_apdu(const CAPDU *capdu, RAPDU *rapdu) { ret = admin_vendor_hw_sn(capdu, rapdu); goto done; + case ADMIN_INS_NFC_ENABLE: + ret = admin_vendor_nfc_enable(capdu, rapdu); + goto done; + case ADMIN_INS_FACTORY_RESET: ret = admin_factory_reset(capdu, rapdu); goto done; @@ -267,9 +271,6 @@ int admin_process_apdu(const CAPDU *capdu, RAPDU *rapdu) { case ADMIN_INS_RESET_CTAP: ret = ctap_install(1); break; - case ADMIN_INS_NFC_ENABLE: - ret = admin_vendor_nfc_enable(capdu, rapdu); - break; case ADMIN_INS_READ_CTAP_SM2_CONFIG: ret = ctap_read_sm2_config(capdu, rapdu); break; From e8e05012da37f152c86a1926fbca678d83718e3a Mon Sep 17 00:00:00 2001 From: Fan DANG Date: Fri, 13 Dec 2024 14:07:57 +0800 Subject: [PATCH 2/3] add a param to admin_vendor_nfc_enabled --- applets/admin/admin.c | 2 +- include/admin.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applets/admin/admin.c b/applets/admin/admin.c index 64270c60..dc436b09 100644 --- a/applets/admin/admin.c +++ b/applets/admin/admin.c @@ -45,7 +45,7 @@ __attribute__((weak)) int admin_vendor_hw_sn(const CAPDU *capdu, RAPDU *rapdu) { return 0; } -__attribute__((weak)) int admin_vendor_nfc_enable(const CAPDU *capdu, RAPDU *rapdu) { +__attribute__((weak)) int admin_vendor_nfc_enable(const CAPDU *capdu, RAPDU *rapdu, bool pin_validated) { UNUSED(capdu); UNUSED(rapdu); return 0; diff --git a/include/admin.h b/include/admin.h index 6f3d8d6f..962cc15b 100644 --- a/include/admin.h +++ b/include/admin.h @@ -47,7 +47,7 @@ int admin_vendor_specific(const CAPDU *capdu, RAPDU *rapdu); int admin_vendor_version(const CAPDU *capdu, RAPDU *rapdu); int admin_vendor_hw_variant(const CAPDU *capdu, RAPDU *rapdu); int admin_vendor_hw_sn(const CAPDU *capdu, RAPDU *rapdu); -int admin_vendor_nfc_enable(const CAPDU *capdu, RAPDU *rapdu); +int admin_vendor_nfc_enable(const CAPDU *capdu, RAPDU *rapdu, bool pin_validated); uint8_t cfg_is_led_normally_on(void); uint8_t cfg_is_ndef_enable(void); From 9ce7027fa01f597690bdfe6c7d4e9a5b7c5dc670 Mon Sep 17 00:00:00 2001 From: Fan DANG Date: Fri, 13 Dec 2024 19:52:39 +0800 Subject: [PATCH 3/3] fix param error --- applets/admin/admin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applets/admin/admin.c b/applets/admin/admin.c index dc436b09..e5d8f50d 100644 --- a/applets/admin/admin.c +++ b/applets/admin/admin.c @@ -48,6 +48,7 @@ __attribute__((weak)) int admin_vendor_hw_sn(const CAPDU *capdu, RAPDU *rapdu) { __attribute__((weak)) int admin_vendor_nfc_enable(const CAPDU *capdu, RAPDU *rapdu, bool pin_validated) { UNUSED(capdu); UNUSED(rapdu); + UNUSED(pin_validated); return 0; } @@ -224,7 +225,7 @@ int admin_process_apdu(const CAPDU *capdu, RAPDU *rapdu) { goto done; case ADMIN_INS_NFC_ENABLE: - ret = admin_vendor_nfc_enable(capdu, rapdu); + ret = admin_vendor_nfc_enable(capdu, rapdu, pin.is_validated); goto done; case ADMIN_INS_FACTORY_RESET: