Monday, 15 January 2018

How to handle "java.security.InvalidKeyException: Illegal key size"

Many of us are using AES encryption. If we would try to do a 256 bit encryption, we would encounter this exception. This exception is thrown because of a restriction imposed by default JDK. On a default JDK installation, AES is limited to 128 bit key size. In order to perform 256-bit AES encryption, you will need to download and install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. We need to use different version of files for different JDK versions. The below table contains link to the appropriate JCE files for the respective JDK versions. 
JDK 1.6Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6
JDK 1.7Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7 Download
JDK 1.8Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 Download
Please download the archive. The archive would contain 2 jar files, namely local_policy.jar and  US_export_policy.jar. Extract the jar files from the archive and save them into  ${java.home}/jre/lib/security/. This would solve the issue.

Exploring Amazon Web Services (AWS)

  Compute Services Database Services Storage Services Networking Services Analytics Services Security, Identity, and Compliance Services Ama...