aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/math/numbertheory/dsa_gen.cpp8
-rw-r--r--src/math/numbertheory/numthry.h4
-rw-r--r--src/pubkey/dl_group/dl_group.cpp8
3 files changed, 14 insertions, 6 deletions
diff --git a/src/math/numbertheory/dsa_gen.cpp b/src/math/numbertheory/dsa_gen.cpp
index 6f4a7cefa..1e44b7148 100644
--- a/src/math/numbertheory/dsa_gen.cpp
+++ b/src/math/numbertheory/dsa_gen.cpp
@@ -4,7 +4,7 @@
*************************************************/
#include <botan/numthry.h>
-#include <botan/libstate.h>
+#include <botan/algo_factory.h>
#include <botan/hash.h>
#include <botan/parsing.h>
#include <algorithm>
@@ -37,6 +37,7 @@ bool fips186_3_valid_size(u32bit pbits, u32bit qbits)
* Attempt DSA prime generation with given seed *
*************************************************/
bool generate_dsa_primes(RandomNumberGenerator& rng,
+ Algorithm_Factory& af,
BigInt& p, BigInt& q,
u32bit pbits, u32bit qbits,
const MemoryRegion<byte>& seed_c)
@@ -51,8 +52,6 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
"Generating a DSA parameter set with a " + to_string(qbits) +
"long q requires a seed at least as many bits long");
- Algorithm_Factory& af = global_state().algo_factory();
-
std::auto_ptr<HashFunction> hash(
af.make_hash_function("SHA-" + to_string(qbits)));
@@ -116,6 +115,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
* Generate DSA Primes *
*************************************************/
SecureVector<byte> generate_dsa_primes(RandomNumberGenerator& rng,
+ Algorithm_Factory& af,
BigInt& p, BigInt& q,
u32bit pbits, u32bit qbits)
{
@@ -125,7 +125,7 @@ SecureVector<byte> generate_dsa_primes(RandomNumberGenerator& rng,
{
rng.randomize(seed, seed.size());
- if(generate_dsa_primes(rng, p, q, pbits, qbits, seed))
+ if(generate_dsa_primes(rng, af, p, q, pbits, qbits, seed))
return seed;
}
}
diff --git a/src/math/numbertheory/numthry.h b/src/math/numbertheory/numthry.h
index 19726646a..78910d063 100644
--- a/src/math/numbertheory/numthry.h
+++ b/src/math/numbertheory/numthry.h
@@ -74,13 +74,17 @@ BigInt BOTAN_DLL random_safe_prime(RandomNumberGenerator&,
/*************************************************
* DSA Parameter Generation *
*************************************************/
+class Algorithm_Factory;
+
SecureVector<byte> BOTAN_DLL
generate_dsa_primes(RandomNumberGenerator& rng,
+ Algorithm_Factory& af,
BigInt& p, BigInt& q,
u32bit pbits, u32bit qbits);
bool BOTAN_DLL
generate_dsa_primes(RandomNumberGenerator& rng,
+ Algorithm_Factory& af,
BigInt& p_out, BigInt& q_out,
u32bit p_bits, u32bit q_bits,
const MemoryRegion<byte>& seed);
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp
index b37bc238c..d97c86e38 100644
--- a/src/pubkey/dl_group/dl_group.cpp
+++ b/src/pubkey/dl_group/dl_group.cpp
@@ -71,7 +71,9 @@ DL_Group::DL_Group(RandomNumberGenerator& rng,
else
{
qbits = qbits ? qbits : ((pbits == 1024) ? 160 : 256);
- generate_dsa_primes(rng, p, q, pbits, qbits);
+ generate_dsa_primes(rng,
+ global_state().algorithm_factory(),
+ p, q, pbits, qbits);
}
g = make_dsa_generator(p, q);
@@ -86,7 +88,9 @@ DL_Group::DL_Group(RandomNumberGenerator& rng,
DL_Group::DL_Group(RandomNumberGenerator& rng,
const MemoryRegion<byte>& seed, u32bit pbits, u32bit qbits)
{
- if(!generate_dsa_primes(rng, p, q, pbits, qbits, seed))
+ if(!generate_dsa_primes(rng,
+ global_state().algorithm_factory(),
+ p, q, pbits, qbits, seed))
throw Invalid_Argument("DL_Group: The seed given does not "
"generate a DSA group");