Smart Card Library

The smart card API provides an application access to the smart card functionality on the device.

About the Smart Card API

The smart card API provides an application access to the smart card functionality on the device.

The smart card functionality includes:
  • cryptographic API (for example, for encryption, decryption, and signing operations)

  • smart card PIN API (for example, to verify a PIN or to get the number of remaining attempts)

  • smart card session management (for example, to open or close a session)

  • reader functionality (for example, to list available readers and monitor reader states)

  • ability to send custom Application Protocol Data Units (APDUs)

To use the smart card API functions, the application must have the _sys_access_smartcard_api capability. To create an extended functionality context for using the custom APDU API, the application also need to have the _sys_access_extended_smartcard_functionality capability.

To be granted these capabilities, the application must add the appropriate permission line in its bar-descriptor.xml file, for example, "<permission>_sys_access_smartcard_api</permission>".

For more information on these capabilities, see App permissions on

Here is a sample flow for accessing the smart card functionality:
  1. Create a context using sc_context_create().

  2. Allocate a handle for accessing the reader functionality using sc_allocate_handle( context, SC_HANDLE_READER_SLOT_LOGICAL, reader_name ).

  3. Obtain supported card drivers that can work with the card in the reader using sc_get_card_types_for_reader().

  4. Choose the card driver to use and allocate the card holder verifier handle using sc_allocate_handle( context, SC_HANDLE_CARD_HOLDER_VERIFIER, chosen_card_name ).

  5. Attach to the card via the reader using sc_attach_by_reader( context, reader_name, SCARD_SHARE_EXCLUSIVE ).

  6. Execute required actions on the card.

  7. Detach from the card using sc_detach().

  8. Destroy the context using sc_context_destroy().

Last modified: 2015-07-24

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus