Invalid key length

A

andrewzzz

Hi guys...
I'm implementing a quite simple cryptographic algorithm , but I keep
on getting this exception :
java.security.InvalidKeyException: Invalid key length: 444 bytes
at com.sun.crypto.provider.DESCipher.engineGetKeySize(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
Please note that I have JCE working correctly..
Now I'll post and explain my code :

I have a byte[] buffer , which lengh is 304 bytes.
I have a Certificate retrieved from local keystore ,from which I get
corresponding PublicKey.
Then I retrieve Private Key from same keystore (passing a password)
I have to create the digital signature of that buffer (and it works
correctly) :

PrivateKey priv = sp.getPrivate();
Signature sig = Signature.getInstance(priv.getAlgorithm());//create a
Signature instance
sig.initSign(priv);
sig.update(BIGBUFFER, 0, BIGBUFFER.length);
byte[] C_FINAL=sig.sign();//returns the signature result in a byte
array



In the second part of the algorithm I have to encrypt the byte[] array
C_FINAL , using the PUBLIC KEY ..... but while executing the following
code I get the InvalidKeyException

Cipher CPHR = Cipher.getInstance("DES/ECB/PKCS5Padding");
Certicate id=sp.getId();//retrieve certificate from another class
PublicKey PUB_KEY=id.getPublicKey();//retrieve public key from
certificate

CPHR.init(Cipher.ENCRYPT_MODE, PUB_KEY);//this line throws the
exception....

C_FINAL = CPHR.doFinal(C_FINAL);



Please,anybody knows how to solve this problem..?
Thanks a lot guys...
bye
 
D

Daniel Dyer

Hi guys...
I'm implementing a quite simple cryptographic algorithm , but I keep
on getting this exception :
java.security.InvalidKeyException: Invalid key length: 444 bytes

By default, key lengths are limited. You will need to download and
install the unlimited strength cryptography policies from Sun's website.

Dan.
 
A

andrewzzz

By default, key lengths are limited. You will need to download and
install the unlimited strength cryptography policies from Sun's website.

Dan.

I've already downloaded the zip file..and uncompressed it in the
security folder of jre...as explained....I don't really know why it
doen't work....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top