Skip to content

Commit

Permalink
patch to fix issue #47 with OwnerPIN.update on J3R180
Browse files Browse the repository at this point in the history
  • Loading branch information
af-anssi committed Apr 12, 2023
1 parent 730a650 commit 7bd6a53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fr/anssi/smartpgp/Persistent.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ public final class Persistent {
protected final byte[] key_derivation_function;
protected short key_derivation_function_length;

protected final OwnerPIN user_pin; /* PW1 */
protected OwnerPIN user_pin; /* PW1 */
protected byte user_pin_length;
protected boolean user_pin_force_verify_signature;

protected final OwnerPIN user_puk; /* resetting code */
protected OwnerPIN user_puk; /* resetting code */
protected byte user_puk_length;

protected final OwnerPIN admin_pin; /* PW3 */
protected OwnerPIN admin_pin; /* PW3 */
protected byte admin_pin_length;


Expand Down Expand Up @@ -235,6 +235,7 @@ protected void reset(final boolean isRegistering) {

Common.beginTransaction(isRegistering);
user_pin_length = (byte)Constants.USER_PIN_DEFAULT.length;
user_pin = new OwnerPIN(Constants.USER_PIN_RETRY_COUNT, Constants.USER_PIN_MAX_SIZE);
user_pin.update(Constants.USER_PIN_DEFAULT, (short)0, user_pin_length);
user_pin.resetAndUnblock();
Common.commitTransaction(isRegistering);
Expand All @@ -252,6 +253,7 @@ protected void reset(final boolean isRegistering) {

Common.beginTransaction(isRegistering);
admin_pin_length = (byte)Constants.ADMIN_PIN_DEFAULT.length;
admin_pin = new OwnerPIN(Constants.ADMIN_PIN_RETRY_COUNT, Constants.ADMIN_PIN_MAX_SIZE);
admin_pin.update(Constants.ADMIN_PIN_DEFAULT, (short)0, admin_pin_length);
admin_pin.resetAndUnblock();
Common.commitTransaction(isRegistering);
Expand Down
5 changes: 5 additions & 0 deletions src/fr/anssi/smartpgp/SmartPGPApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ private final void processChangeReferenceData(final short lc,
}
JCSystem.beginTransaction();
data.user_pin_length = minlen;
data.user_pin = new OwnerPIN(Constants.USER_PIN_RETRY_COUNT, Constants.USER_PIN_MAX_SIZE);
data.user_pin.update(transients.buffer, off, data.user_pin_length);
JCSystem.commitTransaction();
data.user_pin.resetAndUnblock();
Expand Down Expand Up @@ -703,6 +704,7 @@ private final void processChangeReferenceData(final short lc,
}
JCSystem.beginTransaction();
data.admin_pin_length = minlen;
data.admin_pin = new OwnerPIN(Constants.ADMIN_PIN_RETRY_COUNT, Constants.ADMIN_PIN_MAX_SIZE);
data.admin_pin.update(transients.buffer, off, data.admin_pin_length);
JCSystem.commitTransaction();
data.admin_pin.resetAndUnblock();
Expand Down Expand Up @@ -762,6 +764,7 @@ private final void processResetRetryCounter(final short lc,
}
JCSystem.beginTransaction();
data.user_pin_length = minlen;
data.user_pin = new OwnerPIN(Constants.USER_PIN_RETRY_COUNT, Constants.USER_PIN_MAX_SIZE);
data.user_pin.update(transients.buffer, off, data.user_pin_length);
JCSystem.commitTransaction();
data.user_pin.resetAndUnblock();
Expand All @@ -778,6 +781,7 @@ private final void processResetRetryCounter(final short lc,
transients.setUserPinMode82(false);
JCSystem.beginTransaction();
data.user_pin_length = (byte)lc;
data.user_pin = new OwnerPIN(Constants.USER_PIN_RETRY_COUNT, Constants.USER_PIN_MAX_SIZE);
data.user_pin.update(transients.buffer, (short)0, data.user_pin_length);
JCSystem.commitTransaction();
data.user_pin.resetAndUnblock();
Expand Down Expand Up @@ -1151,6 +1155,7 @@ private final void processPutData(final short lc,
}
JCSystem.beginTransaction();
data.user_puk_length = (byte)lc;
data.user_puk = new OwnerPIN(Constants.USER_PUK_RETRY_COUNT, Constants.USER_PUK_MAX_SIZE);
data.user_puk.update(buf, (short)0, data.user_puk_length);
JCSystem.commitTransaction();
data.user_puk.resetAndUnblock();
Expand Down

0 comments on commit 7bd6a53

Please sign in to comment.