Hello
I need help.
I'm using BC provider and I want to encrypt/decrypt data with my password. I will use algoritm "PBEWITHSHA1AND192BITAES-CBC-BC"
I attach mysource code for initialization of Cipher:
byte[] salt = new byte[] { 0x7d, 0x60, 0x43, 0x5f, 0x02, (byte) 0xe9, (byte) 0xe0, (byte) 0xae };
int iterationCount = 19;
byte [] iv = new byte[128];
AlgorithmParameterSpec algSpec = new IvParameterSpec(iv);
PBEKeySpec keySpec = new PBEKeySpec("palo".toCharArray(),salt,iterationCount);
SecretKey key = SecretKeyFactory.getInstance("PBEWITHSHA1AND192BITAES-CBC-BC","BC").generateSecret(keySpec);
Cipher cipher = Cipher.getInstance(key.getAlgorithm(),"BC");
cipher.init(Cipher.ENCRYPT_MODE,key,algSpec);//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//load data
File f = new File("c:\\data");
DataInputStream dis = new DataInputStream(new FileInputStream(f));
byte [] data = new byte[(int)f.length()];
dis.readFully(data);
dis.close();
cipher.update(data);
byte [] encData = cipher.doFinal();
But I got follow exception online with initialization of Cipher:
java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.a(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
at pokus.Untitled1.generuj(Untitled1.java:225)
at pokus.Sprav.main(Sprav.java:25)
I tried it with algorithm PBEWITHSHA1AND128BITAES-CBC-BC and work's fine.
can somebody tell me where is problem ?
Thanks