Forum / MIFARE SDK / Problem initialising key set in MIRAFE DESFire EV2
Tagged: android taplinx desfire ev2
-
Hi guys,
I want to configure a key set for my application but I'm having trouble making it work. The code fails when I try to change the first key of the key set. I have tried two different authentication approaches after I create the application:
1. App authentication using authenticateEV2First: In this case the exception is InvalidResponseLengthException: Length Error which according to the doc of the ev2ChangeKey method means Command size not allowed
2. App authentication using authenticate: In this case the exception is InvalidResponseLengthException: Integrity Error which according to the doc of the ev2ChangeKey method means Integrity error in cryptogram or invalid secure messaging. MAC (EV2 Secure Messaging)
Please find the code below. I appreciate any help. Thanks guys! :)
// 16 bytes AES128 Key.
final byte[] NEW_KEY = {(byte) 0xEE, (byte) 0xFF,
(byte) 0xBB, (byte) 0xDD, (byte) 0xAF, (byte) 0xDF, (byte) 0xFF,
(byte) 0xCC, (byte) 0xBB, (byte) 0xAF, (byte) 0xDF, (byte) 0xFF,
(byte) 0xDD, (byte) 0xCC, (byte) 0xAF, (byte) 0xDF};
final byte[] APP1_ID = new byte[]{0x10, 0x00, 0x00};
void createAppAndInitiliaseKeySet() {
EV2ApplicationKeySettings appSettings = new EV2ApplicationKeySettings.Builder()
.setAppKeySettingsChangeable(true)
.setAppMasterKeyChangeable(true)
.setAuthenticationRequiredForFileManagement(true)
.setAuthenticationRequiredForDirectoryConfigurationData(false)
.setKeyTypeOfApplicationKeys(KeyType.AES128)
.setApplicationKeySets(true)
.setMaxNumberOfApplicationKeys(2)
.setNumberOfKeySets(3)
.build();
KeyData appKeyData = new KeyData();
appKeyData.setKey(new SecretKeySpec(SampleAppKeys.KEY_AES128_ZEROS, "AES"));
desFireEV2.createApplication(APP1_ID, appSettings);
desFireEV2.selectApplication(APP1_ID);
desFireEV2.authenticateEV2First(0, appKeyData, new byte[]{0, 0, 0, 0, 0, 0});
desFireEV2.initializeKeySet((byte) 0x01, KeyType.AES128);
// Execution fails on this line
desFireEV2.ev2ChangeKey(1, 0, KeyType.AES128, SampleAppKeys.KEY_AES128_ZEROS, NEW_KEY, (byte) 2);
desFireEV2.ev2ChangeKey(1, 1, KeyType.AES128, SampleAppKeys.KEY_AES128_ZEROS, NEW_KEY, (byte) 2);
desFireEV2.finalizeKeySet((byte) 0x1, (byte) 0x1);
desFireEV2.rollKeySet((byte) 0x01);
}
Regards,
Diego
+ 1 | - 0
Hi Diego Palomar, Do you solve the problem? What SDK do you use?
+ 0 | - 0
Hi Mike. I haven't solved the problem yet :$ I'm using TapLinx SDK 1.1
+ 0 | - 0
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.