Created
March 15, 2013 06:23
-
-
Save jehrhardt/5167854 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment