Host-based Card Emulation, any guidance please?
Asked Answered
B

1

1

I'm new to this field, I got a Nexus S ( CyanogenMod11 = Android Kitkat 4.4.2) And I need to use HCE (Host-Based Card Emulation) mode in order to emulate a contactless card.

Any guidance on the steps and the tips I need to follow in order to accomplish this? ( - Do I need to program the simulated Secure Element? put it on cloud? )

P.S: I have to use the new Reader Mode also, because my app is going to be read by another Android NfC-enabled phone and not by an NFC reader.

Thank you.

Benildis answered 7/6, 2014 at 17:31 Comment(0)
N
3

Before CyanogenMod 11, CyanogenMod supported its own host-based card emulation functionality. You could register a foreground dispatch for the android.nfc.tech.IsoPcdA technology and could then emulate a smartcard by using the IsoPcdA.transceive() method. See Nikolay Elenkov's blog post on how to use this API.

However, browsing through the CyanogenMod 11 source (specifically tht of the NFC service) it seems that this functionality has been dropped in version 11 in favor of Android 4.4's official HCE API.

The official Android 4.4 HCE API permits apps to emulate a contactless smartcard (ISO 14443-4 + ISO 7816-4 APDUs) in an Android service. That service would handle all incoming command APDUs for an application and generate proper response APDUs. See the official API user guide for further information on how to register such a HCE service and this answer on how to handle incoming command APDUs within your HCE service.

Unfortunately this API is not available either on devices that use libnfc-nxp as the low-level NFC stack (see the empty implementation of routeAid() and enableRoutingToHost() in the CyanogenMod 11 source code).

So to summarize this, it seems as if it's currently not possible to do host-based card emulation on a Nexus S with CM 11.

Nevillenevin answered 11/6, 2014 at 7:36 Comment(6)
Thanks a lot for the detailed response. So, basing on comments in Nikolay Elenkov's blog, his method is functional on Nexus S with CM9/CM10. And, apparently, it is my one and only solution? Another question please, using Nikolay Elenkov's method, is it possible to use another Android NFC-enabled device instead of an NFC reader (like in the New Reader Mode)? Thanks again, I'd appreciate if you answer me soon, it is really urgent ;) ^_^ AndBenildis
@Benildis Correct, if you use CM9 (actually CM9.1 I think) or CM10 on the Nexus S, you can use those CyanogenMod HCE extensions. Regarding access from another Android NFC device, the same restrictions as for the official Android HCE apply (i.e. you need to disable peer-to-peer communication through using the reader-mode API).Nevillenevin
Sorry if i don't understand very well, you mean that it is not possible to do "the reading from another CM9.1/CM10 NFC device" ?Benildis
No it's not as such a device would try to connect using peer-to-peer mode and not using reader/write mode.Nevillenevin
And is there a tutoriel to show me how to do that in details? thank you :DBenildis
Other than what's already linked above: not that I'm aware of.Nevillenevin

© 2022 - 2024 — McMap. All rights reserved.