Exception when using Java

Discussion related to AES Crypt, the file encryption software for Windows, Linux, Mac, and Java.
Post Reply
nkhoury
Posts: 3
Joined: Mon Jul 11, 2011 4:48 pm
Contact:

Exception when using Java

Post by nkhoury » Thu Jul 14, 2011 9:01 pm

Hi,
whenever I try to run the AESCrypt.java (I supplied it with default arguments

AESCrypt aes = new AESCrypt(true,"12");
aes.encrypt(2, "c:\\me.rtf", "c:\\me.rtf.aes"); ),

I get the following exception:

[DEBUG] Using password: [49, 0, 50, 0]
[DEBUG] Opened for reading: c:\me.rtf
[DEBUG] Opened for writing: c:\me.rtf.aes
[DEBUG] IV1: [95, -114, 41, 118, 123, 80, -76, 93, 69, 99, -65, -74, 38, -104, -53, 37]
[DEBUG] AES1: [-39, 125, 61, 2, 45, -27, 33, -58, -54, 19, 16, 114, -50, 65, -111, 1, -45, -117, -34, -122, -41, -58, -111, -55, -67, -71, 34, 53, -127, -40, -119, -91]
[DEBUG] IV2: [-127, 86, 110, -11, 90, 72, 121, 96, -3, 64, 127, -13, 37, 64, -108, 34]
[DEBUG] AES2: [-78, -75, 85, 45, -67, 105, 20, 100, -83, 77, 56, 45, 122, 108, 7, 32, 6, -94, -34, -24, -54, 20, -68, 104, -96, -64, 19, -17, -50, -105, 78, 45]
java.security.GeneralSecurityException: Please make sure "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files" (http://java.sun.com/javase/downloads/index.jsp) is installed on your JRE.
at AESCrypt.encrypt(AESCrypt.java:371)
at AESCrypt.encrypt(AESCrypt.java:291)
at AESCrypt.main(AESCrypt.java:526)
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at AESCrypt.encrypt(AESCrypt.java:342)
... 2 more

has anyone tried using this class? did you come across this?
I have already installed the JCE files - no compilation error, it's only occurring when executing it.
Using: jdk1.6.0_26 - jre6

I tried to replace the following line
aesKey1 = new SecretKeySpec(generateAESKey1(ivSpec1.getIV(), password), CRYPT_ALG);
with this line
aesKey1 = new SecretKeySpec("1234567812345678".getBytes(), CRYPT_ALG);

The issue disappeared but then it occurred again when the cipher.init(...) or cipher.doFinal(...) methods are called.

I can't seem to get what's happening, I've spent a couple of hours watching every variable in the code, but obviously I'm missing something.

Any help would be appreciated.

Thanks,
Nid

nkhoury
Posts: 3
Joined: Mon Jul 11, 2011 4:48 pm
Contact:

Re: Exception when using Java

Post by nkhoury » Fri Jul 15, 2011 5:42 pm

Hi again,

just an update on this post as I was able to resolve the issue. Although I had the jar files in my <java-home>\lib\security [Win32] directory, It seems that I had an older version of those libraries.

I had to re-download the files and replace them with the new ones i got from here http://www.oracle.com/technetwork/java/ ... 29243.html. This totally makes sense because most probably the previous versions did not support bigger keys, thus it was giving InvalidKeyException: Illegal key size

Thanks,
Nid

Post Reply