Lock applet behind the pin

This commit is contained in:
Manuel Thalmann 2023-10-24 18:44:06 +02:00
parent 0b0e3d24ea
commit 80e1d752ad
2 changed files with 18 additions and 1 deletions

View file

@ -1,2 +1,8 @@
SET LENGTH=07
SET AID=01020304050608
SET CONTROLLENGTH=02
SET CONTROLINFO=1122
SET PINLENGTH=04
SET PIN=31323334
@rem -f to force install over old version @rem -f to force install over old version
gp --install %~dp0..\javacard\%PACKAGE%.cap -f gp --install %~dp0..\javacard\%PACKAGE%.cap --params %LENGTH%%AID%%CONTROLLENGTH%%CONTROLINFO%%PINLENGTH%%PIN% -f

View file

@ -42,6 +42,14 @@ public class MyApplet extends Applet {
register(); register();
} }
public boolean select() {
if (pin.getTriesRemaining() == 0) {
return false;
} else {
return super.select();
}
}
/** /**
* Processes an incoming APDU. * Processes an incoming APDU.
* *
@ -90,6 +98,9 @@ public class MyApplet extends Applet {
Util.arrayCopy(buffer, ISO7816.OFFSET_CDATA, storage, (short) 0, length); Util.arrayCopy(buffer, ISO7816.OFFSET_CDATA, storage, (short) 0, length);
} }
break; break;
case 0x20:
length = apdu.setIncomingAndReceive();
pin.check(buffer, (short) ISO7816.OFFSET_CDATA, (byte)length);
default: default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
break; break;