OpenPGP Tools Package

NOTE:These tools are definitely in beta stage, they work for very specific instances and may not work correctly for you. If there are issues, then report them on the dev-crypto@bouncycastle.org mailing list. Please read the options below, and please pay attention when options are not currently implemented. For the short term expect these tools to change rapidly, and to be updated frequently in the betas directory (http://www.bouncycastle.org/betas)

Thanks.

PGPDump

This tool is similar to the gpg --list-packets command.

java org.bouncycastle.tools.openpgp.PGPDump [-K dir] [-skr file] [-pkr file] 
                                            [-P passphrase] [-pbe passphrase] filename

OptionDescription
-K <keyring dir>Specifies the directory containing the gpg keyring files. These must be called pubring.gpg and secring.gpg. This should be sufficient for general use with gpg compatibility. Use the -pkr and -skr options to specify particular files. Using this option will generally require the -P option when processing encrypted files.
-skr <secretkeyring file>Specifies the file containing the gpg secret keyring file. This must be the full path to the file. Using this option will generally require the -P option.
-pkr <publickeyring file>Specifies the file containing the gpg public keyring file. This must be the full path to the file.
-P <passphrase>Specifies the passphrase to unlock the secret keyring file.
-pbe <passphrase>Specifies the passphrase to decrypt the file using the PGP PBE method. (NOT TESTED)
filenameThe filename is the file to process. This is required

NOTE: Combining options such as -K and -pkr will provide results that are unlikely to be useful.

BCRampage

This tool is similar to the gpg command. This tool provides the capability to encrypt, decrypt, sign and verify PGP messages.

java org.bouncycastle.tools.openpgp.BCRampage [ -e[a] | -d | -s | -v  ]
                                              [-K dir] [-skr file] [-pkr file] 
                                              [-R recipient]
                                              [-P passphrase] [-pbe passphrase]
                                              [-mdc] filename

OptionDescription
-e[a]Encrypt [with ascii armour]
-dDecrypt
-sSign (NOT IMPLEMENTED)
-vVerify (REQUIRES MORE TESTING)
-K <keyring dir>Specifies the directory containing the gpg keyring files. These must be called pubring.gpg and secring.gpg. This should be sufficient for general use with gpg compatibility. Use the -pkr and -skr options to specify particular files. Using this option will generally require the -P option when processing encrypted files.
-skr <secretkeyring file>Specifies the file containing the gpg secret keyring file. This must be the full path to the file. Using this option will generally require the -P option.
-pkr <publickeyring file>Specifies the file containing the gpg public keyring file. This must be the full path to the file.
-P <passphrase>Specifies the passphrase to unlock the secret keyring file.
-pbe <passphrase>Specifies the passphrase to decrypt the file using the PGP PBE method. (NOT TESTED)
-R <recipient>Specifies the recipient of the encrypted message. This is normally the email address of the recipient, however the matching is done using String.indexOf(), so any fragment that is part of the user id attribute string for the key should work.
-mdcIf this option is specified, a PGP MDC (modification detection code) packet is added to the encrypted file. (So, use this with the -e option).The MDC packet contains a SHA-1 digest of the plaintext for comparison with the decrypted plaintext.
filenameThe filename is the file to process. This is required

NOTE: Combining options such as -K and -pkr will provide results that are unlikely to be useful. Mixing options or not providing options that might be needed (such as -e with -d, or -e and no -R) may result in NullPointerExceptions or other strange errors.