Page 1 of 2

What is APDU to read ATR ?

Posted: Wed Jul 19, 2017 4:33 am
by leonard
I am newbie in smart card development.
I have a sample of eID and I want to read ATR to check the card support extended APDU or not.
I am using jmrtd api in Android platform, but it is not implement ATR reading function.
I tried command

Code: Select all

"00B0810000" 
but i get

Code: Select all

 "6A 82"
.
Could you give me a suggestion for this?

Re: What is APDU to read ATR ?

Posted: Wed Jul 19, 2017 5:43 am
by UNKNwYSHSA
You can get ATR after card connected.

If you write code, see following:
Using Windows API see https://msdn.microsoft.com/en-us/library/windows/desktop/aa379559(v=vs.85).aspx
Using pyScard see https://pyscard.sourceforge.io/user-gui ... -reset-atr
Using language JAVA and use package javax.smartcardio.Card see http://docs.oracle.com/javase/7/docs/jr ... rdio/spec/
Or other platform/language please tell me. I'll tell you how to got ATR value.

Re: What is APDU to read ATR ?

Posted: Wed Jul 19, 2017 5:51 am
by mabel
Just use pyApdutool to connect your card. ATR value will be directly displayed.


Re: What is APDU to read ATR ?

Posted: Wed Jul 19, 2017 6:31 am
by leonard
mabel wrote:Just use pyApdutool to connect your card. ATR value will be directly displayed.



Thank you for your quick response !
I writing an application in Android and using jmrtd api which.
I wondering is it possible to read ATR by sending a APDU command directly to card instead of using api such as smartcardio...?.
And if it is possible then what is the APDU command I should use?
Because I can not find documents relate to ATR reading command.

Re: What is APDU to read ATR ?

Posted: Wed Jul 19, 2017 10:44 pm
by UNKNwYSHSA
The PassportService is constructed with a CardService instance.
When you using PassportService, you have to create a CardService instance.
The CardService instance have a method called getATR(), you can use it to get ATR value.

PassportService


CardService

Re: What is APDU to read ATR ?

Posted: Thu Jul 20, 2017 3:08 am
by leonard
Thanks for your response.
I already checked the jmrtd api,it provides communication interface base on APDU command (7816-4) between reader and card and support a lot of function and security mechanism, but currently getATR() function is not implemented.
That why I ask the possibility of reading ATR by sending APDU command.
Also Android does not support javax.smartcardio, is there another way to get ATR data in Android ?

Re: What is APDU to read ATR ?

Posted: Thu Jul 20, 2017 10:09 pm
by UNKNwYSHSA
How do you connect the reader to your Android Device? Using OTG?

And how do you send APDUs (You send "00B0810000" and "6982" received in this topic)?
Can you show me your code?

Re: What is APDU to read ATR ?

Posted: Mon Jul 24, 2017 10:16 pm
by leonard
I use android device as a reader and use NFC to tranmit data.
Below is my source code:

Code: Select all

CommandAPDU capdu = new CommandAPDU(ISO7816.CLA_ISO7816, ISO7816.INS_READ_BINARY, (byte)0x81, (byte)0x00, (byte)0x00);
    LOGGER.info(this.getClass().getSimpleName() + IopTest.IOP_READ_ATR +"\n" + Hex.bytesToHexString(capdu.getBytes()));
    try {
      ResponseAPDU rapdu = transmit(capdu);
      atr = rapdu.getData();
      LOGGER.info(this.getClass().getSimpleName() + IopTest.IOP_SW + Hex.bytesToHexString(rapdu.getBytes()));
    } catch (CardServiceException e) {
      e.printStackTrace();
    }

Re: What is APDU to read ATR ?

Posted: Tue Jul 25, 2017 1:31 am
by UNKNwYSHSA
NFC is only for contactless card, contactless card do not have ATR.

Re: What is APDU to read ATR ?

Posted: Tue Jul 25, 2017 3:21 am
by leonard
Thank you for your answer.
I found that :
Contactless cards do NOT provide a real ATR. Instead, a pseudo-ATR generated by the PC/SC driver that connect your smartcard reader to applications is return (the value which I get when use reader to read the card), for example:

The pseudo-ATR (not generated or "returned" by the card) is used to pass (otherwise inaccesible) information about the contactless protocol to the application layer. As Android does not use PC/SC for access to smartcards through NFC there is also no ATR involved here.

But I still have questions:
1. If contactless cards dose not return ATR and pseudo-ATR is used to pass information about contactless protocol then what information I can get?
2. As I read in ISO 7816, if cards support extended length it should be store in ATR, but if in case contactless card ATR is not not real or returned by card then how can i get such kind of information.

I also read about definitions of ATS (answer-to-select) for type A (which comes close to an ATR as in that it also contains historical bytes) and an answer-to-ATTRIB for type B.
But I still do not have clear understanding about these definitions.
Could you give some documents that specify these matters!

Thank you very much for your support.