8

I need to emulate a DESFire EV1 card on an Android device. However, I'm confused on how to use the Mifare SDK (lite or advanced) with the HCE.

Is that even possible? I need to start the project and I had a lot of researches about how the data are stored and ciphered in the DESFire cards but I ended up with the fact that I need to use Mifare SDK on HCE.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
kharbechtein
  • 83
  • 1
  • 4

3 Answers3

14

First of all, you cannot use the MIFARE SDK to emulate cards. The MIFARE SDK provides reader-side functionality only.

Second, you cannot emulate the whole functionality of MIFARE DESFire (EV1) cards using Android HCE. However, you can emulate parts of the MIFARE DESFire protocols (more specifically, you can only emulate ISO/IEC 7816-4 framing (either ISO command set or wrapped native command set) and only if preceded by an ISO SELECT by AID command). If that's sufficient depends on the requirements of the reader side of your system.

  • If your reader only supports the DESFire native command set: You cannot emulate a corresponding card using Android HCE.
  • If your reader uses the wrapped native command set but does not start the communication with an ISO SELECT (by AID) command: You cannot emulate a corresponding card using Android HCE.
  • If your reader uses the wrapped native command set and starts the communication with an ISO SELECT (by AID) command (the AID of MIFARE DESFire is D2760000850100): You can register your HCE service for the DESFire AID and will be able to receive all wrapped native commands after this AID has been selected.
  • If your reader uses the ISO command set but the first command is not an ISO SELECT (by AID) command: You cannot emulate a corresponding card using Android HCE.
  • If your reader uses the ISO command set and starts the communication with an ISO SELECT (by AID) command (either for the MIFARE DESFire AID or (with DESFire EV1) for the ISO AID of one of the DESFire applications): You can register your HCE service for the DESFire AID (or the AID of the specific application) and will be able to receive all ISO commands after this AID has been selected.

Note that there may be licensing issues if you emulate MIFARE DESFire cards.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • Is there any way of checking if the reader supports HCE with an android phone as I dont have the readers implementation. – Anders Larsen Sep 09 '15 at 22:40
  • 2
    In addition: Keep in mind that HCE provides a random UID, so if your reader relies on a fixed UID (i.e. to diversify card keys) this won't work as well (edited the answer but got rejected). – vlp Sep 09 '15 at 22:54
  • @vlp the reject on that edit was perfectly fine. Please don't edit existing answers of other people to add completely new/unrelated information. – Michael Roland Sep 10 '15 at 22:11
  • @MichaelRoland thank you for your reply. What should I do then? Add another answer? Keep it as a comment? – vlp Sep 10 '15 at 22:23
  • Do the restrictions also apply to the MD emulation applet for JavaCards? IS there a good demo/test tool somewhere? – eckes Jun 03 '17 at 21:36
  • 1
    @eckes Basically yes. You also have to select the DESFire AID in that case. – Michael Roland Jun 06 '17 at 09:25
4

MIFARE Classic cannot be emulated in HCE because it works directly on top of ISO 14443-3. HCE emulates the higher layer, ISO 14443-4. But that's the layer where MIFARE DESFire is implemented, so yes it can be done. I have not done it myself but I know at least one company that has made it work, and probably there are several.

mictter
  • 1,358
  • 1
  • 10
  • 13
0

I think Mifare SDK is :

http://www.mifare.net/en/products/mifare-sdk/

If yes then with a simple search "Mifare SDK HCE", I found : http://www.mifare.net/en/micommunity/forum/mifare-and-nfc-reader-ics/can-nfc-phones-operate-rfid-tag-mifare-classic/ And in this thread, Mifare guy said:

Unfortunately the MIFARE SDK does not support HCE.

LaurentY
  • 7,495
  • 3
  • 37
  • 55