3

Is it possible to determine, given a PGP message that you can already decrypt, to determine which other PGP keys that message has also been encrypted for?

8

First of all, although you used , I assume you will actually be using GnuPG. Otherwise, fetch it - it's free software. Although PGP will probably also have similar functionality.

Hidden Recipients

It depends. If the sender included the recipient's key fingerprints, you can retrieve them; otherwise (if encrypted using the --hidden-recipient option) GnuPG has to test all your private decryption keys against the message.

Listing (non-Hidden) Recipients

If the recipients are included, GnuPG will list them when set to verbose mode (--verbose). To prevent GnuPG from actually decrypting the message, add --list-only. The relevant lines are the ones starting with gpg: public key is.

This will output public subkeys, which you have to resolve again using gpg --list-keys [key-id].

A complete command line to retrieve the recipients from a message:

cat message.pgp | LANG=C gpg --verbose --list-only 2>&1 | grep 'gpg: public key is'

If you even want to automatically resolve subkeys, additionally pipe through cut and xargs:

cat message.pgp | LANG=C gpg --verbose --list-only 2>&1 | grep 'gpg: public key is' | cut -d' ' -f 5 | xargs gpg --list-keys

LANG=C is used to enforce English localization, so grepping will not fail for other languages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.