Return an error if incorrect PIN is entered

This commit is contained in:
Manuel Thalmann 2023-11-03 01:30:04 +01:00
parent 0633e5c767
commit 6070b53cdf

View file

@ -14,6 +14,7 @@ import javacard.framework.*;
*/ */
public class MyApplet extends Applet { public class MyApplet extends Applet {
final static short SW_PIN_VERIFICATION_REQUIRED = 0x6301; final static short SW_PIN_VERIFICATION_REQUIRED = 0x6301;
final static short SW_VERIFICATION_FAILED = 0x6300;
final static byte PIN_TRY_LIMIT =(byte)0x03; final static byte PIN_TRY_LIMIT =(byte)0x03;
final static byte MAX_PIN_SIZE =(byte)0x08; final static byte MAX_PIN_SIZE =(byte)0x08;
private byte[] authorName = new byte[] { 'M', 'a', 'n', 'u', 'e', 'l' }; private byte[] authorName = new byte[] { 'M', 'a', 'n', 'u', 'e', 'l' };
@ -127,7 +128,10 @@ public class MyApplet extends Applet {
break; break;
case 0x20: case 0x20:
length = apdu.setIncomingAndReceive(); length = apdu.setIncomingAndReceive();
pin.check(buffer, (short) ISO7816.OFFSET_CDATA, (byte)length);
if (!pin.check(buffer, (short) ISO7816.OFFSET_CDATA, (byte)length)) {
ISOException.throwIt(SW_VERIFICATION_FAILED);
}
break; break;
default: default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);