SELECT command
Posted: Thu Jun 15, 2017 2:10 am
Can we override a select AID command and cause it to pass some data as response data? Thanks for any help.
JavaCardOS - JavaCardForum
http://www.javacardos.com/javacardforum/
http://www.javacardos.com/javacardforum/viewtopic.php?f=15&t=1219
Code: Select all
// "some data "
private static final byte[] somedata= new byte[] {
(byte)0x47, (byte)0x72, (byte)0x65, (byte)0x65,
(byte)0x74, (byte)0x69, (byte)0x6E, (byte)0x67,
(byte)0x73, (byte)0x20
};
public void process(APDU apdu) {
// Good practice: Return 9000 on SELECT
if (selectingApplet()) {
response=somedata;
responseApdu=JCSystem.makeTransientByteArray(
(short)(response.length),
JCSystem.CLEAR_ON_DESELECT);
apdu.setOutgoing();
apdu.setOutgoingLength((short)response.length);
apdu.sendBytesLong(responseApdu, (short)0, (short)responseApdu.length);
}
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS]) {
case (byte) 0x00:
break;
default:
// good practice: If you don't know the INStruction, say so:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}