Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bouncy Castle : Public Key Retrieval based on the finger print provided

 
Rakesh Megharaj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to retrieve the public key based on the fingerprint from the collection file (i.e. the .gpg file) using the Bouncy Castle Api (bcprov-jdk15on-147.jar). As i want to move my application using GNUPG tool to Bouncy castle, where the collection and the finger print is provided for the encryption of a file.As encryption in the BC can be achieved through public key.It would be of great help if you could provide some example.

Is .gpg in GNUPG equivalent for both .pkr and .skr files?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just load the file into a PGPPublicKeyRingCollection and then iterate though each contained keyring until you find the key with the matching fingerprint! One of the BC PGP examples has 90% of the code you require for doing this!

As far as "Is .gpg in GNUPG equivalent for both .pkr and .skr files" is concerned then I'm not sure what you mean by 'equivalent' . As far as I remember the pubring.gpg file has the same format as a '.pkr' file and the secring.gpg file has the same format as a '.skr' file but you can't use the same Java BC code to load both. If you look at the BC examples and Javadoc you will be able to extrapolate from loading the public key file to loading the private key file.

Since this project sounds like it has a large number of PGP key I'm surprise you are not using a database to hold the public keys. I use a MySQL database for public keys with an index on the email address, the fingerprint and the customer name.
 
Rakesh Megharaj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply.
I will try this one.
We are using the Database to store the PGPKeys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic