Search code examples
securityauthenticationrfidmifareparity

Parity bit for MIFARE Classic authentication


I have learned that the MIFARE Classic authentication has a weakness about the parity bit. But I wonder how the reader sends the parity bit to the tag?

For example, here is the trace of a failed authentication attempt:

reader:26
tag:   02 00
reader:93 20
tag:   c1 08 41 6a e2
reader:93 70 c1 08 41 6a e2 e4 7c
tag:   18 37 cd
reader:60 00 f5 7b
tag:   ab cd 19 49
reader:59 d5 92 0f 15 b9 d5 53
tag:   a   //error code: 0x5

I know after the anti-collision, the tag will send NT(32-bit) as challenge to the reader, and the reader responds with the challenge {NR}(32-bit) and {AR}(32-bit). But I don't know where the 8-bit parity bit is in the above example. Which are the parity bits?


Solution

  • The example trace that you posted in your question either does not contain information about parity bits or all parity bits were valid (according to ISO/IEC 14443-3).

    E.g. when the communication traces shows that the reader sends 60 00 f5 7b, the actual data that is sent over the RF interface would be (P is the parity bit):

      b1 ... b8 P b1 ... b8 P b1 ... b8 P b1 ... b8 P
    S 0000 0110 1 0000 0000 1 1010 1111 1 1101 1110 1 E
    

    Parity bits are sent after each 8th byte (i.e. after each octet) and makes sure that all 9 bits contain an odd number of binary ones (odd parity). Therefore, it forms a 1-bit checksum over that byte. In your trace only bytes (but not the parity bits in between them) are shown.

    The vulnerability regarding parity bits in MIFARE Classic is that parity bits are encrypted together with the actual data (cf. de Koning Gans, Hoepman, and Garcia (2008): A Practical Attack on the MIFARE Classic, in CARDIS 2008, LNCS 5189, pp. 267-282, Springer).

    Consequently, when you look at the communication trace without considering encryption, there may be parity errors according to the ISO/IEC 14443-3 parity calculation rule since the encrypted parity bit might not match the parity bit for the raw data stream. Tools like the Proxmark III would indicate such observed parity errors as exclamation marks ("!") after the corresponding bytes in the communication trace.