fix usage of uinitialized keys
This commit is contained in:
parent
a0c15da432
commit
cd26da75d3
|
@ -64,6 +64,7 @@ public class SECP256k1 {
|
|||
this.crypto = crypto;
|
||||
this.ecPointMultiplier = KeyAgreement.getInstance(ALG_EC_SVDP_DH_PLAIN_XY, false);
|
||||
this.tmpECPrivateKey = (ECPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, SECP256K1_KEY_SIZE, false);
|
||||
setCurveParameters(tmpECPrivateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,10 +106,7 @@ public class SECP256k1 {
|
|||
*/
|
||||
short derivePublicKey(byte[] privateKey, short privOff, byte[] pubOut, short pubOff) {
|
||||
tmpECPrivateKey.setS(privateKey, privOff, (short)(SECP256K1_KEY_SIZE/8));
|
||||
short res = derivePublicKey(tmpECPrivateKey, pubOut, pubOff);
|
||||
// Unfortunately our current card does not support EC transient keys
|
||||
tmpECPrivateKey.clearKey();
|
||||
return res;
|
||||
return derivePublicKey(tmpECPrivateKey, pubOut, pubOff);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -640,7 +640,7 @@ public class WalletApplet extends Applet {
|
|||
*/
|
||||
private void resetKeyStatus() {
|
||||
parentPrivateKey.clearKey();
|
||||
parentPublicKey.clearKey();
|
||||
secp256k1.setCurveParameters(parentPrivateKey);
|
||||
keyPathLen = 0;
|
||||
}
|
||||
|
||||
|
@ -800,7 +800,7 @@ public class WalletApplet extends Applet {
|
|||
pathLenOff = 0;
|
||||
break;
|
||||
case DERIVE_P1_SOURCE_PARENT:
|
||||
if (!parentPublicKey.isInitialized()) {
|
||||
if (!parentPrivateKey.isInitialized()) {
|
||||
ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue