appletjavacardgpshell

Java Card applet selection


I encountered a problem performing select for an installed applet. The applet is HelloWorld app from the Java Card SDK 2.2.1

If I understand correctly, after opening secure channel I should select an applet (execute the select command) and then send an apdu command to the selected applet. After that, HelloWorld should return the payload of the received command in response.

I am using gpshell. The applet is installed on a physical card. get_status -element 20 returns the following:

enter image description here

When I try to execute select I get error 6108. (Also tried d00000006203010c01 - same result)

The sequence of commands to execute in gpshell is as follows:

mode_211

enable_trace

set_context

card_connect

select -AID A000000003000000

open_sc -security 3 -scpimpl 0x15 -scp 2 -keyind 0 -key 404142434445464748494a4b4c4d4e4f -keyDerivation emvcps11

get_status -element 20

select -AID d00000006203010c01

I'm just starting to work with Java Card, so maybe the problem is obvious. What am I doing wrong?

P.S. According to https://www.eftlab.com/knowledge-base/complete-list-of-apdu-responses code 6108 is not an error code(??) It is Info message (61 - SW1; 08 - number of bytes available - SW2 ). So why gpshell terminate connection?


Solution

  • As you already have guessed, your command is returning data, and you should issue a GET RESPONSE with Lc = SW2 in order to read the remaining bytes. The response probably contains the FCI, FCP, AID, or other proprietary data returned by the applet upon selection.

    The command should be as follows

    00 C0 00 00 08
    

    The reason why the command is returning 61 XX instead of the response bytes followed by 90 00 seems to be that gpshell is sending here the SELECT command without Le field (case 3 - no response). The best move would be to send the SELECT command with a Le field set to 00 (case 4 - return all the bytes from the response).