Can a JavaCard emulate a MIFARE Ultralight or NTAG NFC tag?

我与影子孤独终老i 提交于 2019-12-10 19:28:24

问题


I would like to write a Java Card applet that responds to an NFC reader as if it was a regular MIFARE Ultralight or NTAG NFC tag.

I am aware the MIFARE protocol is proprietary and may be a little more difficult but surely I should be able to achieve emulation of the NTAG protocol.

If I match the NTAG specification and respond to the correct APDUs then I can surely emulate an NTAG?

Update to original question

I think I asked my original question incorrectly. I'm not looking to emulate a specific tag per sé. What I am actually trying to do is use a Java Card powered card to be able to supply dynamic information to a smartphone such as Android or Apple iPhone using the new Core NFC API. Note that this API is said to support tags of type 1 through 5. I would like to be able to write a Java Card applet that can run on a contactless smartcard and allow (simplex) communication with a smartphone.

I guess my question is: How can I determine the flow of APDU from the Core NFC API so that I can write an applet that will respond suitably?


回答1:


No, that's not possible. MIFARE Ultralight, NTAG, and other NFC Forum Type 2 tags operate on top of the anti-collision and framing protocols defined in ISO/IEC 14443-3A (also called NFC-A).

Java Card applets (in general) communicate using APDU commands (a protocol layer defined in ISO/IEC 7816-4). The Java Card run-time environment only passes APDU commands to applets. Contactless smartcards exchange these APDU commands on top of the ISO-DEP half duplex transmission protocol (as specified in ISO/IEC 14443-4). This transmission protocol, in turn, sits on top of one of the framing protocols defined in ISO/IEC 14443-3 (also called NFC-A and NFC-B).

+-------------------------+  +-------------------------+
| MIFARE Ultralight/NTAG  |  | Contactless Java Card   |
+-------------------------+  +-------------------------+

                             +-------------------------+
                             | Commands: APDUs         |
                             | (ISO/IEC 7816-4)        |
+-------------------------+  +-------------------------+
| Commands: Proprietary   |  | ISO-DEP                 |
| or NFC Forum Type 2ary  |  | (ISO/IEC 14443-4)       |
+-------------------------+  +-------------------------+
| Framing: NFC-A          |  | Framing: NFC-A or NFC-B |
| (ISO/IEC 14443-3 A)     |  | (ISO/IEC 14443-3 A/B)   |
+-------------------------+  +-------------------------+
|           ...           |  |          ...            |
+-------------------------+  +-------------------------+

Consequently, while both technologies share common protocol layers, Java Card applets can only exchange APDU commands and cannot control much of the lower protocol layers directly.

Edit (based on ErikM's remark):

While it's not possible to emulate NFC Forum Type 2 tags on Java Card (unless there would be dedicated hardware support on your smartcard platform --- And I don't think that this currently exists.), you could easily emulate an NFC Forum Type 4 tag on any Java Card contactless smartcard. So if your goal is to emulate an NFC tag that presents an NDEF message to e.g. a smartphone, then you could follow this approach. There is even open-source implementations of such applets, e.g.

  • https://github.com/promovicz/javacard-ndef
  • https://github.com/slomo/ndef-javacard



回答2:


While NTAG 2xx is not doable, as Michael Roland explained above, one could write an applet acc. to T4T. Not sure however if it would be worth the effort, as both NTAG 2xx as well as DESFire or NTAG 413 DNA are probably way cheaper. Of course, as a technical challenge it might be worth doing.



来源:https://stackoverflow.com/questions/44761119/can-a-javacard-emulate-a-mifare-ultralight-or-ntag-nfc-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!