Installed JCE Unlimited Strength, but AES 256 is not supported

I installed JCE Unlimited power for JAVA_HOME \ lib \ security
However, I still get 128 for Cipher.getMaxAllowedKeyLength("AES") .

I am wondering if I installed JCE in the wrong place.
I have Java installed in 2 places.

  • C: \ Program Files \ Java \ jre7
  • C: \ Development \ Java \ jdk1.6.0_21

Can someone tell me where is the place to install JCE Unlimited? Your help is greatly appreciated.

my code is:

  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); } 
0
source share
1 answer

You need to install the files depending on which JVM will run your code. To be safe, I would recommend installing it in both.

I notice that you have two different versions: Java 7 for the JRE and Java 6 for the SDK. Keep in mind that Java 6 and 7 have different unlimited force policy files, so you need to download both sets.

  • For the JRE, install in C:\Program Files\Java\jre7\lib\security .
  • For the JDK, install in C:\Development\Java\jdk1.6.0_21\jre\lib\security .
+3
source

Source: https://habr.com/ru/post/1014879/


All Articles