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