Skip to content

Commit 2cfbb87

Browse files
griesemeradg
authored andcommitted
crypto/dsa: eliminate invalid PublicKey early
For PublicKey.P == 0, Verify will fail. Don't even try. Change-Id: I1009f2b3dead8d0041626c946633acb10086d8c8 Reviewed-on: https://go-review.googlesource.com/21533 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-on: https://go-review.googlesource.com/21637
1 parent 92faba5 commit 2cfbb87

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/crypto/dsa/dsa.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
249249
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool {
250250
// FIPS 186-3, section 4.7
251251

252+
if pub.P.Sign() == 0 {
253+
return false
254+
}
255+
252256
if r.Sign() < 1 || r.Cmp(pub.Q) >= 0 {
253257
return false
254258
}

0 commit comments

Comments
 (0)