Improve PUK (aka Reset Code) handling

This commit is contained in:
Arnaud Fontaine 2018-05-23 17:09:50 +02:00
parent 981899718f
commit 5022bca0b5
2 changed files with 9 additions and 6 deletions

View File

@ -241,7 +241,14 @@ public final class Persistent {
user_pin.resetAndUnblock();
Common.commitTransaction(isRegistering);
user_puk_length = 0;
Common.beginTransaction(isRegistering);
user_puk_length = (short)0;
/* Ensures any previously defined PUK code is blocked at factory reset */
byte[] emptyPin = new byte[0];
while(user_puk.getTriesRemaining() > 0) {
user_puk.check(emptyPin, (short)0, (byte)0);
}
Common.commitTransaction(isRegistering);
Common.beginTransaction(isRegistering);
admin_pin_length = (byte)Constants.ADMIN_PIN_DEFAULT.length;

View File

@ -154,11 +154,7 @@ public final class SmartPGPApplet extends Applet {
buf[off++] = Constants.ADMIN_PIN_MAX_SIZE;
buf[off++] = data.user_pin.getTriesRemaining();
if(data.user_puk_length > 0) {
buf[off++] = data.user_puk.getTriesRemaining();
} else {
buf[off++] = (byte)0x00;
}
buf[off++] = data.user_puk.getTriesRemaining();
buf[off++] = data.admin_pin.getTriesRemaining();
return off;