Hi,
I am trying to use ECIES mechanism for cryptography and when I am running the below code I am geting error Illegal key size or default parameters
Security.addProvider(new BouncyCastleProvider());
// NOTE just "EC" also seems to work here
KeyPairGenerator kpg = KeyPairGenerator.getInstance("ECIES");
kpg.initialize(new ECGenParameterSpec("secp256r1"));
// Key pair to store public and private key
KeyPair keyPair = kpg.generateKeyPair();
Cipher iesCipher = Cipher.getInstance("ECIES");
iesCipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic());
The last line is giving the error. Please find below the error
Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026)
at javax.crypto.Cipher.implInit(Cipher.java:801)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1249)
at javax.crypto.Cipher.init(Cipher.java:1186)
at ECIESExample.main(ECIESExample.java:28)
Hi, I am trying to use ECIES mechanism for cryptography and when I am running the below code I am geting error Illegal key size or default parameters
The last line is giving the error. Please find below the error Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026) at javax.crypto.Cipher.implInit(Cipher.java:801) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1249) at javax.crypto.Cipher.init(Cipher.java:1186) at ECIESExample.main(ECIESExample.java:28)
Please suggest what I am doing wrong..