openpgp: Fix panic on v3 public keys with too-short modulus.
Found using gofuzz. Fixes golang/go#11504 Change-Id: I49cf01e75e37c5d87dad58c5349161d79d0b72f5 Reviewed-on: https://go-review.googlesource.com/12635 Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
committed by
Adam Langley
parent
cb32d3bd66
commit
ae8e58be79
@@ -95,6 +95,11 @@ func (pk *PublicKeyV3) parseRSA(r io.Reader) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// RFC 4880 Section 12.2 requires the low 8 bytes of the
|
||||
// modulus to form the key id.
|
||||
if len(pk.n.bytes) < 8 {
|
||||
return errors.StructuralError("v3 public key modulus is too short")
|
||||
}
|
||||
if len(pk.e.bytes) > 3 {
|
||||
err = errors.UnsupportedError("large public exponent")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user