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
Implementing Elliptic Curve Cryptography on javacard
-
- Posts: 30
- Joined: Wed Aug 19, 2015 2:55 am
- Points :213
- Contact:
Implementing Elliptic Curve Cryptography on javacard
I would like to implement Elliptic curve cryptography on my java card? Does java card support Elliptic curve cryptography?
If yes, can someone provide me some sample code on how to encrypt and decrypt the data using the same mechanism.
If yes, can someone provide me some sample code on how to encrypt and decrypt the data using the same mechanism.
- horse dream
- Posts: 76
- Joined: Thu May 21, 2015 11:48 pm
- Points :140
- Contact:
Re: Implementing Elliptic Curve Cryptography on javacard
Firstly, you should check whether your card supports EC cryptography.
ECC is rather dedicated to sign/verify operation on java card.
Here is part of sample code which maybe helpful to you.
ECC is rather dedicated to sign/verify operation on java card.
Here is part of sample code which maybe helpful to you.
Code: Select all
byte[] dataToSend = new byte[64];
KeyPair ecKeyPair = new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_128);
ecKeyPair.genKeyPair();
ECPrivateKey ecPrivateKey = (ECPrivateKey) ecKeyPair.getPrivate();
ECPublicKey ecPublicKey = (ECPublicKey) ecKeyPair.getPublic();
Signature sig = Signature.getInstance(Signature.ALG_ECDSA_SHA, false);
sig.init(ecPrivateKey, Signature.MODE_SIGN);
short resLen = sig.sign(new byte[]{0,1,2,3}, (short)0, (short)4, dataToSend, (short)0);
sig.init(ecPublicKey, Signature.MODE_VERIFY);
if (!sig.verify(new byte[]{0,1,2,3}, (short)0, (short)4, dataToSend, (short)0, resLen))
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
Who is online
Users browsing this forum: No registered users and 17 guests