aboutsummaryrefslogtreecommitdiffstats
path: root/src/make_prm.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-05-24 18:25:00 +0000
committerlloyd <[email protected]>2008-05-24 18:25:00 +0000
commitb7563677f13adb8dfa5813ef91ed79364b2d984d (patch)
treecf7fabb3eb43bc49333be726c15ecac1a7f9a1a7 /src/make_prm.cpp
parenta6a9110d02925e111cff2dc1143a09a3b7680f0b (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/make_prm.cpp')
-rw-r--r--src/make_prm.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/make_prm.cpp b/src/make_prm.cpp
index d5f9961af..7d399b825 100644
--- a/src/make_prm.cpp
+++ b/src/make_prm.cpp
@@ -5,7 +5,6 @@
#include <botan/numthry.h>
#include <botan/parsing.h>
-#include <botan/libstate.h>
#include <algorithm>
namespace Botan {
@@ -13,7 +12,8 @@ namespace Botan {
/*************************************************
* Generate a random prime *
*************************************************/
-BigInt random_prime(u32bit bits, const BigInt& coprime,
+BigInt random_prime(RandomNumberGenerator& rng,
+ u32bit bits, const BigInt& coprime,
u32bit equiv, u32bit modulo)
{
if(bits < 48)
@@ -29,7 +29,7 @@ BigInt random_prime(u32bit bits, const BigInt& coprime,
while(true)
{
- BigInt p = random_integer(bits);
+ BigInt p = random_integer(rng, bits);
p.set_bit(bits - 2);
p.set_bit(0);
@@ -61,7 +61,7 @@ BigInt random_prime(u32bit bits, const BigInt& coprime,
if(!passes_sieve || gcd(p - 1, coprime) != 1)
continue;
- if(passes_mr_tests(p))
+ if(passes_mr_tests(rng, p))
return p;
}
}