From efc498ca4caa340ac2fe11f2efee06c1a294501f Mon Sep 17 00:00:00 2001 From: David Hook Date: Mon, 18 Dec 2023 14:41:35 +1100 Subject: [PATCH] added bounds check on f2m field size. --- core/src/main/java/org/bouncycastle/math/ec/ECCurve.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java b/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java index 04bde03404..dec459d49e 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java +++ b/core/src/main/java/org/bouncycastle/math/ec/ECCurve.java @@ -998,6 +998,11 @@ protected ECFieldElement solveQuadraticEquation(ECFieldElement beta) int m = this.getFieldSize(); + if (m > Properties.asInteger("org.bouncycastle.ec.max_f2m_field_size", 1142)) // twice 571 + { + throw new IllegalStateException("field size out of range: " + m); + } + // For odd m, use the half-trace if (0 != (m & 1)) {