aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli/cli.h11
-rw-r--r--src/cli/utils.cpp17
2 files changed, 13 insertions, 15 deletions
diff --git a/src/cli/cli.h b/src/cli/cli.h
index 23cf0ff1c..9568fb76f 100644
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -252,7 +252,8 @@ class Command
virtual std::string help_text() const
{
- return "Usage: " + m_spec;
+ return "Usage: " + m_spec +
+ "\n\nAll commands support --verbose --help --output= --error-output --rng-type= --drbg-seed=";
}
const std::string& cmd_spec() const
@@ -328,13 +329,7 @@ class Command
m_spec_flags.insert("help");
m_spec_opts.insert(std::make_pair("output", ""));
m_spec_opts.insert(std::make_pair("error-output", ""));
-
-#if defined(BOTAN_HAS_SYSTEM_RNG)
- const std::string availableRng = "system";
-#else
- const std::string availableRng = "user";
-#endif
- m_spec_opts.insert(std::make_pair("rng-type", availableRng));
+ m_spec_opts.insert(std::make_pair("rng-type", ""));
m_spec_opts.insert(std::make_pair("drbg-seed", ""));
}
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;
+ }
}
}