Skip to content

Commit

Permalink
feat: return error if verifySignature fail
Browse files Browse the repository at this point in the history
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 <guilhem@barpilot.io>
  • Loading branch information
guilhem committed Oct 3, 2021
1 parent d1b2846 commit 4a57375
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crypto/keyring_streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 4a57375

Please sign in to comment.