Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Invalid key length

Thread view: 
andrewzzz - 06 Mar 2007 14:30 GMT
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
Daniel Dyer - 06 Mar 2007 14:31 GMT
> 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.

Signature

Daniel Dyer
http://www.uncommons.org

andrewzzz - 06 Mar 2007 15:55 GMT
> > Hi guys...
> > I'm implementing a quite simple cryptographic algorithm , but I keep
[quoted text clipped - 8 lines]
> --
> Daniel Dyerhttp://www.uncommons.org

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....


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.