-
-
Save nogweii/6786915 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
javac Test.java | |
java Test |
import javax.crypto.Cipher; | |
class Test { | |
public static void main(String[] args) { | |
try { | |
System.out.println("Hello World!"); | |
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); | |
System.out.println(maxKeyLen); | |
} catch (Exception e){ | |
System.out.println("Sad world :("); | |
} | |
} | |
} |
From my understanding 2147483647 (Integer.MAX_VALUE
) is not a "bullshit policy" but rather the result you get if you're using OpenJDK which has no limits. See: https://www.eyrie.org/~eagle/notes/debian/jce-policy.html
Very useful. Thanks for posting.
As a one-liner: $JAVA_HOME/bin/jrunscript -e 'print (javax.crypto.Cipher.getMaxAllowedKeyLength("RC5") >= 256);'
one-liner - perfect, needed in bash script!
thanks for the info. Here mod one liner for WAS (IBM) on Win
C:\IBM\WebSphere\AppServer\java\8.0\bin\jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('AES'))"
C:\IBM\WebSphere\AppServer\java_1.7.1_64\bin\jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('AES'))"
If you want true/false
jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('AES') >= 256)"
jrunscript -e "print (javax.crypto.Cipher.getMaxAllowedKeyLength('RC5') >= 256)"
Excellent work!
Thanks for this and the one liners!
JCE is enabled by default since java 8u161
Thanks dude.
unzip -c ${JAVA_HOME}/jre/lib/security/local_policy.jar default_local.policy | grep -q javax.crypto.CryptoAllPermission && echo "unlimited JCE" || echo "vanilla JCE"
Great help, thanks for the post.
Thanks dude. 👍