Skip to content

Commit

Permalink
rename alt chain code
Browse files Browse the repository at this point in the history
  • Loading branch information
bitgamma committed Nov 10, 2022
1 parent 509abc2 commit 4956fcc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/im/status/keycard/KeycardApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public class KeycardApplet extends Applet {
private ECPublicKey masterPublic;
private ECPrivateKey masterPrivate;
private byte[] masterChainCode;
private byte[] fakeChainCode;
private byte[] altChainCode;
private byte[] chainCode;
private boolean isExtended;

Expand Down Expand Up @@ -177,7 +177,7 @@ public KeycardApplet(byte[] bArray, short bOffset, byte bLength) {
masterPublic = (ECPublicKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PUBLIC, SECP256k1.SECP256K1_KEY_SIZE, false);
masterPrivate = (ECPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, SECP256k1.SECP256K1_KEY_SIZE, false);
masterChainCode = new byte[CHAIN_CODE_SIZE];
fakeChainCode = new byte[CHAIN_CODE_SIZE];
altChainCode = new byte[CHAIN_CODE_SIZE];
chainCode = masterChainCode;

keyPath = new byte[KEY_PATH_MAX_DEPTH * 4];
Expand Down Expand Up @@ -545,7 +545,7 @@ private void verifyPIN(APDU apdu) {
break;
case 2:
case 3: // if pins are equal fake pin takes precedence
chainCode = fakeChainCode;
chainCode = altChainCode;
mainPIN.resetAndUnblock();
pin = altPIN;
break;
Expand Down Expand Up @@ -695,7 +695,7 @@ private void loadKey(APDU apdu) {
*/
private void generateKeyUIDAndRespond(APDU apdu, byte[] apduBuffer) {
if (isExtended) {
crypto.sha256.doFinal(masterChainCode, (short) 0, CHAIN_CODE_SIZE, fakeChainCode, (short) 0);
crypto.sha256.doFinal(masterChainCode, (short) 0, CHAIN_CODE_SIZE, altChainCode, (short) 0);
}

short pubLen = masterPublic.getW(apduBuffer, (short) 0);
Expand Down Expand Up @@ -1029,7 +1029,7 @@ private void removeKey(APDU apdu) {
masterPublic.clearKey();
resetCurveParameters();
Util.arrayFillNonAtomic(masterChainCode, (short) 0, (short) masterChainCode.length, (byte) 0);
Util.arrayFillNonAtomic(fakeChainCode, (short) 0, (short) fakeChainCode.length, (byte) 0);
Util.arrayFillNonAtomic(altChainCode, (short) 0, (short) altChainCode.length, (byte) 0);
Util.arrayFillNonAtomic(keyPath, (short) 0, (short) keyPath.length, (byte) 0);
Util.arrayFillNonAtomic(pinlessPath, (short) 0, (short) pinlessPath.length, (byte) 0);
}
Expand Down

0 comments on commit 4956fcc

Please sign in to comment.