My function looks like:
Code: Select all
private final static byte[] gpo = new byte[]
{
(byte)0x80, 0x0A, 0x1C, 0x00, 0x08, 0x01, 0x01, 0x00, 0x18, 0x01, 0x02, 0x00
};
public void process(APDU apdu)
{
byte[] apduBuffer = apdu.getBuffer();
byte cla = apduBuffer[ISO7816.OFFSET_CLA];
byte ins = apduBuffer[ISO7816.OFFSET_INS];
if (selectingApplet())
{
apdu.setOutgoing();
apdu.setOutgoingLength((short)fci.length);
apdu.sendBytesLong(fci, (short)0, (short)fci.length);
return;
}
switch(cla)
{
case (byte)0x00:
{
switch(ins)
{
case (byte)0xB2:
{
byte[] buf = apdu.getBuffer();
Util.arrayCopyNonAtomic(gpo,(byte)0,buf,ISO7816.OFFSET_CDATA,(short)gpo.length);
apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA,(short)gpo.length);
}
break;
default: ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); break;
}
}
break;
case (byte)0x80:
{
switch(ins)
{
case (byte)0xA8:
{
byte[] buffer = apdu.getBuffer();
short le = apdu.setOutgoing();
apdu.setOutgoingLength((byte)10);
apdu.sendBytesLong(GPO_COMMAND, (short)0, (short)10);
}
break;
case (byte)0xCA: getData(apdu, apduBuffer); break;
default: ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); break;
}
}
break;
default: ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED); break;
}
}
I have some questions regarding this code
1: When i send: 80 A8 00 00 02 83 00, I receive 6C 0A. When i send again: 80 A8 00 00 0A i get the gpo, however if i send 00 A8 00 0A 83 00 or do this automatically from my c++ program or with program like CardPeek, this function goes in an endless loop.
How can i programmatically ignore the Data In field and just process apdu with success response regardless of Data Field ?
2: In some applets when i select application i receive 61 xx status and then retrieve the bytes with C0. How can i implement this on selectingApplet() ? Currently my function just return the full bytes.
Thanks in advance!