This is a question specific to Java Card development (applets not MIDlets), and more specifically Mifare cards/architecture. Any help would be really appreciated!
Using the G&D JCSuite toolkit I'm developing an applet which reads/writes data to the Mifare emulation element. The problem I'm getting is that when I set the sector trailer to some specific keys, I cannot read or write data from the data-blocks within the sector - I effectively lock the Mifare sector even though I know the keys.
So, from the MF_Password generation document:
There are examples of generating the MF_Password for 3 different keys, and I can verify my applet generates the same correct password. When I set the keys:
KeyA: A0 A1 A2 A3 A4 A5 KeyB: B0 B1 B2 B3 B4 B5
i.e. a write-block of 16 bytes:
Into block 7 (Sector 1 Block 3).
If I read back the data from Block 4, I get no error & valid data - everything works as expected.
If however (and unexplicably) I write the keys:
KeyA: 4D 3A 99 C3 51 DD KeyB: 1A 98 2C 7E 45 9A
i.e. the write-block of 16 bytes:
Into the same block, and then try to read back the corresponding block (like the example above). I get a security error as if I specified the wrong keys.
How can the keys function correctly for one set, but not another. When I can verify that MF_Password is being generated correctly (using the JCSuite debugger).