From 6febd85ddc696f3367098cd4927ecca20febf95b Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 3 Nov 2023 02:01:21 +0100 Subject: [PATCH] Handle `SELECT` verification properly --- hwb1/src/hwb1/MyApplet.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/hwb1/src/hwb1/MyApplet.java b/hwb1/src/hwb1/MyApplet.java index 30e1e08..366c9e9 100644 --- a/hwb1/src/hwb1/MyApplet.java +++ b/hwb1/src/hwb1/MyApplet.java @@ -53,15 +53,6 @@ public class MyApplet extends Applet { register(); } - public boolean select() { - if (pin.getTriesRemaining() == 0) { - ISOException.throwIt(SW_VERIFICATION_FAILED); - return false; - } else { - return super.select(); - } - } - public void deselect() { super.deselect(); pin.reset(); @@ -78,7 +69,11 @@ public class MyApplet extends Applet { byte[] buffer = apdu.getBuffer(); if (selectingApplet()) { - ISOException.throwIt(ISO7816.SW_NO_ERROR); + if (pin.getTriesRemaining() == 0) { + ISOException.throwIt(SW_VERIFICATION_FAILED); + } else { + ISOException.throwIt(ISO7816.SW_NO_ERROR); + } } else { if (buffer[ISO7816.OFFSET_CLA] != (byte)0x80) { ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);