Forum Replies Created

  • Re: Reply To: DesFire EV2 BackupData file write and read

    7. April 2020 at 14:42
    in reply to: DesFire EV2 BackupData file write and read
    Hi Support,

    I have solved the problem.

    Thank you very much for your support and effort. Really appreciate it.

    Bye
    + 0  |  - 0

    Re: Reply To: DesFire EV2 BackupData file write and read

    7. April 2020 at 14:23
    in reply to: DesFire EV2 BackupData file write and read
    Hi Support,

    Thanks for your effort.

    In the above posts (code snippets) you are using the default key for authentication.

    If you change the default AES key to the custom then your code should also fail.

    In my code if I use default AES key (all zeros) then everything works. But I am not using default keys. I have changed the keys after creating application.

    Can you try to write and read after changing the default key.

    Thanks
    + 0  |  - 0

    Re: Reply To: DesFire EV2 BackupData file write and read

    7. April 2020 at 9:13
    in reply to: DesFire EV2 BackupData file write and read
    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

    Re: Reply To: DesFire EV2 read linear record

    3. April 2020 at 11:42
    in reply to: DesFire EV2 read linear record
    Hi Support,

    Thanks for the reply.

    According to the documentation readRecords description is following:

    byte[] readRecords(int fileNo,
    int offsetRecords,
    int noOfRecords)

    Parameters:
    fileNo - Record file number.
    offsetRecords - Offset from which records is read.
    noOfRecords - Number of records to read.

    Returns:
    read records as byte[]


    In my code i have

    byte[] userData = desFireEV2.readRecords(objectFileNo, 0, 1);


    where
    objectFileNo is 0,
    offsetRecords is 0,
    noOfRecords is 1

    since i have only written the record once.

    I am still receiving the same error.

    com.nxp.nfclib.exceptions.InvalidResponseLengthException: Boundary Error


    To try your answer i even used readRecords with more parameters which is below.

    byte[] readRecords(int fileNumber,
    int offsetRecords,
    int numberOfRecords,
    int recordSize,
    IDESFireEV1.CommunicationType communicationSettings,
    int filesize)


    But still receiving the same error message.

    What am I missing?
    Please help.

    + 0  |  - 0

    Re: Reply To: DesFire EV2 read linear record

    3. April 2020 at 11:42
    in reply to: DesFire EV2 read linear record
    Hi Support,

    After much debugging I found out that after
    desFireEV2.createFile(1, new DESFireFile.LinearRecordFileSettings(
    IDESFireEV1.CommunicationType.Enciphered, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
    fileSize, 1, 1));
    desFireEV2.writeRecord(1, 0, data, IDESFireEV1.CommunicationType.Enciphered);
    desFireEV2.commitTransaction();


    When I read the file settings with
    DESFireFile.LinearRecordFileSettings fileSettings = (DESFireFile.LinearRecordFileSettings) desFireEV2.getFileSettings(1);


    And log the result with
    Log.i(TAG, "fileSettings: => MaxNumberOfRecords: " + fileSettings.getMaxNumberOfRecords()
    + " CurrentNumberOfRecords: " + fileSettings.getCurrentNumberOfRecords() +
    " RecordSize: " + fileSettings.getRecordSize() + " fileType: " + fileSettings.getType());


    I am getting the 0 as currentNumberOfRecords
    I/DemoActivity: fileSettings: => MaxNumberOfRecords: 3, CurrentNumberOfRecords: 0, RecordSize: 500, fileType: RecordLinear


    Why is the currentNumberOfRecords = 0?
    I am banging my head to understand.

    Thanks in advance.
    + 0  |  - 0

    Re: Reply To: DesFire EV2 BackupData file write and read

    3. April 2020 at 9:50
    in reply to: DesFire EV2 BackupData file write and read
    Hi Support,

    Thanks for the reply.

    I tried as you asked for. But i'm getting the same result.

    Below is what i tried after setting MACed communication type during file creation.

    byte[] data = {(byte) 0x01, (byte) 0x12, (byte) 0x11};
    desFireEV2.writeData(0, 0, data, IDESFireEV1.CommunicationType.MACed);

    Utilities.dumpBytes(desFireEV2.readData(0, 0, 6, IDESFireEV1.CommunicationType.MACed, backupFileSize));


    I even tried with Enciphered and Plain but produced similar result (0x000000000000).

    During the both write and read actions no exceptions are thrown but the data read are all zeroes.

    Seems like nothing is being written to the file.
    I've been stuck for a week over this.

    Please help



    + 0  |  - 0
Viewing 6 posts - 1 through 6 (of 6 total)