aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/elliptic/elliptic.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/elliptic/elliptic.go')
-rw-r--r--src/crypto/elliptic/elliptic.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/crypto/elliptic/elliptic.go b/src/crypto/elliptic/elliptic.go
index f93dc16419..afedf18df1 100644
--- a/src/crypto/elliptic/elliptic.go
+++ b/src/crypto/elliptic/elliptic.go
@@ -71,6 +71,11 @@ func (curve *CurveParams) polynomial(x *big.Int) *big.Int {
}
func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool {
+ if x.Sign() < 0 || x.Cmp(curve.P) >= 0 ||
+ y.Sign() < 0 || y.Cmp(curve.P) >= 0 {
+ return false
+ }
+
// y² = x³ - 3x + b
y2 := new(big.Int).Mul(y, y)
y2.Mod(y2, curve.P)