How do I list all recipient of a message (including myself)?

Werner Koch wk at
Mon May 16 11:24:57 CEST 2011

On Thu, 12 May 2011 04:49, lists at said:

> I am writing application in which I need to know if a GnuPG encrypted
> message was sent to me.  It seems that whenever you list the
> recipients of a message it will list every recipient but you -- even
> if you're one of them.  Surely there's a way to reveal whether or not
> you're one of those recipients...?

$ fortune | gpg2 -er alpha at example -r bravo at example >x
$ gpg2 --status-fd 1 --with-colons --list-only --batch x
[GNUPG:] ENC_TO 5381EA4EE29BA37F 16 0
[GNUPG:] ENC_TO 6AE6D7EE46A871F8 16 0
[GNUPG:] ENC_TO B58845F7F409CD54 1 0

The ENC_TO lines show you the recipients:

    ENC_TO  <long_keyid>  <keytype>  <keylength>
	The message is encrypted to this LONG_KEYID.  KEYTYPE is the
	numerical value of the public key algorithm or 0 if it is not
	known, KEYLENGTH is the length of the key or 0 if it is not
	known (which is currently always the case).  Gpg prints this
	line always; Gpgsm only if it knows the certificate.

The first line above is for the bravo key, the second line for the alpha
key and the third line is my own encryption key.  If a hidden recipient
(option -R) is used you see 0000000000000000 for the long keyid.



Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

More information about the Gnupg-users mailing list