13.56MHz MIFARE Reader Module
The MIFARE Application Oriented Protocol is a reader Interface to communicate with MIFARE transponders. The major applications to be supported are:
Access control, Identification: Reading the serial numbers of all cards in the field.
Data Storage: Performing encrypted read and write operations.
Ticketing: Performing read, write, increment and decrement operations in an encrypted environment.
Multi applications: Performing read, write, increment and decrement operations on various sectors of the MIFARE tags using different encryption keys.

 MIFARE Data Structures 

Sector Memory segment of the MIFARE®Standard Card. Each segment consists of 4 blocks and has individual keys and access conditions. Typically in a multiapplication environment each block is assigned to an application.
Key 6 byte structure assigned to each sector of the card. The reader may store up to 32 keys in its EEPROM or one key in its RAM.
Transport Key Key as stored after delivery from the manufacturer. (f.e. A0A1A2A3A4A5, B0B1B2B3B4B5 or FFFFFFFFFFFF)
Block 16 byte memory segment of the MIFARE®Standard card.
Value 4 byte (unsigned long) variable stored in a special format in a block or page. Values are 2s complement numbers that can be negative also. Values are used for cashless payment. Values consume a complete block each using redundancy for integrity checking.
Card ID 4 byte unique serial number (single size type). Together with manufacturer code and check byte 16 bytes. Read-only. It Is stored in block 0 (sector 0) of each tag.

MIFARE Card
The MIFARE Card consists of 16 sectors. Each sector has 4 blocks. Each block has 16 bytes.
 Mifare 4K Card Printing,NXP MF1ICS70 Cards,NXP Mifare 4K printed cards,Mifare Classic 4K S70 Offset Printing Cards,Mifare Classic 4K Card,

Sector 0 / Block 0
Serial Number (4 byte) Check byte (1 byte) Manufacturer data (11 byte)
This block is read only

 

Block 3, 7, 11, 15, …
Key A (6 byte) Access Conditions (4 bytes) Key B (6 byte)

Transport keys (keys after manufacturing, on delivery):
Key A: A0 A1 A2 A3 A4 A5 (Infineon) or FF FF FF FF FF FF (new NXP cards) Key B: B0 B1 B2 B3 B4 B5 (Infineon) or FF FF FF FF FF FF (new NXP cards) Access Conditions: FF 07 80 xx (key A used to read or write, the key A itself is not readable; key B is data only)
Note: Remark 1: enabled keys read as 00 00 00 00 00 00 Remark 2: using key B as data area will cause a security gap, due to the fact that it is necessary to rewrite key A and Access Conditions at every write access (MIFARE® does only support read/write whole blocks). Therefore this configuration is not recommended for security sensitive applications.

MIFARE States
The MIFARE Concept can handle multiple tags in the field and has encrypted memory access for secure cashless payment. Those features require a sequence of access as described below:

Mifare Classic 4K cards,NXP Mifare 4k Offset Printing Cards,Mifare 4K Proximity Smart Cards

This state machine structure is mapped in application oriented reader commands:

Get Serial Number “c” continuously reads serial numbers of all cards in the field “m displays a list of all tags in the field
Select “s” reads a serial number and selects a single card in the field “m…” selects a specific card in the field
Login “l” does the authentication procedure for a sector;  always requires a select (using “s” or “m…”) before
Read, Write, Increment, Decrement, Copy “r”, “w”, “+”, “-“, “=” does the reading, writing and value handling; always requires a select and a login before