2025-02-12 9:19 AM
We are using an ST25R3916B to read and write to both ST25TV512C tags and Mifare Classic 1K cards. While we have successfully communicated with ST25 tags, we are encountering issues at the authentication stage with Mifare Classic.
Steps We Are Following:
Before sending authentication commands, we ensure the reader is in the RFAL_NFC_STATE_ACTIVATED state.
Mifare Classic authentication follows a challenge-response mechanism. To begin, we must send the authentication command and obtain a 4-byte random challenge from the card.
The command consists of:
uint8_t authCmd[12];
authCmd[0] = 0x60; // Authenticate using Key A
authCmd[1] = block; // Block number
memcpy(&authCmd[2], keyA, 6); // Copy the 6-byte key
memcpy(&authCmd[8], device.nfcid, device.nfcidLen); // Copy the UID
We then transmit this using rfalTransceiveBlockingTxRx():
status = driver.rfalTransceiveBlockingTxRx(
authCmd, // Transmit buffer
sizeof(authCmd), // Transmit length
response, // Receive buffer
sizeof(response), // Max receive length
&responseLen, // Actual response length
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_FWT_NONE
);
Current Issue
In the code below, I attempt to send only 4 bytes for authentication, which includes CRC values (D1 and 3D) for 0x60 and 0x04:
uint8_t authCmd[4];
authCmd[0] = 0x60; // Authentication command (Key A)
authCmd[1] = 0x04; // Block number
authCmd[2] = 0xD1; // CRC for 60 and 04
authCmd[3] = 0x3D; // CRC
status = driver.rfalTransceiveBlockingTxRx(
authCmd, // Transmit buffer
sizeof(authCmd), // Transmit length
response, // Receive buffer
sizeof(response), // Max receive length
&responseLen, // Actual response length
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_FWT_NONE
);
What I Need Help With
Any help would be greatly appreciated.
Thanks in advance.
2025-02-13 12:58 AM
Hi AMCI,
you can find some hints here: nfc0541-read-mifare-classic-1k .
Concerning the ERR_IO: No idea really, please debug through and isolate the code line. There should only be very few ERR_IO and in normal operation this error code shouldn't appear.
Regards, Ulysses
2025-03-05 2:28 PM
I have the same issue with not being able to receive the NONCE upon calling the code here. After powering up the ST25R3916B, we set it to 3.3V in register 0x01H by setting bit 7 high Updated value of register 0x1 (Binary): 0b10000000.
With or without the register setting, I can successfully get the device, identify it as Mifare Classic 1K (ATQA: 04 00
SAK: 08) and then proceed to the authentication using the code below.
In some other threads, I read that I should be using bit-oriented calls vs. byte. Does that apply to the call to which the device responds with the nonce. I'm not able to get the nonce. My ESP32S3 MCU goes to watchdog and reboots.
2025-03-06 12:28 AM
Hello,
I think this 60 command is in reality much shorter. Please check against the specs of the cards in use. To my knowledge it can be sent using normal mode. First verify that. And once you get a response - as subsequent commands need to be sent in low level mode (SW generated parity and CRC)- it will be a good idea to already exercise with this command the transmission and reception of low level frames.
A similar approach with a T2T command was discussed under keyword "template" in the mentioned other community thread.
BR, Ulysses