File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Keystore and Encryption Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Keystore and Encryption" Watch "Keystore and Encryption" New topic
Author

Keystore and Encryption

vishwamitra hegde
Greenhorn

Joined: Feb 09, 2012
Posts: 7

Hi,

I have a scenario where I am encrypting and decrypting a string using Cypher by using SecretKey. I am storing SecretKey (AES type) into a keystore (JCEKS type keystore) by using a small java code and retriving that key for encryption and decryption.
But when i try to use key (RSA type) from keystore (JKS type) generated using "keytool" i am getting exception :
java.security.InvalidKeyException: Wrong format: RAW bytes needed
at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)
at com.sun.crypto.provider.AESCipher.engineInit(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)


The command i have used to generate keystore using keytool : keytool -genkey -alias key3 -keyalg RSA -keystore teststore.jks -storepass tspassword

Please explain me, weather it is possible to use the key generated using keytool for encryption and decryption?
If so please explain me.

Thanks!


"Experience is what you get when you didn't get what you wanted" -- Randy Pausch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Keystore and Encryption
 
Similar Threads
Problem in getting decrypted data from MySql Database
KeyStore Algorithm & Cipher Algorithm
Questions about email encryption and signing with S/MIME
Certificate not accepted in JRE 1.4.2
Decryption of file is taking too much time.