Throw an error for incorrect CLAs
This commit is contained in:
parent
22b11b1ee8
commit
995ba68bdf
|
@ -51,40 +51,44 @@ public class MyApplet extends Applet {
|
|||
public void process(APDU apdu) {
|
||||
short length;
|
||||
byte[] buffer = apdu.getBuffer();
|
||||
|
||||
if (buffer[ISO7816.OFFSET_CLA] != 0x80) {
|
||||
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
|
||||
} else {
|
||||
byte instruction = buffer[ISO7816.OFFSET_INS];
|
||||
|
||||
byte instruction = buffer[ISO7816.OFFSET_INS];
|
||||
switch (instruction) {
|
||||
case 0x00:
|
||||
case 0x04:
|
||||
byte[] response;
|
||||
length = apdu.setOutgoing();
|
||||
|
||||
switch (instruction) {
|
||||
case 0x00:
|
||||
case 0x04:
|
||||
byte[] response;
|
||||
length = apdu.setOutgoing();
|
||||
if (instruction == 0x00) {
|
||||
response = AuthorName;
|
||||
} else {
|
||||
response = storage;
|
||||
}
|
||||
|
||||
if (instruction == 0x00) {
|
||||
response = AuthorName;
|
||||
} else {
|
||||
response = storage;
|
||||
}
|
||||
if (length > response.length) {
|
||||
length = (short) response.length;
|
||||
}
|
||||
|
||||
if (length > response.length) {
|
||||
length = (short) response.length;
|
||||
}
|
||||
apdu.setOutgoingLength(length);
|
||||
apdu.sendBytesLong(response, (short) 0, length);
|
||||
break;
|
||||
case 0x02:
|
||||
length = apdu.setIncomingAndReceive();
|
||||
|
||||
apdu.setOutgoingLength(length);
|
||||
apdu.sendBytesLong(response, (short) 0, length);
|
||||
break;
|
||||
case 0x02:
|
||||
length = apdu.setIncomingAndReceive();
|
||||
|
||||
if (length > 20) {
|
||||
// ToDo: Handle too much data.
|
||||
} else {
|
||||
Util.arrayCopy(buffer, ISO7816.OFFSET_CDATA, storage, (short) 0, length);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
|
||||
break;
|
||||
if (length > 20) {
|
||||
// ToDo: Handle too much data.
|
||||
} else {
|
||||
Util.arrayCopy(buffer, ISO7816.OFFSET_CDATA, storage, (short) 0, length);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue