Host Card Emulation


Published on

Host Card Emulation in android

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Host Card Emulation

  1. 1. Host Card Emulation (HCE)
  2. 2. NFC
  3. 3. NFC APPS
  4. 4. Card Emulation with a Secure Element
  5. 5. Host-based Card Emulation • • • • Host Card What? Host Card Why? Implementing an HCE Service Host Card Security
  6. 6. Host Card What? • Where data is routed ? • Support for many different protocols • Android NFC devices functioning as readers • ( IsoDep class). HCE services
  7. 7. Host Card Why? • No more complex SE cards. • Multiple NFC payment wallets can be on the • • • phone No worrying about SE storage size. No need to pay the Carrier for Over-the-air SE provisioning and lifecycle management. Enabling any wallet to use it to communicate to a PoS
  8. 8. Implementing an HCE Service
  9. 9. Implementing an HCE Service • Service selection • AID groups and categories • Service implementation • Service manifest declaration and AID registration
  10. 10. Service Selection
  11. 11. Service selection • • • • • ISO/IEC 7816-4 specification Application ID (AID). Length between 5 and 16 bytes AID well-known and publicly registered What if you want to deploy new reader infrastructure for your own application ?
  12. 12. AID Groups • AID group is a list of AIDs that should be • • considered as belonging together by the OS HCE service may need to register multiple AIDs to implement a certain application Android guarantees one of the following o All AIDs in the group are routed to this HCE service o No AIDs in the group are routed to this HCE service
  13. 13. AID groups and categories • Each AID group can be associated with a • • category avoid mentioning AIDs in any user-facing parts of your application. Android 4.4 supports two categories: o CATEGORY_PAYMENT o CATEGORY_OTHER
  14. 14. Checking for HCE support • Your application can check whether a device supports HCE by checking for the FEATURE_NFC_HOST_CARD_EMULATION feature.
  15. 15. Service implementation • • The first step is therefore to extend HostApduService. HostApduService declares two abstract methods that need to be overridden and implemented
  16. 16. Service implementation (2) • • • • • processCommandApdu() is called whenever a NFC reader sends an Application Protocol Data Unit (APDU) to your service "SELECT AID" APDU. processCommandApdu() run on the main thread. When Android will stop forwarding new APDUs from the reader to your service ? o The NFC reader sends another "SELECT AID" APDU, which the OS resolves to a different service o The NFC link between the NFC reader and your device is broke. In both of these cases,onDeactivated() implementation is called
  17. 17. Android Protocol Data Unit (APDU) • • • APDUs are the application-level packets being exchanged between the NFC reader and your HCE service. APDU is a half-duplex. Android’s HCE implementation only supports a single logical channel.
  18. 18. Android Protocol Data Unit (APDU) (2)
  19. 19. Manifest declaration and AID registration
  20. 20. Manifest declaration and AID registration (2)
  21. 21. Screen Off and Lock-screen Behavior
  22. 22. AID Conflict Resolution • The same AID can be registered by more • than one service. Checking if your service is the default
  23. 23. Secure element AID registration
  24. 24. Secure element AID registration (2)
  25. 25. Coexistence with Secure Element Cards
  26. 26. HCE and Security • • BIND_NFC_SERVICE system permission. Android Application Sandbox,
  27. 27. HEADER
  28. 28. Ahmed Fathallah Junior android developer