aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli/math.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-27 00:22:14 -0500
committerJack Lloyd <[email protected]>2015-12-27 00:22:14 -0500
commitd27416e791c9aed684efe0d6071fe66a43cf7af0 (patch)
tree8da077c7ac4a0b4d7c368e63591716d4b665f224 /src/cli/math.cpp
parentb36cb4b4ab944f91fbf34d730806fc74640cd2f8 (diff)
Add Command::rng()
for when a command wants an RNG but doesn't much care what kind. This adds a place where a future --rng-type= option can be consulted to eg use the system RNG or a user seeded DRBG.
Diffstat (limited to 'src/cli/math.cpp')
-rw-r--r--src/cli/math.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/cli/math.cpp b/src/cli/math.cpp
index c6f40e785..07b809d19 100644
--- a/src/cli/math.cpp
+++ b/src/cli/math.cpp
@@ -10,7 +10,6 @@
#include <botan/reducer.h>
#include <botan/numthry.h>
-#include <botan/auto_rng.h>
#include <iterator>
namespace Botan_CLI {
@@ -22,14 +21,12 @@ class Gen_Prime : public Command
void go() override
{
- Botan::AutoSeeded_RNG rng;
-
const size_t bits = get_arg_sz("bits");
const size_t cnt = get_arg_sz("count");
for(size_t i = 0; i != cnt; ++i)
{
- const Botan::BigInt p = Botan::random_prime(rng, bits);
+ const Botan::BigInt p = Botan::random_prime(rng(), bits);
output() << p << "\n";
}
}
@@ -46,8 +43,7 @@ class Is_Prime : public Command
{
Botan::BigInt n(get_arg("n"));
const size_t prob = get_arg_sz("prob");
- Botan::AutoSeeded_RNG rng;
- const bool prime = Botan::is_prime(n, rng, prob);
+ const bool prime = Botan::is_prime(n, rng(), prob);
output() << n << " is " << (prime ? "probably prime" : "composite") << "\n";
}
@@ -68,9 +64,7 @@ class Factor : public Command
{
Botan::BigInt n(get_arg("n"));
- Botan::AutoSeeded_RNG rng;
-
- std::vector<Botan::BigInt> factors = factorize(n, rng);
+ std::vector<Botan::BigInt> factors = factorize(n, rng());
std::sort(factors.begin(), factors.end());
output() << n << ": ";