I have installed JCE Unlimited strength to JAVA_HOME\lib\security
However, I'm still getting 128 for Cipher.getMaxAllowedKeyLength("AES")
.
I'm wondering if I have installed the JCE at the wrong place.
I have Java installed in 2 places.
- C:\Program Files\Java\jre7
- C:\Development\Java\jdk1.6.0_21
Can anyone tell me where is the correct place to install JCE Unlimited strength? Your help is much appreciated.
my code:
KeyGenerator generator = KeyGenerator.getInstance("AES");
generator.init(256); SecretKey secretKey = generator.generateKey();
byte[] raw= secretKey.getEncoded();
SecretKeySpec sskey= new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
if (mode == Cipher.ENCRYPT_MODE) {
Cipher.getMaxAllowedKeyLength("AES"));
cipher.init(Cipher.ENCRYPT_MODE, sskey);
CipherInputStream cis = new CipherInputStream(is, cipher);
doCopy(cis, os);
} else if (mode == Cipher.DECRYPT_MODE) {
cipher.init(Cipher.DECRYPT_MODE, sskey);
CipherOutputStream cos = new CipherOutputStream(os, cipher);
doCopy(is, cos);
}