简体   繁体   中英

Android/NFC: read ATR from Smartcard (EMV)

I got an EMV Smartcard wich I want to communicate with with my Mobile phone. The communication itself works without problems via IsoDep, but I can't figure out how I can get the ATR. As far as I know the intent should contain the ATR, can someone please tell me the code I need therefore?

Or if this is not possible maybe someone knows how to warm reset the card with a command like SELECT where the answer is the ATR.

Contactless cards do not have an ATR. You may be interested in the historical bytes of the ATS (Answer to Select), though. You can retrieve these by calling getHistoricalBytes() :

Tag tag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG));
IsoDep iso = IsoDep.get(tag);
NfcA nfcA = NfcA.get(tag);
if (nfcA == null || iso == null)
   return; // not an IsoDep+NfcA tag
byte[] histBytes = iso.getHistoricalBytes();
...

Keep in mind that this only works for ISO 14443 Type A tags ( NfcA ). For Type B tags ( NfcB ), you may want to investigate getHiLayerResponse() .

Contactless card do return ATR. However, you can't get ATR from current android NFC API. Android NFC API only returns historical bytes from ATR.

The reason that contactless card do return ATR: Please note that ATR is 7816 Answer to reset. The reader (nfc phone in this case) talks to smart cards using ISO 7816 (T=CL) APDU exchange, which is transported via contactless interface ISO 14443-4. Since there is ISO 7816 in this case, you will get ATR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM