Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions openpgp/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,3 +1303,16 @@ func TestKeyValidateOnDecrypt(t *testing.T) {
t.Fatal("Failed to detect invalid ElGamal key")
}
}

// Should not panic (generated with go-fuzz)
func TestCorruptKeys(t *testing.T) {
data := `-----BEGIN PGP PUBLIC KEY BLOCK00000

mQ00BF00000BCAD0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000ABE000G0Dn000000000000000000iQ00BB0BAgAGBCG00000`
ReadArmoredKeyRing(strings.NewReader(data))
}
2 changes: 1 addition & 1 deletion openpgp/packet/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func parseSignatureSubpacket(sig *Signature, subpacket []byte, isHashed bool) (r
}
case issuerFingerprintSubpacket:
v, l := subpacket[0], len(subpacket[1:])
if v < 5 && l != 20 || v == 5 && l != 32 {
if v == 5 && l != 32 || v != 5 && l != 20 {
return nil, errors.StructuralError("bad fingerprint length")
}
sig.IssuerFingerprint = make([]byte, l)
Expand Down