How to configure communication with the external Secure Element

We have designed a simple API to communicate with external Secure Elements.

Sample code

We have created a sample Android application that uses our API to help you to develop your application as quickly as possible.

Please download the sample code here.

External SE library v1.6.0

This release of the library focuses on ease of the negotiation for best speed, the changes are:

  • powerOn will by default auto negotiate the best card parameters based on the card’s ATR, use setAutoNegotiate(false) to suppress this behavior
  • powerOn_5V_ISO() and powerOn_5V_EMV() are now deprecated due to stability issues

SeCommunicaton Library v1.6.0

API documentation

This SmartCardReader API helps you to develop Android applications which communicate with your external Secure Elements.

Code Example

// obtain smartcard reader instance 
SmartcardReader reader = SmartcardReader.GetInstance();

// open smartcard reader with default baud rate 38400
// reader.openReader(115200); can be used for higher baudrate
reader.openReader();

// power on smartcard reader
reader.powerOn();

// send APDU
reader.sendApdu(new byte[]{});

// power off smartcard reader
reader.powerOff();

// close smartcard reader
reader.closeReader();

Documentation
Class SmartcardReader com.famoco.secommunication.SmartcardReader

_ Method Summary
void closeReader() Close Smartcard reader
static SmartcardReader getInstance() Get SmartcardReader singleton instance
boolean openReader() Open Smartcard reader
boolean openReader(int baudrate) Open Smartcard reader with baudrate
void powerOff() Power off the Smartcard reader
byte[] powerOn() Power on the Smartcard reader
byte[] sendApdu(byte[] apdu) Transmits the specified command APDU and returns the response APDU.

Note on Secure Element powerOn()

A secure element can have different power requirements (1.8V, 3V, 5V). By default, we use “power_up_iso” to power the SE.

    power\_up\_iso

This command does not need any argument. The principle consists in an activation of the card as described in ISO 7816-3:

  • Attempt to activate the card at a VCC of 3V, if the card answers correctly and if it indicates in its ATR that it is a class A or a class AB card (TAi with T=15), then the command is finished and the ATR is returned to the host,

  • If in the previous stage, the card did not answer correctly or did not specify in its ATR that it was a class A or a class AB card, a new activation of the card is launched at 5V. If the card does not answer to the reset, a status giving an error code is returned to the application, otherwise the answer contains all the parameters of the card.

However, some secure elements don't comply with this process. So we also give direct access to methods to power on secure element with specific voltage / options:

byte[] atr = mSmartcardReader.powerOn(); --> Now same as powerOn_3V_ISO() but in old releases same as powerOn_ISO()
byte[] atr = mSmartcardReader.powerOn_ISO();
byte[] atr = mSmartcardReader.powerOn_1_8V_ISO();
byte[] atr = mSmrtcardReader.powerOn_1_8V_EMV();
byte[] atr = mSmartcardReader.powerOn_3V_ISO();
byte[] atr = mSmartcardReader.powerOn_3V_EMV();
byte[] atr = mSmartcardReader.powerOn_5V_ISO();
byte[] atr = mSmartcardReader.powerOn_5V_EMV();

Advanced usage

FAMOCO devices use the NXP TDA8029 smartcard reader. For more details in communicating with the external Secure Element, you can refer to the following document:

Old releases

Below you will find all previous releases:

External SE library v1.5.0

This release of the library focuses on T=1 compatibilities and bug fixes, the changes include:

  • API sendApdu will Send APDU via T=1 if negotiate is called with T=1
  • T1 sequence number will be reset when the SmartcardReader is powered off

SeCommunicaton Library v1.5.0

External SE library v1.4.0

This release of the library focuses on T=1 compatibilities and documentation, the changes include:

  • New API send_T1_IFSRequest to work around the native command Ifsd_request issue with high speed cards
  • The javadoc documentation is now included in the library

SeCommunicaton Library v1.4.0

External SE library v1.3.0

This release of the library focuses on speed and T=1 compatibilities, the changes include:

  • Easy support on baudrate 115200bps between host and smartcard reader for FX100,5 and above
  • New API processT1Command for smartcard reader process_T=1_command, request and response chaning supported.
  • New API setClockCard for smartcard reader set_clock_card command.
  • New API negotiate for smartcard reader negotiate command
  • New API setCardBaudRate for smartcard reader set_card_baud_rate command.
  • New API ifsdRequest for smartcard reader Ifsd_request command, it is to negotiate the IFSD size in T=1 protocol.
  • Add option to enable/disable alpar frame hex dumping.

SeCommunicaton Library v1.3.0

Sample Smartcard Application v1.5.0

To enable you to develop your own application as quickly as possible, we have created a sample android application that takes advantage of our custom API. This sample application uses the library to access a SE.

SmartcardExample v1.5.0