diff options
author | lloyd <[email protected]> | 2008-05-24 18:28:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-05-24 18:28:57 +0000 |
commit | ebc67ae27481549a152858f24fff4a7a82ad4e51 (patch) | |
tree | 9b8f0e18725ebdee90c5e5e54f2aadcf56bd93af /src/dsa_gen.cpp | |
parent | b7563677f13adb8dfa5813ef91ed79364b2d984d (diff) |
Avoid using global rng in DL_Group::generate_dsa_primes
Diffstat (limited to 'src/dsa_gen.cpp')
-rw-r--r-- | src/dsa_gen.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/dsa_gen.cpp b/src/dsa_gen.cpp index 0e4f5301f..d0b60f73c 100644 --- a/src/dsa_gen.cpp +++ b/src/dsa_gen.cpp @@ -7,7 +7,6 @@ #include <botan/numthry.h> #include <botan/lookup.h> #include <botan/parsing.h> -#include <botan/libstate.h> #include <algorithm> #include <memory> @@ -34,7 +33,8 @@ bool fips186_3_valid_size(u32bit pbits, u32bit qbits) /************************************************* * Attempt DSA prime generation with given seed * *************************************************/ -bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q, +bool DL_Group::generate_dsa_primes(RandomNumberGenerator& rng, + BigInt& p, BigInt& q, u32bit pbits, u32bit qbits, const MemoryRegion<byte>& seed_c) { @@ -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, global_state().prng_reference())) + if(!is_prime(q, rng)) return false; const u32bit n = (pbits-1) / (HASH_SIZE * 8), @@ -104,8 +104,7 @@ bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q, p = X - (X % (2*q) - 1); - if(p.bits() == pbits && - is_prime(p, global_state().prng_reference())) + if(p.bits() == pbits && is_prime(p, rng)) return true; } return false; @@ -124,7 +123,7 @@ SecureVector<byte> DL_Group::generate_dsa_primes(RandomNumberGenerator& rng, { rng.randomize(seed, seed.size()); - if(generate_dsa_primes(p, q, pbits, qbits, seed)) + if(generate_dsa_primes(rng, p, q, pbits, qbits, seed)) return seed; } } |