How NXP AN10787 structures MAD1 (Sector 00h) and MAD2 (Sector 10h)
When a campus, municipality or workplace shares one MIFARE Classic or MIFARE Plus SL1 card across independent readers — doors, canteen tills, print release, library kiosks or bike lockers — hardcoding sector numbers eventually causes collisions. NXP’s MIFARE Application Directory (AN10787) reserves fixed directory sectors readable with the public Key A A0 A1 A2 A3 A4 A5 so any terminal can look up its 2-byte Application Identifier (AID) dynamically:
- Sector 00h (MAD1 & lower MAD2): Block 0 is the read-only IC manufacturer/UID block. Block 1 Byte 0 holds the 8-bit
CRC-8/MIFARE-MADchecksum across the next 31 bytes; Block 1 Byte 1 holds the 6-bitInfopointer to the card publisher’s sector (00hif unused); Block 1 Bytes 2–15 and Block 2 Bytes 0–15 hold fifteen 2-byte little-endian[AppCode, ClusterCode]slots for Sectors01h–0Fh. - Sector 10h / Sector 16 (MAD2 upper directory for cards > 1 KB): Because Sector 16 has no manufacturer block, all three data blocks (Blocks 0, 1 and 2 = 48 bytes) store the upper directory: Block 0 Byte 0 holds the 8-bit CRC over the next 47 bytes, Block 0 Byte 1 holds the
Infobyte, and the remaining 46 bytes hold twenty-three 2-byte little-endian slots for Sectors11h–27h(Sectors 17–39). - General Purpose Byte (GPB, Sector 00h Block 3 Byte 9): Bit 7 (
DA = 1) declares that a MAD is present; Bit 6 (MA) marks multi-application (1) vs mono-application (0); Bits 5..2 are reserved0000b; Bits 1..0 (ADV) select01bfor MAD1 (C1h/81h) or10bfor MAD2 (C2h/82h). Sector 10h’s trailer GPB is reserved00h.
Standard MAD presets & reference checksums
| Preset | MAD / GPB | Sector 00h CRC | Block 1 first 6 bytes | Notes |
|---|---|---|---|---|
| NFC Forum NDEF 1K (E103h × 15) | MAD1 · C1h | 0x14 | 14 01 03 E1 03 E1 | NXP AN1305 MIFARE Classic 1K NDEF tag: Info = 01h, all 15 sectors assigned to E103h (stored 03 E1), CRC = 14h, GPB = C1h. |
| Campus 4K Multi-App (MAD2) | MAD2 · C2h | 0xDC | DC 01 01 48 01 48 | 4K card with MAD2 (GPB = C2h): 4 access sectors (4801h), 4 canteen sectors (6001h), 1 cardholder ASCII sector (0004h) and 29 free sectors. |
| MIFARE Plus 2K (MAD2 + 0005h pad) | MAD2 · C2h | 0x15 | 15 01 01 48 01 48 | 32-sector 2K card using MAD2: 15 access sectors (4801h) + 4 NDEF sectors (E103h), with non-existent sectors 20h–27h marked 0005h per AN10787. |
| Blank Initialised MAD1 (CRC CEh) | MAD1 · C1h | 0xCE | CE 00 00 00 00 00 | Pre-formatted empty 1K directory: Info = 00h, all 15 application sectors free (0000h), CRC = CEh, public Key A = A0..A5. |
Four implementation traps in MAD firmware and card personalisation
- CRC seed
0xE3vs0xC7: AN10787’s hardware shift-register diagram draws bit 0 on the left (1110 0011b = 0xE3). In MSB-first C, Python or TypeScript byte code, initializecrc = 0xC7(1100 0111b) with polynomial0x1Dand feed bytes fromInfoonward without feeding the CRC byte itself. - Swapping Cluster and Application bytes: Logical AID
4801h(Cluster48haccess control, App01h) is stored in memory as01 48, and NFC Forum NDEFE103his stored as03 E1. Reversing the pair makes compliant readers skip your sector. - Leaving Sector 00h trailer in transport mode (
FF 07 80): Public Key A (A0 A1 A2 A3 A4 A5) is published in AN10787 so every reader can inspect the directory. Always lock Sector 00h (and Sector 10h on MAD2) with access bytes78 77 88(check bit complements in our MIFARE Classic Access Bits Calculator) so only your secret issuer Key B can alter directory pointers. - Mistaking MAD organisation for cryptographic security: Public Key A gives an attacker a known key on Sector 00h immediately, enabling the 2015 hardnested attack against other Crypto-1 sectors on MIFARE Classic EV1. New multi-application estates should use MIFARE DESFire EV3 (which manages isolated 3-byte AIDs natively in hardware under AES-128 — size files in our DESFire Memory Calculator) or MIFARE Plus EV2 in Security Level 3.