aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli/cli.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/cli.h')
-rw-r--r--src/cli/cli.h41
1 files changed, 8 insertions, 33 deletions
diff --git a/src/cli/cli.h b/src/cli/cli.h
index fcff94870..23cf0ff1c 100644
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -11,14 +11,6 @@
#include <botan/parsing.h>
#include <botan/rng.h>
-#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
- #include <botan/auto_rng.h>
-#endif
-
-#if defined(BOTAN_HAS_SYSTEM_RNG)
- #include <botan/system_rng.h>
-#endif
-
#include <fstream>
#include <iostream>
#include <functional>
@@ -30,6 +22,10 @@
namespace Botan_CLI {
+/* Declared in utils.cpp */
+std::unique_ptr<Botan::RandomNumberGenerator>
+cli_make_rng(const std::string& type, const std::string& hex_drbg_seed);
+
class CLI_Error : public std::runtime_error
{
public:
@@ -334,11 +330,12 @@ class Command
m_spec_opts.insert(std::make_pair("error-output", ""));
#if defined(BOTAN_HAS_SYSTEM_RNG)
- const auto availableRng = "system";
+ const std::string availableRng = "system";
#else
- const auto availableRng = "auto";
+ const std::string availableRng = "user";
#endif
m_spec_opts.insert(std::make_pair("rng-type", availableRng));
+ m_spec_opts.insert(std::make_pair("drbg-seed", ""));
}
/*
@@ -493,29 +490,7 @@ class Command
{
if(m_rng == nullptr)
{
- const std::string rng_type = get_arg("rng-type");
-
- if(rng_type == "system")
- {
-#if defined(BOTAN_HAS_SYSTEM_RNG)
- m_rng.reset(new Botan::System_RNG);
-#endif
- }
-
- // TODO --rng-type=drbg
- // TODO --drbg-seed=hexstr
-
- if(rng_type == "auto")
- {
-#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
- m_rng.reset(new Botan::AutoSeeded_RNG);
-#endif
- }
-
- if(!m_rng)
- {
- throw CLI_Error_Unsupported("rng", rng_type);
- }
+ m_rng = cli_make_rng(get_arg("rng-type"), get_arg("drbg-seed"));
}
return *m_rng.get();