public
Created

Detect the allowed size of AES keys on the JVM. If the size is <= 256, it is limited. To fix it JCE unlimted stregth files are needed.

  • Download Gist
KeyLengthDetector.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import javax.crypto.Cipher;
import java.security.NoSuchAlgorithmException;
 
public class KeyLengthDetector {
public static void main(String[] args) {
int allowedKeyLength = 0;
 
try {
allowedKeyLength = Cipher.getMaxAllowedKeyLength("AES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
 
System.out.println("The allowed key length for AES is: " + allowedKeyLength);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.