From fa9a2ff8687ec9efe57b4b9833d5590d20f8a83f Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 30 Jan 2025 14:10:36 +0100 Subject: [PATCH] crypto: add IsOnCurve check (#31100) --- crypto/crypto.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/crypto.go b/crypto/crypto.go index aaa5cc43a2..f9979aa4bb 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -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 }