rename alt chain code

This commit is contained in:
Michele Balistreri 2022-11-10 15:48:05 +01:00
parent 509abc291b
commit 4956fcc1ee
1 changed files with 5 additions and 5 deletions

View File

@ -120,7 +120,7 @@ public class KeycardApplet extends Applet {
private ECPublicKey masterPublic; private ECPublicKey masterPublic;
private ECPrivateKey masterPrivate; private ECPrivateKey masterPrivate;
private byte[] masterChainCode; private byte[] masterChainCode;
private byte[] fakeChainCode; private byte[] altChainCode;
private byte[] chainCode; private byte[] chainCode;
private boolean isExtended; private boolean isExtended;
@ -177,7 +177,7 @@ public class KeycardApplet extends Applet {
masterPublic = (ECPublicKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PUBLIC, SECP256k1.SECP256K1_KEY_SIZE, false); 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); masterPrivate = (ECPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, SECP256k1.SECP256K1_KEY_SIZE, false);
masterChainCode = new byte[CHAIN_CODE_SIZE]; masterChainCode = new byte[CHAIN_CODE_SIZE];
fakeChainCode = new byte[CHAIN_CODE_SIZE]; altChainCode = new byte[CHAIN_CODE_SIZE];
chainCode = masterChainCode; chainCode = masterChainCode;
keyPath = new byte[KEY_PATH_MAX_DEPTH * 4]; keyPath = new byte[KEY_PATH_MAX_DEPTH * 4];
@ -545,7 +545,7 @@ public class KeycardApplet extends Applet {
break; break;
case 2: case 2:
case 3: // if pins are equal fake pin takes precedence case 3: // if pins are equal fake pin takes precedence
chainCode = fakeChainCode; chainCode = altChainCode;
mainPIN.resetAndUnblock(); mainPIN.resetAndUnblock();
pin = altPIN; pin = altPIN;
break; break;
@ -695,7 +695,7 @@ public class KeycardApplet extends Applet {
*/ */
private void generateKeyUIDAndRespond(APDU apdu, byte[] apduBuffer) { private void generateKeyUIDAndRespond(APDU apdu, byte[] apduBuffer) {
if (isExtended) { 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); short pubLen = masterPublic.getW(apduBuffer, (short) 0);
@ -1029,7 +1029,7 @@ public class KeycardApplet extends Applet {
masterPublic.clearKey(); masterPublic.clearKey();
resetCurveParameters(); resetCurveParameters();
Util.arrayFillNonAtomic(masterChainCode, (short) 0, (short) masterChainCode.length, (byte) 0); 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(keyPath, (short) 0, (short) keyPath.length, (byte) 0);
Util.arrayFillNonAtomic(pinlessPath, (short) 0, (short) pinlessPath.length, (byte) 0); Util.arrayFillNonAtomic(pinlessPath, (short) 0, (short) pinlessPath.length, (byte) 0);
} }