Unable to change historical bytes JCOP4 P71 J3R200 with default privilege
Posted: Sun Jul 03, 2022 5:40 am
I've created a simple app which should be able to modify historical bytes.
Compiled it with java_card_kit-305u3 and GlobalPlatform 2.1.1
Successfully installed it using GlobalPlafromPro using the command (after deleting the applet that came with the card and was set to default),
and verified with that indeed my applet is installed and has the CardReset privilege.
When I send an apdu to the card, it should just take the data of that apdu and set it as the historical bytes, I'm also checking the return value and throw if it is False (meaning that the function had failed setting the bytes).
It calls the function, and returns fine - but the historical bytes are unchanged.
I've also tried physically removing the card and reconnecting, but it didn't change anything.
Here's my code:
Any ideas?
Compiled it with java_card_kit-305u3 and GlobalPlatform 2.1.1
Successfully installed it using GlobalPlafromPro using the command
Code: Select all
/gp --install miniAppletPkg.cap -default
and verified with
Code: Select all
gp --list
When I send an apdu to the card, it should just take the data of that apdu and set it as the historical bytes, I'm also checking the return value and throw if it is False (meaning that the function had failed setting the bytes).
It calls the function, and returns fine - but the historical bytes are unchanged.
I've also tried physically removing the card and reconnecting, but it didn't change anything.
Here's my code:
Code: Select all
import javacard.framework.*;
import org.globalplatform.*;
public final class miniApplet extends Applet
{
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new miniApplet();
}
public miniApplet() {
register();
}
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
if (buf[ISO7816.OFFSET_CLA] != 0xA0)
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
if (buf[ISO7816.OFFSET_INS] != 0x01)
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
if (!GPSystem.setATRHistBytes(buf, ISO7816.OFFSET_CDATA, buf[ISO7816.OFFSET_LC]))
ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
}
}