How to change the Mifare Classic 1k key A and Key B

Liban picture Liban · Jan 8, 2013 · Viewed 11.8k times · Source

I am using a Mifare classic 1k reader, and it comes with the default key A and B which is:

FFFFFFFFFFFF

Using the Key A to read and write works. but I want to change the keys.

Is there anyway to get the correct access bits for the sector and what is the format?

What I have done now is,

<newKey>+ access bits + <oldKEY>
212121212121078069FFFFFFFFFFFF

The access bits 078069 I got from reading block 7 of sector 1, which is like this:

000000000000FF078069FFFFFFFFFFFF

But there is error.

Are the access bits incorrect or is the format wrong?

Answer

NFC guy picture NFC guy · Jan 8, 2013

Depending on the access control settings of the sector trailer, you may need to authenticate with key A or key B to be able to write keys. See the section 8.7 (and specifically 8.7.2) of the datasheet at http://www.nxp.com/documents/data_sheet/MF1S70YYX.pdf on how to encode/decode the access control bits in the sector trailer.