crypto: add IsOnCurve check (#31100) (#374)

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
David 2025-01-31 18:00:43 +08:00 committed by GitHub
parent cdca79128b
commit d9086a2838
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -178,6 +178,9 @@ func UnmarshalPubkey(pub []byte) (*ecdsa.PublicKey, error) {
if x == nil {
return nil, errInvalidPubkey
}
if !S256().IsOnCurve(x, y) {
return nil, errInvalidPubkey
}
return &ecdsa.PublicKey{Curve: S256(), X: x, Y: y}, nil
}