blob: 6a6930805967eef4bcfb754274d06fbfea472f37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package org.bouncycastle.crypto.signers;
import java.math.BigInteger;
import java.security.SecureRandom;
public class RandomDSAKCalculator
implements DSAKCalculator
{
private static final BigInteger ZERO = BigInteger.valueOf(0);
private BigInteger q;
private SecureRandom random;
public boolean isDeterministic()
{
return false;
}
public void init(BigInteger n, SecureRandom random)
{
this.q = n;
this.random = random;
}
public void init(BigInteger n, BigInteger d, byte[] message)
{
throw new IllegalStateException("Operation not supported");
}
public BigInteger nextK()
{
int qBitLength = q.bitLength();
BigInteger k;
do
{
k = new BigInteger(qBitLength, random);
}
while (k.equals(ZERO) || k.compareTo(q) >= 0);
return k;
}
}
|