How the 16-byte MIFARE Classic sector trailer is structured
On a MIFARE Classic 1K card (MF1S50, 16 sectors of 4 blocks), block 3 of every sector is its sector trailer; on a 4K card (MF1S70), block 3 guards sectors 0–31 and block 15 guards the eight 16-block sectors 32–39 (NXP MF1S50YYX_V1 §8.6; MF1S70YYX_V1 §8.6.2). Each 16-byte trailer holds:
- Bytes 0–5 (Key A, 6 bytes): mandatory primary sector key. Key A always reads back as logical zeros (
00 00 00 00 00 00) regardless of access bits, so reading a sector trailer never reveals Key A. - Bytes 6–8 (Access bits, 3 bytes): three bits (
C1, C2, C3) for each of the four block groups (12 bits), interleaved with their bitwise complements (~C1, ~C2, ~C3, 12 bits) across 24 bits. - Byte 9 (General-purpose byte, 1 byte): arbitrary user/version byte governed by the same read/write rights as the access bits (
69hat NXP delivery). - Bytes 10–15 (Key B, 6 bytes): optional second sector key. When the trailer access condition makes Key B readable (
000,010or transport default001), Key B serves as data and cannot be used to authenticate (Table 7 Remark 1).
Standard access-byte presets at a glance
| Configuration | Bytes 6–9 | Data C1C2C3 | Trailer C1C2C3 | Behaviour |
|---|---|---|---|---|
| Factory transport | FF 07 80 69 | 000 / 000 / 000 | 001 | NXP factory delivery configuration: Key A (FF FF FF FF FF FF) has full access; Key B is readable data. |
| Key A read / Key B write | 78 77 88 69 | 100 / 100 / 100 | 011 | Field readers hold Key A (read-only); issuing station holds Key B to write blocks and rotate keys. |
| Closed-loop value counter | 68 77 89 69 | 110 / 100 / 100 | 011 | Block 0 configured as a Value Block (Key B increments, Key A|B decrements); Blocks 1–2 standard R/W. |
| Frozen read-only sector | 07 87 8F 69 | 010 / 010 / 010 | 111 | Irreversible read-only configuration: Key A or B reads data blocks; no key can ever alter data or keys. |
Three ways sectors get accidentally locked — and how to avoid them
- Writing unverified hex to bytes 6–8: if a script flips a bit in
C1..C3without flipping its complement in~C1..~C3, the chip permanently blocks the entire sector on the very next command. Always generate or validate the 3 access bytes before sending aWRITEAPDU to a trailer block. - Requiring Key B on data blocks while leaving trailer at
001: if you set data blocks to100(write with Key B) or011(read/write with Key B) while leaving the sector trailer in factory transport condition001, Key B remains readable and disabled for authentication — so nobody can write those blocks until Key A updates the trailer to011or100. - Overwriting Key A/B with zeros from a read-back buffer: reading block 3 returns
00 00 00 00 00 00in bytes 0–5 (and in bytes 10–15 when Key B is hidden). Modifying bytes 6–8 in that read buffer and writing all 16 bytes back overwrites your secret keys with all-zeros unless you explicitly populate bytes 0–5 and 10–15 with the intended 6-byte keys.
Remember that access bits organize application roles within a card; they do not fix Crypto-1’s cryptographic weakness. Where copy resistance matters, migrate to MIFARE Plus in Security Level 3 (AES-128) or MIFARE DESFire EV3.