Skip to content

Commit

Permalink
Merge pull request #103 from canokeys/feature/nfc_status_without_pin
Browse files Browse the repository at this point in the history
allow fetching nfc enable status without an admin pin
  • Loading branch information
z4yx authored Dec 13, 2024
2 parents 9834767 + 9ce7027 commit 6c6385b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions applets/admin/admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ __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);
UNUSED(pin_validated);
return 0;
}

Expand Down Expand Up @@ -223,6 +224,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, pin.is_validated);
goto done;

case ADMIN_INS_FACTORY_RESET:
ret = admin_factory_reset(capdu, rapdu);
goto done;
Expand Down Expand Up @@ -267,9 +272,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;
Expand Down
2 changes: 1 addition & 1 deletion include/admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6c6385b

Please sign in to comment.