Reply To: Change Key

Forum MIFARE SDK Change Key Reply To: Change Key

Re: Change Key

17. April 2017 at 2:46

AS
Having issue with Changing masterKey. I can format the card but cannot change Master KEY.

public static final byte[] DEFAULT_KEY_2KTDES = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};

/**
* 16 bytes AES128 Key.
*/
public static final byte[] TEST_MASTER_KEY_AES128 = {
(byte) 0x04, (byte) 0x01, (byte) 0x04, (byte) 0x01,
(byte) 0x03, (byte) 0x02, (byte) 0x03, (byte) 0x02,
(byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x03,
(byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x04};

iDESFireEV1.selectApplication(0x00);

final Key AUTH_KEY = new SecretKeySpec(DEFAULT_KEY_2KTDES, "DESede");

KeyData keyData = new KeyData();
keyData.setKey(AUTH_KEY);

iDESFireEV1.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.TWO_KEY_THREEDES, keyData);

iDESFireEV1.changeKey(0, KeyType.AES128, DEFAULT_KEY_2KTDES,
TEST_MASTER_KEY_AES128, (byte) 0x00);

Error:
W/System.err: com.nxp.nfclib.exceptions.InvalidResponseLengthException: Integrity Error
+ 0  |  - 0