Files
unleashed-firmware/lib/nfc/protocols/mf_desfire
Mykhailo ShevchukandClaude Opus 5 5f8727ae0e [NFC]: Support MIFARE DESFire Light (read as ISO14443-4A Unknown) (#1173)
DESFire Light takes only ISO 7816-wrapped commands. A plain native frame gets
SW 6700 ("wrong length"), so every command the DESFire poller sent was refused,
detection died at GetVersion and nothing in the ISO14443-4A family claimed the
card. mf_desfire_poller_read_version_any_mode() now settles on the mode the card
answers and keeps it for the session; only a refusal of the frame itself earns a
second attempt, so the EV series keeps its plain frames and MIFARE Plus / NTAG
4xx still cost one exchange. The wrapped path and its 0xAF chaining already
existed in nxp_native_command.c for type_4_tag and ntag4xx.

Light also reports its own hardware type (0x08), which mf_desfire_version_parse
rejected, and its hw_major 0x30 is outside the EV1/EV2/EV3 series, so the type is
classified from hw_type first. It reads as "Mifare DESFire Light".

Light answers 0x1C to GetFreeMemory, GetKeySettings and GetKeyVersion, so the
read has to survive those refusals. Unmodelled status codes became
MfDesfireErrorRejected (mirroring MfPlusErrorRejected) instead of sharing
MfDesfireErrorProtocol with a broken exchange, and the two handlers that each
tolerated one specific refusal now tolerate any refusal via
mf_desfire_error_is_refusal(), which also covers an EV card with a locked PICC.
A transport failure still fails the read.

Detection no longer sends GetKeyVersion(0) ahead of GetVersion: the 28-byte
layout plus the hardware type nibble already separate the families, and the probe
only answered whether key 0 was readable.

Also fixed: the key-version refusal path zeroes max_keys with the array it
empties (save writes one line per element, load reads max_keys of them, so a
stale count made the file the app had just written unloadable) and honours
is_free_directory_list; mf_desfire_reset clears master_key_settings; read_success
fills the event error field; refusals log at FURI_LOG_W, which release builds keep;
the device name appends the size only when known.

mf_desfire_get_type_from_version is exported for the NFC app, as ntag4xx, slix and
mf_ultralight already do. API 88.16.

Hardware-verified on a 7-byte-UID MF2DL(H)x0: nfc scanner reports "Mifare DESFire"
where it reported "Iso14443-4a", and nfc dump -p des saves a complete file whose
PICC Version matches the Proxmark3 reading byte for byte.

Reading the Light's file contents is not part of this.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-04 18:37:21 +03:00
..