diff options
author | Alexander Bluhm <[email protected]> | 2017-03-29 02:48:52 +0200 |
---|---|---|
committer | Alexander Bluhm <[email protected]> | 2017-03-29 17:55:03 +0200 |
commit | 2377e2b25c9daa61c7b8908bf99a5aaf794e799f (patch) | |
tree | b64a16e9d938bebd781fa95c83be0b4a690049ee /src/cli | |
parent | 8eacc25b3617195ba901404768fdc6e72fe3ed46 (diff) |
Use entropy source for cli rng.
With "botan rng --entropy" the global entropy sources are used to
seed the auto seeded random number generator.
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/utils.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp index c0af0332e..76501add4 100644 --- a/src/cli/utils.cpp +++ b/src/cli/utils.cpp @@ -10,6 +10,7 @@ #include <botan/hash.h> #include <botan/cpuid.h> #include <botan/hex.h> +#include <botan/entropy_src.h> #if defined(BOTAN_HAS_BASE64_CODEC) #include <botan/base64.h> @@ -156,7 +157,7 @@ BOTAN_REGISTER_COMMAND("hash", Hash); class RNG final : public Command { public: - RNG() : Command("rng --system --rdrand *bytes") {} + RNG() : Command("rng --system --rdrand --entropy *bytes") {} void go() override { @@ -180,6 +181,15 @@ class RNG final : public Command return; #endif } + else if(flag_set("entropy")) + { +#if defined(BOTAN_HAS_AUTO_SEEDING_RNG) + rng.reset(new Botan::AutoSeeded_RNG(Botan::Entropy_Sources::global_sources())); +#else + error_output() << "auto_rng disabled in build\n"; + return; +#endif + } else { #if defined(BOTAN_HAS_AUTO_SEEDING_RNG) |