Get CryptoException.ILLEGAL_VALUE when generating ECC key pair
Moderator: horse dream
Get CryptoException.ILLEGAL_VALUE when generating ECC key pair
Hi everyone!
Today I used JCOP card to generate ECC key pair. I can create ECPrivateKey, ECPublicKey, KeyPair w/o any problems, but it throws exception CryptoException.ILLEGAL_VALUE when genKeyPair(). What's wrong with my card or my operation? I have no idea. Could you please tell me where I made the mistake? Much appreciated!
BTW, I found that JCAlgTest has encountered the same problem, pls check the test report here.
Today I used JCOP card to generate ECC key pair. I can create ECPrivateKey, ECPublicKey, KeyPair w/o any problems, but it throws exception CryptoException.ILLEGAL_VALUE when genKeyPair(). What's wrong with my card or my operation? I have no idea. Could you please tell me where I made the mistake? Much appreciated!
BTW, I found that JCAlgTest has encountered the same problem, pls check the test report here.
- horse dream
- Posts: 76
- Joined: Thu May 21, 2015 11:48 pm
- Points :138
- Contact:
Re: Get CryptoException.ILLEGAL_VALUE when generating ECC key pair
For JCOP card, you should set ECC domain parameters for both the public key and private key before genKeyPair().
FYI:
Check the code below to set the parameters.
FYI:
Check the code below to set the parameters.
Code: Select all
pubKey.setFieldFP(p, (short) 0, (short) p.length);
pubKey.setA(a, (short) 0, (short) a.length);
pubKey.setB(b, (short) 0, (short) b.length);
pubKey.setG(g, (short) 0, (short) g.length);
pubKey.setR(n, (short) 0, (short) n.length);
pubKey.setK((short) 1);
priKey.setFieldFP(p, (short) 0, (short) p.length);
priKey.setA(a, (short) 0, (short) a.length);
priKey.setB(b, (short) 0, (short) b.length);
priKey.setG(g, (short) 0, (short) g.length);
priKey.setR(n, (short) 0, (short) n.length);
priKey.setK((short) 1);
Re: Get CryptoException.ILLEGAL_VALUE when generating ECC key pair
horse dream wrote:For JCOP card, you should set ECC domain parameters for both the public key and private key before genKeyPair().
FYI:
Check the code below to set the parameters.Code: Select all
pubKey.setFieldFP(p, (short) 0, (short) p.length);
pubKey.setA(a, (short) 0, (short) a.length);
pubKey.setB(b, (short) 0, (short) b.length);
pubKey.setG(g, (short) 0, (short) g.length);
pubKey.setR(n, (short) 0, (short) n.length);
pubKey.setK((short) 1);
priKey.setFieldFP(p, (short) 0, (short) p.length);
priKey.setA(a, (short) 0, (short) a.length);
priKey.setB(b, (short) 0, (short) b.length);
priKey.setG(g, (short) 0, (short) g.length);
priKey.setR(n, (short) 0, (short) n.length);
priKey.setK((short) 1);
@horse dream, thanks for your detailed reply! I have solved my problem according to your answer!
Who is online
Users browsing this forum: No registered users and 52 guests