diff options
author | lloyd <[email protected]> | 2008-05-24 18:25:00 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-05-24 18:25:00 +0000 |
commit | b7563677f13adb8dfa5813ef91ed79364b2d984d (patch) | |
tree | cf7fabb3eb43bc49333be726c15ecac1a7f9a1a7 /src/dsa_gen.cpp | |
parent | a6a9110d02925e111cff2dc1143a09a3b7680f0b (diff) |
Previously random_integer and friends used the global PRNG object to get
random bits. Now they take a reference to a RandomNumberGenerator object.
This was applied several times out, so now the constructors to private
key objects also take a RandomNumberGenerator& argument. This is also true
for a number of randomized algorithms (Miller-Rabin, for instance).
You can get a reference to the global PRNG with
global_state().prng_reference()
This is a provisional thing: and warning: it is not thread safe! If this
is a problem instead keep per-thread PRNGs and pass them were needed.
Diffstat (limited to 'src/dsa_gen.cpp')
-rw-r--r-- | src/dsa_gen.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/dsa_gen.cpp b/src/dsa_gen.cpp index 002af7d96..0e4f5301f 100644 --- a/src/dsa_gen.cpp +++ b/src/dsa_gen.cpp @@ -80,7 +80,7 @@ bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q, q.set_bit(qbits-1); q.set_bit(0); - if(!is_prime(q)) + if(!is_prime(q, global_state().prng_reference())) return false; const u32bit n = (pbits-1) / (HASH_SIZE * 8), @@ -104,7 +104,8 @@ bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q, p = X - (X % (2*q) - 1); - if(p.bits() == pbits && is_prime(p)) + if(p.bits() == pbits && + is_prime(p, global_state().prng_reference())) return true; } return false; @@ -113,14 +114,15 @@ bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q, /************************************************* * Generate DSA Primes * *************************************************/ -SecureVector<byte> DL_Group::generate_dsa_primes(BigInt& p, BigInt& q, +SecureVector<byte> DL_Group::generate_dsa_primes(RandomNumberGenerator& rng, + BigInt& p, BigInt& q, u32bit pbits, u32bit qbits) { SecureVector<byte> seed(qbits/8); while(true) { - global_state().randomize(seed, seed.size()); + rng.randomize(seed, seed.size()); if(generate_dsa_primes(p, q, pbits, qbits, seed)) return seed; |