• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Load my private key to keystore(problem in loading private key to key store)

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I am trying to load the keystore with the private key and password, but i am facing an exception.
Here the exception is :
java.io.IOException: Wrong version of key store.
at org.bouncycastle.jce.provider.JDKKeyStore.engineLoad(Unknown Source)
at java.security.KeyStore.load(KeyStore.java:1150)
at XML.Decryptor.keystoreTest(Decryptor.java:329)
at XML.Decryptor.main(Decryptor.java:349)

my Code is :

String passPhrase="password";
FileInputStream privKey = null;
privKey = new FileInputStream("C:/TEMP/secring.asc");
KeyStore ks = KeyStore.getInstance("BKS");
ks.load(privKey, passPhrase.toCharArray());

here privKey is the Private key generated using open pgp boouncy castle encryption, and i want to store this in the keystore of BKS.

Cansomeone please help me, I am not able to understand how to proceed, even googling doesnt helped me.
Correct me in the above way of doing if my approach is wrong.

thank you in advance.

Regards,
Harish Ponduri.
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A PGP keyring cannot be used as a KeyStore. It is not compatible with, or related in any way to, a Bouncycastle keystore, nor any of Sun's keystores. You must use the methods of the bouncycastle PGP api to process PGP keys and messages.
 
Harish Ponduri
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg stark

thank you very much for your valuable reply.

So, could you please suggest me or give any idea on my requirement.

My Requirement:

I got a PGP-private key by which i am able to decrypt my encrypted files, and do all the stuff.

so now in my current implementation i am using keystore object to load and by which i am decrypting some data (it is different from my above bouncy castle implementation)

so my requirement is can i even load my PGP Private key in the keystore, so that i will retrieve them on individual alias name and use for their purpose.

can this be implemented, or do we have any other way of loading my PGP private key to KeyStore(NOT to JAVA keystore some other related to bouncy, if it exists).


thank you,


Ponduri.
 
greg stark
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if by keystore you mean the KeyStore class, then no, you cannot use the KeyStore class to access your PGP keys. Java 6 contains no support for PGP. You must use a third party library such as Bouncycastle's. There are two classes, PGPSecretKeyRing and PGPPublicKeyRing that are designed for processing a keyring of a single master key, and other relevant classes as well.
 
Harish Ponduri
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg Stark,

thank you for your reply,

Any idea in using ikeyman utility for storing my private keys.

could you please share your knowledge on ikeyman if any.
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic