From ae946ad142efa730e2372b00572e9a473319de12 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Tue, 2 Apr 2013 16:59:32 +0200 Subject: [PATCH] also do resetAndUnblock() when setting new rc or p1 update() only resets the try counter, doesn't reset block state so if the pin is blocked we need to do resetAndUnblock() in the right places. --- src/openpgpcard/OpenPGPApplet.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/openpgpcard/OpenPGPApplet.java b/src/openpgpcard/OpenPGPApplet.java index c039920..d4e9e2e 100644 --- a/src/openpgpcard/OpenPGPApplet.java +++ b/src/openpgpcard/OpenPGPApplet.java @@ -506,12 +506,6 @@ private void resetRetryCounter(APDU apdu, byte mode) { if (!rc.check(buffer, _0, rc_length)) ISOException.throwIt(SW_CONDITIONS_NOT_SATISFIED); - - // Change PW1 - JCSystem.beginTransaction(); - pw1.update(buffer, rc_length, (byte) new_length); - pw1_length = (byte) new_length; - JCSystem.commitTransaction(); } else if (mode == (byte) 0x02) { // Authentication using PW3 if (!pw3.isValidated()) @@ -519,15 +513,16 @@ private void resetRetryCounter(APDU apdu, byte mode) { if (in_received < PW1_MIN_LENGTH || in_received > PW1_MAX_LENGTH) ISOException.throwIt(SW_WRONG_LENGTH); - - // Change PW1 - JCSystem.beginTransaction(); - pw1.update(buffer, _0, (byte) in_received); - pw1_length = (byte) in_received; - JCSystem.commitTransaction(); } else { ISOException.throwIt(SW_WRONG_P1P2); } + + // Change PW1 + JCSystem.beginTransaction(); + pw1.update(buffer, _0, (byte) in_received); + pw1_length = (byte) in_received; + pw1.resetAndUnblock(); + JCSystem.commitTransaction(); } /** @@ -1039,6 +1034,7 @@ private void putData(short tag) { JCSystem.beginTransaction(); rc.update(buffer, _0, (byte) in_received); rc_length = (byte) in_received; + rc.resetAndUnblock(); JCSystem.commitTransaction(); } else { ISOException.throwIt(SW_WRONG_LENGTH);