HID SAM: read MIFARE Classic SE through CMD_HF_SAM_MFC

sam_mfc.c was empty and CMD_HF_SAM_MFC was a no-op. Implement the relay
the way Seader's plugin_hf_mfc_transmit does it. The SAM runs Crypto1
itself and tags each nfcSend with a format:

- 00 C0 00: plain bytes, CRC already included, parity generated
- 00 00 40 / 24 / 44: air order bit stream carrying the SAM's own parity

Answers to the latter go back in the same bit form, len + len / 8 + 1
bytes like Seader. Unlike Seader, every byte gets its real parity bit;
Seader leaves bytes 8 and on at zero. A silent card is reported to the
SAM as rfStatus 00 20, an unknown format as 00 04, Seader's codes, and
the conversation continues.

Card detected follows Seader for MIFARE Classic: protocol, CSN and SAK,
no ATQA. The card is selected without RATS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-10 10:23:39 +07:00
1 parent d2e077ded9
commit 0fdbdbdadd
5 files changed
+324 -1

No files matched your search

+7
View File
@@ -96,6 +96,13 @@ int sam_relay_iso15_loop(
);
int sam_set_card_detected_iso14a(const iso14a_card_select_t *card_select, bool with_atqa);
uint16_t sam_copy_payload_nfc2sam_status(uint8_t *sam_tx, const uint8_t *nfc_rx, uint8_t nfc_len, uint16_t rf_status);
bool sam_nfc_send_format(const uint8_t *sam_rx_buf, uint16_t sam_rx_len, uint8_t *format);
// nfcRx rfStatus values, as Seader reports them
#define SAM_RF_STATUS_OK 0x0000
#define SAM_RF_STATUS_TIMEOUT 0x0020
#define SAM_RF_STATUS_PROTOCOL 0x0004
// Capture of UID and plaintext SIO for the extended PACS reply (sam_ext_reply_hdr_t)
void sam_capture_reset(void);