aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli/utils.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-08-31 13:26:27 -0400
committerJack Lloyd <[email protected]>2017-08-31 13:26:27 -0400
commitbbedc1aac81747ff459f282556ba0cdf250dbfce (patch)
tree5b411c04de5760769202280eb65663d8aed42f6a /src/cli/utils.cpp
parent16af7b986dbf9b04be45cdc075d70f81238269ad (diff)
Simplify RNG logic in CLI a bit
Diffstat (limited to 'src/cli/utils.cpp')
-rw-r--r--src/cli/utils.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp
index ce461cb65..0fb939066 100644
--- a/src/cli/utils.cpp
+++ b/src/cli/utils.cpp
@@ -55,7 +55,7 @@ std::unique_ptr<Botan::RandomNumberGenerator>
cli_make_rng(const std::string& rng_type, const std::string& hex_drbg_seed)
{
#if defined(BOTAN_HAS_SYSTEM_RNG)
- if(rng_type == "system")
+ if(rng_type == "system" || rng_type.empty())
{
return std::unique_ptr<Botan::RandomNumberGenerator>(new Botan::System_RNG);
}
@@ -74,7 +74,7 @@ cli_make_rng(const std::string& rng_type, const std::string& hex_drbg_seed)
const std::vector<uint8_t> drbg_seed = Botan::hex_decode(hex_drbg_seed);
#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
- if(rng_type == "auto" || rng_type == "entropy")
+ if(rng_type == "auto" || rng_type == "entropy" || rng_type.empty())
{
std::unique_ptr<Botan::RandomNumberGenerator> rng;
@@ -236,14 +236,17 @@ class RNG final : public Command
void go() override
{
- std::string type = "auto"; // default
+ std::string type = get_arg("rng-type");
- for(std::string flag : { "system", "rdrand", "auto", "entropy", "drbg" })
+ if(type.empty())
{
- if(flag_set(flag))
+ for(std::string flag : { "system", "rdrand", "auto", "entropy", "drbg" })
{
- type = flag;
- break;
+ if(flag_set(flag))
+ {
+ type = flag;
+ break;
+ }
}
}