Reply To: KeyA and KeyB and how to protect the contacless card from cloning?

Forum MIFARE general topics and applications KeyA and KeyB and how to protect the contacless card from cloning? Reply To: KeyA and KeyB and how to protect the contacless card from cloning?

Re: KeyA and KeyB and how to protect the contacless card from cloning?

15. February 2016 at 9:47
Hi,

First of all: you can use any sector of the MIFARE Classic card. Only for sector 0 the first block is used with the manufacturer data. This is the UID of the device which you cannot change. The number of sectors and blocks depend on the size of the card. E.g.: a MIFARE Classic 1K provides 16 sectors with 4 blocks (=1024 bytes).

If you use sector 1 (blocks 4 … 7) then 3 blocks (4, 5 and 6) can be used for store you data. The last block is the so called sector trailer and contains the keys and the access condition bits. The access condition bits can be set e.g. to “read = free”, “write = Key A” or “read = Key B” and “write = Key A” etc. The level of protection depends on your use case.

Please note that you have to authenticate with the correct key to each sector before you can read or write to it.
Let us assume you use sectors 1 and 2 for your application. A typical sequence look like:

Authenticate( 4, KEY_A )   // Authenticate to sector 1/block 4 with key A
Read( 4 ) // Read from block 4
Write( 4, “0011...” ) // Write to block 4
Authenticate( 8, KEY_B ) // Authenticate to sector 2/block 8 with key B
Read( 8 ) // Read from block 8
...


The real commands depend on the driver interface you use (C, C#, Java etc.)

For a blank card both keys are “FFFFFFFFFFFF”. Before you issue the card to the end-customer you change the default keys to a new byte sequence. Please note, if you write to the sector trailer, you also set the access condition bits. Any later access to the sector must comply the new keys and condition bits.

You will find more information:
http://www.nxp.com/documents/data_sheet/MF1S50YYX_V1.pdf

Kind regards,
The MIFARE Team
+ 0  |  - 0