aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-05-24 18:28:57 +0000
committerlloyd <[email protected]>2008-05-24 18:28:57 +0000
commitebc67ae27481549a152858f24fff4a7a82ad4e51 (patch)
tree9b8f0e18725ebdee90c5e5e54f2aadcf56bd93af /src
parentb7563677f13adb8dfa5813ef91ed79364b2d984d (diff)
Avoid using global rng in DL_Group::generate_dsa_primes
Diffstat (limited to 'src')
-rw-r--r--src/dl_group.cpp5
-rw-r--r--src/dsa_gen.cpp11
2 files changed, 8 insertions, 8 deletions
diff --git a/src/dl_group.cpp b/src/dl_group.cpp
index d0b27be0c..7ec591b15 100644
--- a/src/dl_group.cpp
+++ b/src/dl_group.cpp
@@ -84,9 +84,10 @@ DL_Group::DL_Group(RandomNumberGenerator& rng,
/*************************************************
* DL_Group Constructor *
*************************************************/
-DL_Group::DL_Group(const MemoryRegion<byte>& seed, u32bit pbits, u32bit qbits)
+DL_Group::DL_Group(RandomNumberGenerator& rng,
+ const MemoryRegion<byte>& seed, u32bit pbits, u32bit qbits)
{
- if(!generate_dsa_primes(p, q, pbits, qbits, seed))
+ if(!generate_dsa_primes(rng, p, q, pbits, qbits, seed))
throw Invalid_Argument("DL_Group: The seed/counter given does not "
"generate a DSA group");
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;
}
}