Search code examples
androidnfccontactless-smartcardhceemv

Emulate different cards using Android HCE


I would like to implement an app that can support some types of cards. I would like to know the following things:

  1. Can I emulate different types of cards using HCE such as a payment contactless card?

  2. What do I need to implement it?


Solution

  • Can I emulate different types of cards by using HCE?

    That depends on the specific card type that you would want to emulate. Android HCE can emulate any smartcard application that implements ISO/IEC 7816-4 on top of ISO/IEC 14443-4 (ISO-DEP) and that uses the application selection mechanism defined in ISO/IEC 7816-4 with any well-known AID.

    This means that you could, for instance, emulate

    Note that besides the technical implementation aspect there might (will!) also be some organizational barriers that you need to overcome...

    What do I need to implement it?

    From a pure technical perspective, you need to obtain, read, and understand the technical specifications of the card scheme that you want to implement. You can then implement a HostApduService that speaks the protocol defined in those specifications and that is registered for the AID(s) used by the specification/the reader system. You could even use mutile HostApduService components to emulate different smartcard applications (as long as they are addressed by a different AID) in once HCE application.

    From an organizational perspective there is certainly more than that: Depending on the system, you probably need to obtain permissions/license for your implementation. You also need to get your user media (e.g. cryptographic keys, etc.) registered into the system (typically you can't just extract them from an existing card, that's why secure smartcards are used in the first place).