[Muscle] SELECT, GET RESPONSE, and pcsc-lite

Ludovic Rousseau ludovic.rousseau at gmail.com
Mon Feb 11 00:00:04 PST 2008


On Feb 11, 2008 2:57 AM, Geoff Elgey <Geoff.Elgey at quest.com> wrote:
> G'day,

Hello,

> I am investigating writing a card applet, and using pcsc-lite to communicate to the card.
>
> My understanding of the calling stack is as follows:
>
>   application -> pcsc-lite -> ccid -> reader -> card -> applet

Exact.

> I am interested in how to handle the ISO7816-4 SELECT command.
>
> For T0 protocol, it seems that the application will send a SELECT command and get back a 61xx response. The application then sends a GET RESPONSE command to fetch the SELECT response data and get back a 9000 response.
>
> For T1 protocol, it seems that the SELECT command will return the response data and a 9000 response to the application.
>
> I understand that ISO7816-4 Annex A mentions that a case 4 command APDU (such as a SELECT with Le present) should be split up into 2 x command APDU by the "transmission system" when T0 protocol is used, but I am wondering what constitutes the "transmission system" in this context. Is it pcsc-lite? The ccid driver? Within the reader?

PC/SC does not correctly manage case 4 APDU. pcsc-lite and the driver
will not send a GET RESPONSE by them self.

You should not use case 4 APDU but use a case 3 SELECT (so without Le)
and a case 2 GET RESPONSE.

> The corresponding question is how the applet should handle SELECT: does it return response data and 9000 in all cases, or only if an Le is present in the APDU, or does the applet need to recognize when to return 61xx for SELECT and also handle a GET RESPONSE command APDU?

This should be managed automatically by the JVM inside the card. But I
am not a Java Card expert.

> In short, I'm trying to figure out what stuff I need to handle in the applet and what stuff is already handled for me by pcsc-lite, ccid, the reader, the card manager, etc.

Good luck

-- 
 Dr. Ludovic Rousseau


More information about the Muscle mailing list