views:

42

answers:

2

I am using the Bouncy Castle Java cryptographic algorithm implementation. I am getting an IllegalKeySizeException. To overcome this I have even changed my java security jars (local_policy.jar and US_Export_policy.jar), but I am still getting the same problem.

Can anyone suggest a solution for this (I am using centos operating system)?

A: 

Some encryption algorithms expect a fixed key size (or a key that is a multiple of, say, 16 bytes). Pad the key with 0 bytes until it's big enough or truncate it accordingly.

Aaron Digulla
hi Aaron thanks for ur interest!i am using the same code on different machine with centos..there i havnt came across such exception...padding the key with 0 will result change in the code...what i want to know is why is this happening even if i have changed the security .jar's of java on current machine..
Azhar
Maybe a bug was fixed and the key size is now checked. Make sure you use the exact same version of Java and all JARs on all machines.
Aaron Digulla
A: 

For it runs on some machines but not on others, the cause can be a missing 'unlimited strength policy file' - found the hint here. Good luck!

Andreas_D