From 4a57375c7e921bef0b2b94770af3c1c77e0efb78 Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Sun, 3 Oct 2021 19:31:26 +0200 Subject: [PATCH] feat: return error if verifySignature fail This prevent hard plumbing and to only use io.Reader interface with security. VerifySignature() doesn't return error if verifyKeyRing isn't specified. Signed-off-by: Guilhem Lettron --- crypto/keyring_streaming.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/keyring_streaming.go b/crypto/keyring_streaming.go index 215212a7..52b74a21 100644 --- a/crypto/keyring_streaming.go +++ b/crypto/keyring_streaming.go @@ -159,6 +159,9 @@ func (msg *PlainMessageReader) Read(b []byte) (n int, err error) { n, err = msg.details.UnverifiedBody.Read(b) if errors.Is(err, io.EOF) { msg.readAll = true + if vErr := msg.VerifySignature(); vErr != nil { + err = vErr + } } return } @@ -174,8 +177,6 @@ func (msg *PlainMessageReader) VerifySignature() (err error) { if msg.verifyKeyRing != nil { processSignatureExpiration(msg.details, msg.verifyTime) err = verifyDetailsSignature(msg.details, msg.verifyKeyRing) - } else { - err = errors.New("gopenpgp: no verify keyring was provided before decryption") } return }