mirror of
https://github.com/status-im/status-keycard.git
synced 2025-01-12 14:54:54 +00:00
make JCOP4 happy
This commit is contained in:
parent
ab4afcb4cd
commit
a1c2bc119d
@ -19,6 +19,7 @@ public class CashApplet extends Applet {
|
||||
private SECP256k1 secp256k1;
|
||||
|
||||
private Signature signature;
|
||||
private boolean schnorrInitialized;
|
||||
|
||||
/**
|
||||
* Invoked during applet installation. Creates an instance of this class. The installation parameters are passed in
|
||||
@ -55,6 +56,7 @@ public class CashApplet extends Applet {
|
||||
|
||||
signature = Signature.getInstance(Signature.ALG_ECDSA_SHA_256, false);
|
||||
signature.init(privateKey, Signature.MODE_SIGN);
|
||||
schnorrInitialized = false;
|
||||
|
||||
short c9Off = (short)(bOffset + bArray[bOffset] + 1); // Skip AID
|
||||
c9Off += (short)(bArray[c9Off] + 1); // Skip Privileges and parameter length
|
||||
@ -95,6 +97,11 @@ public class CashApplet extends Applet {
|
||||
}
|
||||
|
||||
private void selectApplet(APDU apdu) {
|
||||
if (!schnorrInitialized) {
|
||||
secp256k1.initSchnorr();
|
||||
schnorrInitialized = true;
|
||||
}
|
||||
|
||||
byte[] apduBuffer = apdu.getBuffer();
|
||||
|
||||
short off = 0;
|
||||
|
@ -343,6 +343,8 @@ public class KeycardApplet extends Applet {
|
||||
puk.update(apduBuffer, (short)(ISO7816.OFFSET_CDATA + PIN_LENGTH), PUK_LENGTH);
|
||||
|
||||
JCSystem.commitTransaction();
|
||||
|
||||
secp256k1.initSchnorr();
|
||||
} else {
|
||||
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
|
||||
}
|
||||
|
@ -93,11 +93,13 @@ public class SECP256k1 {
|
||||
SECP256k1(Crypto crypto) {
|
||||
this.crypto = crypto;
|
||||
|
||||
this.tmp = JCSystem.makeTransientByteArray(TMP_LEN, JCSystem.CLEAR_ON_RESET);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void initSchnorr() {
|
||||
this.tmp = JCSystem.makeTransientByteArray(TMP_LEN, JCSystem.CLEAR_ON_RESET);
|
||||
|
||||
multPair = new KeyPair(KeyPair.ALG_RSA_CRT, SCHNORR_MULT_KEY_SIZE);
|
||||
multPair.genKeyPair();
|
||||
|
Loading…
x
Reference in New Issue
Block a user