Android Question Possible to get ATR from smartcard on Android?

Sandman

Expert
Licensed User
Longtime User
(Nothing in this post is about NFC using NDEF.)

When a NFC reader connects to a card it automatically sends a RESET command to the card, which makes the card return with an ATR (Answer To Reset). The ATR contains some information about what type of card it is. This can then affect how you decide to interact with it. So it's pretty good info to have.

To my knowledge it is not possible to request this information in some other way from the card, so I imagine the ATR should be available from when the mobile connected to the card. Do we know if it is available and possible to extract this somehow?

(I am not an expert, if it in fact is possible to send some sequence of bytes to the card to get a (new) ATR, I would be interested in that too.)
 

drgottjr

Expert
Licensed User
Longtime User
this is a waste of your - hopefully - valuable time.

contactless cards have an ats, not an atr (that's for contact-ful cards). the terms are often
used interchangeably, but there are technical differences. the biggest one being that android
gives you an emulated ats. android generates the ats automatically, and there is no api to
change its contents. since android is the first in line to discover an nfc tag, the only way
to get ahead of it is to write your own nfc chip driver and insert it where android's currently goes.

but it's not all bad news: the so-called historical bytes for nfc-a tags are found in the atr/ats,
and these bytes are available. what you make of them is another story.
start here: https://cardwerk.com/smart-card-standard-iso7816-4-section-8-historical-bytes/
(my favorite passage: "The coding and meaning of this byte are outside the scope of this part of the
ISO/IEC 7816." in other words, if the people who wrote the standard don't know what a given byte
means, who does?)

in addition to hearing about historical bytes, you may also run across the so-called DSFID.
to paraphrase humpty dumpty, "when i use the dsfid, it means what i choose it to mean."
its meaning is up to the creator of the system.
 
Upvote 0
Top