Hi all,
has anyone had any luck with APDU response chaining on a JC 2.2.1 card that only supports protocol T=0? It is deffined in ISO7816-4 and the standard only states that the SW 6884 should be returned if the card does not support chaining (I assume that is if the applet does not support chaining).
In the standard it says to return a status word of 0x61xx to indicate there is more data to be sent back to the client. When I send back this status word from a card it seems to hang and the PCSC connection drops out. When I send it to the JCOP simulator, it seems to work fine. It also works fine when the protocol is T=1.
I am using smardcardio to communicate to the card and in the code for ChannelImpl (OpenJDK 6) it is handled transparently by the channel.
boolean getresponse = (t0 && t0GetResponse) || (t1 && t1GetResponse);
int k = 0;
byte[] result = B0;
while (true) {
if (++k >= 32) {
throw new CardException("Could not obtain response");
}
byte[] response = SCardTransmit(card.cardId, card.protocol, command, 0, n);
int rn = response.length;
if (getresponse && (rn >= 2)) {
// see ISO 7816/2005, 5.1.3
if ((rn == 2) && (response[0] == 0x6c)) {
// Resend command using SW2 as short Le field
command[n - 1] = response[1];
continue;
}
if (response[rn - 2] == 0x61) {
// Issue a GET RESPONSE command with the same CLA
// using SW2 as short Le field
if (rn > 2) {
result = concat(result, response, rn - 2);
}
command[1] = (byte)0xC0;
command[2] = 0;
command[3] = 0;
command[4] = response[rn - 1];
n = 5;
continue;
}
}
result = concat(result, response, rn);
break;
}
Is there something I am missing? Is 7816 chaining unsupported on a card that only supports protocol T=1?
Cheers,
Shane