Skip to content

Commit

Permalink
[release-branch.go1.12-security] crypto/dsa: prevent bad public keys …
Browse files Browse the repository at this point in the history
…from causing panic

dsa.Verify might currently use a nil s inverse in a
multiplication if the public key contains a non-prime Q,
causing a panic. Change this to check that the mod
inverse exists before using it.

Fixes CVE-2019-17596

Change-Id: I94d5f3cc38f1b5d52d38dcb1d253c71b7fd1cae7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/572809
Reviewed-by: Filippo Valsorda <valsorda@google.com>
(cherry picked from commit 9119dfb0511326d4485b248b83d4fde19c95d0f7)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/575232
  • Loading branch information
katiehockman committed Oct 16, 2019
1 parent 6c15c7c commit 2017d88
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/crypto/dsa/dsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool {
}

w := new(big.Int).ModInverse(s, pub.Q)
if w == nil {
return false
}

n := pub.Q.BitLen()
if n&7 != 0 {
Expand Down

0 comments on commit 2017d88

Please sign in to comment.