JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html
https://ftsafe.en.alibaba.com/index.html
Do ECC cryptography, ECDSA and elliptic Diffie-Hellman on a JavaCard
Do ECC cryptography, ECDSA and elliptic Diffie-Hellman on a JavaCard
I have already bought some java cards and I m going to do ECC cryptography, ECDSA and elliptic Diffie-Hellman on a JavaCard. Could you share any code samples with me? I would be greatly grateful for any reply!
Re: Do ECC cryptography, ECDSA and elliptic Diffie-Hellman on a JavaCard
leogen wrote:I have already bought some java cards and I m going to do ECC cryptography, ECDSA and elliptic Diffie-Hellman on a JavaCard. Could you share any code samples with me? I would be greatly grateful for any reply!
Hi guy!
I have written an applet for testing ECDH. Maybe this will be helpful to you!
Code: Select all
private byte[] SimulatedReceivedKeybuf;
private byte[] tempbuf;
private KeyPair KeyPairH;
private KeyAgreement SharedKey;
private ECPublicKey SimulatedReceivedKey;
protected void initialize(short KeySize)
{
if (SimulatedReceivedKeybuf != null || tempbuf != null)
ISOException.throwIt((short)0x9B01);
//Initialize two keypairs
try{
KeyPairH = new KeyPair(KeyPair.ALG_EC_FP,KeySize);
KeyPairH.genKeyPair();
SimulatedReceivedKey = (ECPublicKey)KeyPairH.getPublic();
KeyPairH = new KeyPair(KeyPair.ALG_EC_FP,KeySize);
KeyPairH.genKeyPair();
}
catch(Exception e){ISOException.throwIt((short)0x9A01);}
//create a useful temporary buffer
tempbuf = JCSystem.makeTransientByteArray((short)256,JCSystem.CLEAR_ON_RESET);
//create the buffer for the shared key computation thanks to the SimulatedReceiveKey (param W)
SimulatedReceivedKeybuf = JCSystem.makeTransientByteArray(((ECPublicKey)KeyPairH.getPublic()).getW(tempbuf, (short) 0),JCSystem.CLEAR_ON_RESET);
SimulatedReceivedKey.getW(SimulatedReceivedKeybuf, (short)0);
//Initialize the Key agreement object
SharedKey = KeyAgreement.getInstance(KeyAgreement.ALG_EC_SVDP_DH, false);
SharedKey.init(KeyPairH.getPrivate());
}
private void GenerateSecretKey()
{
//Compute and set the shared secret key into the temporary buffer
SharedKey.generateSecret(SimulatedReceivedKeybuf, (short)0, (short)SimulatedReceivedKeybuf.length, tempbuf, (short)0);
}
Onward...
Who is online
Users browsing this forum: No registered users and 62 guests