GET REPONSE command with JCOP card
Posted: Thu Dec 17, 2015 3:29 am
I also installed my applet into JCOP card and tested GET REPONSE COMMAND. But it returned as follows:
Why did JCOP card return these?
Here is applet-code:
Send: 00 00 00 00 00
Recv: 6C 02
Time used: 0.000 ms
Send: 00 00 00 00 02
Recv: 03 01 90 00
Time used: 10.000 ms
Why did JCOP card return these?
Here is applet-code:
Code: Select all
package GR_TEST;
import javacard.framework.*;
import javacardx.apdu.ExtendedLength;
public class GR_TEST extends Applet implements ExtendedLength
{
byte[] a = null;
public GR_TEST() {
a = new byte[(short)1000];
for (short i = 0; i < 1000; ++i) {
a[i] = (byte)((short)i & 0xFF);
}
}
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new GR_TEST().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
short reason = 0;
try {
apdu.setOutgoing();
} catch (APDUException e) {
reason = 0x0100;
reason |= e.getReason();
}
try {
apdu.setOutgoingLength((short)1000);
} catch (APDUException e) {
reason = 0x0200;
reason |= e.getReason();
}
try {
apdu.sendBytesLong(a, (short)0, (short)1000);
} catch (APDUException e) {
reason = 0x0300;
reason |= e.getReason();
}
if (reason != 0) {
apdu.setOutgoingLength((short) 2);
Util.setShort(buf, (short) 0, reason);
apdu.sendBytes((short) 0, (short) 2);
}
break;
default:
ISOException.throwIt((short)0x8080);
}
}
}