Skip to content

Commit

Permalink
also do resetAndUnblock() when setting new rc or p1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
klali committed Apr 2, 2013
1 parent 14d5a7a commit ae946ad
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/openpgpcard/OpenPGPApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,28 +506,23 @@ 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())
ISOException.throwIt(SW_CONDITIONS_NOT_SATISFIED);

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();
}

/**
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ae946ad

Please sign in to comment.