Reputation: 63
I would like to make MIFARE Classic 1k cards read only after writing some initial data to them. I guess I need to change keys A and B to something custom after writing data to the new card. But how do I do that? These keys are located in the same block as the access bits, so I can't use MifareClassic method for writing a complete block:
public void writeBlock(int blockIndex, byte[] data) throws IOException
because it will also rewrite the access bits.
Upvotes: 1
Views: 2222
Reputation: 40831
Sure you need to use the method MifareClassic.writeBlock()
. Since MIFARE Classic only supports writing complete blocks, you have to update the whole sector trailer block.
As MIFARE Classic does not have a free read mode (i.e. read without prior authentication) you need to set both, a read key (you would typically use key A for that) and the access bits (that cofigure key A as read-only key).
You can find further information about possible access condition values and the block format here:
Upvotes: 2