Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

smartcardio ResponseAPDU buffer size issue?

843851Apr 16 2009 — edited Aug 17 2009
Greetings All,

I’ve been using the javax.smartcardio API to interface with smart cards for around a year now but I’ve recently come across an issue that may be beyond me. My issue is that I whenever I’m trying to extract a large data object from a smart card, I get a “javax.smartcardio.CardException: Could not obtain response” error.

The data object I’m trying to extract from the card is around 12KB. I have noticed that if I send a GETRESPONSE APDU after this error occurs I get the last 5 KB of the object but the first 7 KB are gone. I do know that the GETRESPONSE dialogue is supposed to be sent by Java in the background where the responses are concatenated before being sent as a ResponseAPDU.

At the same time, I am able to extract this data object from the card whenever I use other APDU tools or APIs, where I have oversight of the GETRESPONSE APDU interactions.

Is it possible that the ResponseAPDU runs into buffer size issues? Is there a known workaround for this? Or am I doing something wrong?

Any help would be greatly appreciated! Here is some code that will demonstrate this behavior:
/*
 * test program
 */
import java.io.*;
import java.util.*;
import javax.smartcardio.*;
import java.lang.String;

public class GetDataTest{
    public void GetDataTest(){}
    public static void main(String[] args){
        try{
            byte[] aid = {(byte)0xA0, 0x00, 0x00, 0x03, 0x08, 0x00, 0x00};
            byte[] biometricDataID1 = {(byte)0x5C, (byte)0x03, (byte)0x5F, (byte)0xC1, (byte)0x08};
            byte[] biometricDataID2 = {(byte)0x5C, (byte)0x03, (byte)0x5F, (byte)0xC1, (byte)0x03};

            //get the first terminal
            TerminalFactory factory = TerminalFactory.getDefault();
            List<CardTerminal> terminals = factory.terminals().list();
            CardTerminal terminal = terminals.get(0);
            //establish a connection with the card
            Card card = terminal.connect("*");
            CardChannel channel = card.getBasicChannel();

            //select the card app
            select(channel, aid);
            //verify pin
            verify(channel);

            /*
             * trouble occurs here
             * error occurs only when extracting a large data object (~12KB) from card.
             * works fine when used on other data objects, e.g. works with biometricDataID2 
             * (data object ~1Kb) and not biometricDataID1 (data object ~12Kb in size)
            */
            //send a "GetData" command
            System.out.println("GETDATA Command");
            ResponseAPDU response = channel.transmit(new CommandAPDU(0x00, 0xCB, 0x3F, 0xFF, biometricDataID1));
            System.out.println(response);

            card.disconnect(false);
            return;
        }catch(Exception e){
            System.out.println(e);
        }finally{
            card.disconnect(false)
        }
    }   
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2009
Added on Apr 16 2009
4 comments
566 views