Reply To: DesFire EV2 BackupData file write and read

Forum MIFARE SDK DesFire EV2 BackupData file write and read Reply To: DesFire EV2 BackupData file write and read

Re: DesFire EV2 BackupData file write and read

7. April 2020 at 9:13
Hi Support,

Thanks for the reply.

Remember I am working with DesFire EV2 card and commitTransaction is executed after writeData. Even in the first post(code snippet) i had included commitTransaction.

Below is my code snippet and output.

desFireEV2.selectApplication(APP_ID);
desFireEV2.authenticateEV2First(0, SampleAppKeys.MASTER_AES(), new byte[]{0, 0, 0, 0, 0, 0});

desFireEV2.createFile(backupFileNo, new DESFireFile.BackupDataFileSettings(
IDESFireEV1.CommunicationType.MACed, (byte) 0x1, (byte) 0x2, (byte) 0x2, (byte) 0x0,
backupFileSize));
mStringBuilder.append("Created Files \n\n");
desFireEV2.authenticateEV2First(1, SampleAppKeys.KEY1_AES(), new byte[]{0, 0, 0, 0, 0, 0});
mStringBuilder.append(Utilities.dumpBytes(desFireEV2.readData(backupFileNo,
0, 6, IDESFireEV1.CommunicationType.MACed, 128))).append("\n");

desFireEV2.authenticateEV2First(2, SampleAppKeys.KEY2_AES(), new byte[]{0, 0, 0, 0, 0, 0});
byte[] userData = userJson.getBytes(encode);
desFireEV2.writeData(backupFileNo, 0, userData, IDESFireEV1.CommunicationType.MACed);
desFireEV2.commitTransaction();

desFireEV2.authenticateEV2First(1, SampleAppKeys.KEY1_AES(), new byte[]{0, 0, 0, 0, 0, 0});
mStringBuilder.append("Data read from backup: \n")
.append(Utilities.dumpBytes(desFireEV2.readData(backupFileNo,
0, 6, IDESFireEV1.CommunicationType.MACed, 128))).append("\n\n");



mStringBuilder is written to the log.

This is the console log.

2020-04-03 16:37:56.369 10332-10332/com.example.sampleticket I/DemoActivity: Dump Data:Card Detected:DESFireEV2
2020-04-03 16:30:46.478 9862-9862/com.example.sampleticket I/DemoActivity: Dump Data:Created Files 

Data read from backup:
0x000000000000
Data read from backup:
0x000000000000


I have tried creating application with TWO_KEY_THREEDES and everything works fine. In just the case of AES, this issue occurs.

Thanks
+ 0  |  - 0