In the case where you have the standard two key ring the easiest way to
pick up the key is to use the isEncryptionKey method.
example class in the signed jar file. You would be better to simply copy
it and modify it your own ends.
Post by Chakraborty, Debanjan [WHQEO]Hi Brian,
I am facing some similar problems, and I was looking forward to
some inputs, and then I saw your mail in the group, and it helped a
lot. Thanks a lot for that.
I have a few more questions, and I would be grateful if any of
you can give some inputs on that too.
We have a scenario where we need to encrypt a CSV file and FTP it out
to some 3rd party service provider. Now, in order to encrypt, we have
been provided the public key by the 3rd party service provider (to
whom we are sending out the file). The public key seems to have 2
keys (I observed this, both by using the PGP Desktop as well as by
iterating through the key using the KeyBasedLargeFileProcessor.java),
the pubic key and a sub-key (for signature verification purposes). We
would like to do the encryption using the PGP APIs of BouncyCastle
1.29.
a) What would be the best way to identify the public key from
within the class? Should we go ahead and use the ID of the key in
order to identify the public key that we need? If no, then what is the
recommended attribute to use for picking out the public key from the
public key collection?
b) While encrypting the file, we would like to create the
encrypted file with .PGP extension. As of now, using the sample, we
are being able to create a file with the .ASC extension. However, when
we try to override the extension (by modifying the sample), it gives
us an exception (java.lang.SecurityException: SHA1 digest error for
org/bouncycastle/openpgp/ examples/KeyBasedLargeFileProcessor.class).
Any idea as to what would be the best way to go about doing this?
Regards,
Debanjan
-----Original Message-----
Sent: Thursday, September 15, 2005 3:35 PM
Subject: RE: [dev-crypto] PGPOnePassSignatureList
I would guess that your key file has only the “public key pair”, which
is slightly different. When you use most software to export a key, you
actually export a pair of keys: one for encryption, and one for
signature verification.
It’s very common for the master key in a public key pair to be a
signature verification key. Your PGPPublicKeyRing object probably
contains at least two keys. Use the getPublicKeys() method rather than
getPublicKey() – or better yet, access the encryption key using the
getPublicKey( long ) method.
If you’re parsing a typical GPG pubring.gpg file, your simple reading
Use a PGPObjectFactory to access the file, and loop over the objects in it.
For each PGPPublicKeyRing object, loop over each of the keys
For each PGPPublicKey, do whatever is
necessary.
-Brian
______________________________________________________________________
Sent: Thursday, September 15, 2005 10:09 AM
Subject: Re: [dev-crypto] PGPOnePassSignatureList
Has anyone dealt with the problem of encryption with PGP or GPG keys
and when you use BouncyCastle to read in the key to create the
PGPPublicKey. What is happening to me is when I call the method on
the PGPPublicKey isEncryptionKey, false is returned. But when I call
isMasterKey, that is true. In my key file, I only have the public
key. Anyone have any ideas. I'm using BC 1.28 with java 1.4.2_03
John