Initialisation d'un Cipher
Bonsoir, j'essai de démarrer avec le cryptage en utilisant l'API flexiprovider mais je suis coincé à l’initialisation du Cipher en utilisant.
Voici le code que j'ai essayé (j'ai copié le code depuis le site officiel):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Security.addProvider(new FlexiCoreProvider());
Security.addProvider(new FlexiECProvider());
KeyPairGenerator kpg = KeyPairGenerator.getInstance("ECIES", "FlexiEC");
CurveParams ecParams = new CurveRegistry.BrainpoolP160r1();
kpg.initialize(ecParams, new SecureRandom());
KeyPair keyPair = kpg.generateKeyPair();
PublicKey pubKey = keyPair.getPublic();
PrivateKey privKey = keyPair.getPrivate();
Cipher cipher = Cipher.getInstance("ECIES", "FlexiEC");
//IESParameterSpec iesParams = new IESParameterSpec("AES128-CBC","HmacSHA1", null, null);
IESParameterSpec iesParams = new IESParameterSpec();
cipher.init(Cipher.ENCRYPT_MODE, pubKey, iesParams) |
L'erreur est dans la dernière ligne, le message d'erreur est :
Exception in thread "main" java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1024)
at javax.crypto.Cipher.init(Cipher.java:1345)
at javax.crypto.Cipher.init(Cipher.java:1282)
at ExampleECIES.main(ExampleECIES.java:42)