Desfire AppID

Forum / MIFARE SDK / Desfire AppID

  • 16. October 2014 at 2:30
    My agency just got their first prototype desfire card that is anticipated to go into production (50K employee agency). I'm trying to connect to, authenticate and read a particular file. So when I present my android device, onDESFIRECardDetected is fired. I connect to the tag (desfire object), authenticate by passing my agency's master and app key and providing the appId. My next step is to try to read a particular file within the application. I don't see any method that accepts the fileId??? I see the command 'Read(int iNoOfBytes)', which the javadoc states, "iNoOfBytes - Number of bytes to read", but from where???. However, when I run my application and put in an arbitrary value for the parameter (e.g. say, 1), an exception is thrown stating, "File Not Found".

    Basically, how do I read a particular FileID within an application for a Desfire card using the SDK???
    + 0  |  - 0

    Re: Desfire AppID

    16. October 2014 at 11:22
    Hi,
    Before using any DESFire Lite API please follow the following steps. for these steps to work, you should have either factory default card ( New card where card master key is set to all zeros and key is of type 3DES.) OR you must know the Card Master Key and it must be of type AES.

    1) Use format API of the DESFire class, this API erases all the data in the card. [ this Step is not required if you have factory default card. ]

    2) Use personalize API of the DESFire class, this creates default application with std file in it for reading and writing. And changes the card master key to AES type.This API should be used once for each new card. OR this should be used after formatting the card.

    3) After personalize you can able to read and write to the new card. For future reading and writing with the already personalized card, please authenticate the card before reading and writing.

    For Factory default card.
    a) Personalize --> Read/Write.
    b) authenticate --> Read/Write.

    For Personalizing again with different APP Id and key.
    a) format --> personalize --> Read/Write.

    NOTE: Lite SDK Limitations:
    1) you cant use the card personalized with different application.
    2) you dont have control on creating multiple applications and files.
    Regards,
    MIFARE SDK Team
    + 0  |  - 0

    Re: Desfire AppID

    16. October 2014 at 12:24
    Hi,
    Below are the steps to create application and writing and reading from it for factory default card.

    public void onDESFIRECardDetected(final DESFire objDesfire) {
    NxpLogUtils.i(TAG, "Desfire Card Detected!!");
    desfire = objDesfire;
    /* Insert your logic here by commenting the function call below. */
    // New Card Master Key.
    byte[] cardKey = new byte[] { 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    // New Application Key.
    byte[] appKey = new byte[] { 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

    // Application ID.
    byte[] appID = new byte[] { 0x12, 0x12, 0x12 };
    // Data to write.
    byte[] data = new byte[] { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
    0x11 };
    try {
    objDesfire.connect();
    objDesfire.setTimeOut(2000);
    // Only Use First personalize API, for subsequent use with the same card replace
    // personalize with authenticate API.
    objDesfire.personalize(cardKey, appID, appKey);
    objDesfire.write(data);
    byte[] Readdata = objDesfire.read(5);
    objDesfire.close();
    } catch (Exception t) {
    showMessage("Unknown Error Tap Again!", 't');
    }

    }

    Note: please refer sample application code for further information.
    Regards,
    MIFARE SDK Team
    + 0  |  - 0

    Re: Desfire AppID

    16. October 2014 at 13:52
    I have already reviewed the sample code (before I sent my first post).

    The card I have can not be formatted. It is pre encoded to use with our current access control system. I want to access the badgeId that is encoded into a particular file (within a particular application) in the Desfire card.

    From my understanding of Desfire cards, it is structured in a hierarchical fashion (as oppose to Mifare Classic, our old card). That is, the desfire card can contain several applications (max 28) and within each application, it can contain several files (max 16 per app). I see the command Read/Write but how does this relate to the files. That is, back to my first question, how do I read a File???

    Is it also a limitation that I can't read an already encoded cards with the NXP SDK??? That is, do I need to revert back to sending APDU commands specific for the Desfire card. Seems like a big limitation if so.
    + 0  |  - 0

    Re: Desfire AppID

    17. October 2014 at 13:16
    Hello Implicete1796,
    Yes, single file access is the limitation with the LITE version of MIFARE SDK. But we are working on Advanced version SDK which will be released soon. Please bear with us.


    Thank you.
    + 0  |  - 0

    Re: Desfire AppID

    19. December 2014 at 4:45
    Hi MIFARE team,

    We are using DESFire card, I want a tool on Windows to format card, update master key, app ID, and application ID. Do you support this tool? Where can I download it?

    An other question:
    Is there any way to read/write card without master key? just app ID and app key is required.
    Thanks very much!
    + 0  |  - 0

    Re: Desfire AppID

    3. September 2019 at 11:17
    Hi Wisekey,

    For Windows we have our own development tools which you also can get. Please check this link:

    RFID-DISCOVER

    It is up to you if you are the card issuer. Of course, you can prepare a card with your data and set the access to this data as “free”, readable in plain without any key access before.

    The TapLinx team
    + 0  |  - 0
Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.