aboutsummaryrefslogtreecommitdiffstats
path: root/include/numthry.h
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 /include/numthry.h
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 'include/numthry.h')
-rw-r--r--include/numthry.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/include/numthry.h b/include/numthry.h
index 44d56601a..6ca06be10 100644
--- a/include/numthry.h
+++ b/include/numthry.h
@@ -6,6 +6,7 @@
#ifndef BOTAN_NUMBTHRY_H__
#define BOTAN_NUMBTHRY_H__
+#include <botan/base.h>
#include <botan/bigint.h>
#include <botan/reducer.h>
#include <botan/pow_mod.h>
@@ -42,23 +43,31 @@ u32bit BOTAN_DLL low_zero_bits(const BigInt&);
/*************************************************
* Primality Testing *
*************************************************/
-bool BOTAN_DLL check_prime(const BigInt&);
-bool BOTAN_DLL is_prime(const BigInt&);
-bool BOTAN_DLL verify_prime(const BigInt&);
+bool BOTAN_DLL check_prime(const BigInt&, RandomNumberGenerator&);
+bool BOTAN_DLL is_prime(const BigInt&, RandomNumberGenerator&);
+bool BOTAN_DLL verify_prime(const BigInt&, RandomNumberGenerator&);
s32bit BOTAN_DLL simple_primality_tests(const BigInt&);
-bool BOTAN_DLL passes_mr_tests(const BigInt&, u32bit = 1);
-bool BOTAN_DLL run_primality_tests(const BigInt&, u32bit = 1);
+
+bool BOTAN_DLL passes_mr_tests(RandomNumberGenerator&,
+ const BigInt&, u32bit = 1);
+
+bool BOTAN_DLL run_primality_tests(RandomNumberGenerator&,
+ const BigInt&, u32bit = 1);
/*************************************************
* Random Number Generation *
*************************************************/
-BigInt BOTAN_DLL random_integer(u32bit);
-BigInt BOTAN_DLL random_integer(const BigInt&, const BigInt&);
-BigInt BOTAN_DLL random_prime(u32bit, const BigInt& = 1,
+BigInt BOTAN_DLL random_integer(RandomNumberGenerator&, u32bit);
+BigInt BOTAN_DLL random_integer(RandomNumberGenerator&,
+ const BigInt&, const BigInt&);
+
+BigInt BOTAN_DLL random_prime(RandomNumberGenerator&,
+ u32bit n, const BigInt& = 1,
u32bit = 1, u32bit = 2);
-BigInt BOTAN_DLL random_safe_prime(u32bit);
+BigInt BOTAN_DLL random_safe_prime(RandomNumberGenerator&,
+ u32bit);
/*************************************************
* Prime Numbers *