Skip to content

Commit 9171ce2

Browse files
committed
expanded range of e generation.
1 parent bda52d5 commit 9171ce2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

core/src/main/java/org/bouncycastle/crypto/signers/DSTU4145Signer.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)