Ignore hidden recipients when decrypting

When --throw-keyids, --hidden-recipient, or --hidden-encrypt-to were
used for an encrypted file, the encryption metadata uses all zeroes as
the key ID.  Ignore these key IDs to avoid generating extraneous
messages during decryption or adding invalid IDs to the recipients list.

Closes jamessan/vim-gnupg#50
Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
James McCoy 2015-11-04 21:48:25 -05:00
parent a3e4dc94d4
commit 1c61d3f9ed
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB

View File

@ -514,6 +514,15 @@ function s:GPGDecrypt(bufread)
let start = start + strlen("gpg: public key is ")
let recipient = matchstr(output, s:keyPattern, start)
call s:GPGDebug(1, "recipient is " . recipient)
" In order to support anonymous communication, GnuPG allows eliding
" information in the encryption metadata specifying what keys the file
" was encrypted to (c.f., --throw-keyids and --hidden-recipient). In
" that case, the recipient(s) will be listed as having used a key of all
" zeroes.
" Since this will obviously never actually be in a keyring, only try to
" convert to an ID or add to the recipients list if it's not a hidden
" recipient.
if recipient !~? '^0x0\+$'
let name = s:GPGNameToID(recipient)
if !empty(name)
let b:GPGRecipients += [name]
@ -524,6 +533,7 @@ function s:GPGDecrypt(bufread)
echom "The recipient \"" . recipient . "\" is not in your public keyring!"
echohl None
end
end
let start = match(output, asymmPattern, start)
endwhile
else