Question

I have some card, wanted to get ATR from it (using method from some SDK). Implementation looks like this:

unsigned char ATR[128]={0};
int len=33;
int maxlen=33;
ret = sd7816_ATR(0,1,ATR,len,maxlen,1);

first, second and last parameters to sd7816_ATR function should be like that. The length fields I tried changing to different values, including 0 but no help.

My concern is the ATR string I am sending is empty in the beginning, and I am expecting something to get written in it after the call finishes (which actually returns success).

But after call ATR is still empty .. What can be going wrong here?

(I want to find out if card is of ISO/IEC 14443 or ISO/IEC 7816 type).

Was it helpful?

Solution

You are trying to receive an ATR for a command specific for a ISO/IEC 7816-3 contact card. In this particular case, that's requested from a (SIM form) SAM card reader. However, you are trying to read out the contactless based reader.

Now contactless cards do not have an ATR. Some cards do have an ATS (i.e. ISO/IEC 14443 Type A cards), but that should be requested by a similar 14443 SELECT command. Some cards, particularly Type B cards, contain an EF.ATR to make up for the lack of (space within the) ATR. Still, an ATR/ATS has only limited functionality for identifying cards.

ISO/IEC 7816 is comprised of several parts: parts 1 to 3 describe contact cards and 4 and higher describe the Application level APDU commands and file structure of processor cards. If your contactless card implements ISO/IEC 7816-4 then you can - in general - also directly use the PCSC interface to send and receive APDU's to/from the card.

In general readers are for contact or contactless only. If you have a reader which contains both contact and contactless operation then in general they will show up as two different readers in the operating system. So in general, if you know the reader, you know if the card is a contact card or contactless card.

SAM slots may not be identified as readers by the operating system - you may only be able to access them using a low level interface. They are mainly used as a secure storage of keys from the terminal/inspection system/interface device or whatever the name is of the system that reads out the card.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top