Search code examples
nfcmifareapdupcscacr122

MIFARE Classic 1K load authentication keys failure with ACR122U


I am using an ACR122U NFC reader/writer and a MIFARE Classic 1K card. To load authentication keys for the MIFARE card, I use the following APDU command:

FF 82 20 00 06 FF FF FF FF FF FF

The reader responds with 90 00 (indicating success). However, on another PC I have the same reader/writer and the same tag but I receive the response code 63 00, which means that the operation failed.

When I read the ACR122U documentation it states the command as

FF 82 00 00 06 <KEY>

This byte is named key structure and its value is 00 in the documentation. Can this byte be the source of this problem?

Can anyone help me on this and explain the value of the key structure byte?


Solution

  • I'm rather surprised that you found one ACR122U that supports key structure (P1) set to 0x20. The API manual of the reader (see section 5.1 Load Authentication Keys) clearly indicates that values other than 0x00 are reserved (i.e. must not be used). This means that the ACR122U only supports card keys (i.e. authentication keys for cards) in volatile memory (i.e. keys are cleared from memory when the reader is unplugged).

    You can find the definition of the key structure (P1) byte in the PC/SC specification (in Part 3. Requirements for PC-Connected Interface Devices):

    • Bit 7: This bit indicates if the key transmitted in this command is a card key ('0') or a reader key ('1'). Reader keys are keys used to encrypt card keys during transmission in the LOAD KEYS command (see bit 6).
    • Bit 6: The key transmitted in this command is transmitted in plain text ('0') or encrypted ('1') using a reader key (see bits 3..0).
    • Bit 5: This bit indicates if the transmitted key should be stored in volatile ('0') or non-volatile ('1') memory.
    • Bit 4: Reserved and always set to '0'.
    • Bit 3..0: The reader key number used for encrypteion of the transmitted key if bit 6 is set.