File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
core/src/main/java/org/bouncycastle/crypto/signers Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -149,11 +149,20 @@ protected ECMultiplier createBasePointMultiplier()
149149 }
150150
151151 /**
152- * Generates random integer such, than its bit length is less than that of n
152+ * Generates random integer such that its value is less than that of n
153153 */
154154 private static BigInteger generateRandomInteger (BigInteger n , SecureRandom random )
155155 {
156- return BigIntegers .createRandomBigInteger (n .bitLength () - 1 , random );
156+ int nBitLength = n .bitLength ();
157+
158+ BigInteger k ;
159+ do
160+ {
161+ k = BigIntegers .createRandomBigInteger (nBitLength , random );
162+ }
163+ while (k .equals (BigIntegers .ZERO ) || k .compareTo (n ) >= 0 );
164+
165+ return k ;
157166 }
158167
159168 private static ECFieldElement hash2FieldElement (ECCurve curve , byte [] hash )
You can’t perform that action at this time.
0 commit comments