aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli/utils.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-07-01 07:20:17 -0400
committerJack Lloyd <[email protected]>2016-07-17 10:43:41 -0400
commit9e6013809d63f3365023e6047fa31865db4e556d (patch)
treed82061d59ba7a00d086c054372ae3c17ec8aa684 /src/cli/utils.cpp
parenta9dceed96891088efe454018bd027b58929596cf (diff)
Update rng cli - can make multiple requests
Diffstat (limited to 'src/cli/utils.cpp')
-rw-r--r--src/cli/utils.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp
index 199a7894f..76e445126 100644
--- a/src/cli/utils.cpp
+++ b/src/cli/utils.cpp
@@ -149,24 +149,29 @@ BOTAN_REGISTER_COMMAND("hash", Hash);
class RNG final : public Command
{
public:
- RNG() : Command("rng bytes --system") {}
+ RNG() : Command("rng --system *bytes") {}
void go() override
{
- const size_t bytes = get_arg_sz("bytes");
+ std::unique_ptr<Botan::RNG> rng;
if(flag_set("system"))
{
#if defined(BOTAN_HAS_SYSTEM_RNG)
- output() << Botan::hex_encode(Botan::system_rng().random_vec(bytes)) << "\n";
+ rng.reset(new Botan::System_RNG);
#else
error_output() << "system_rng disabled in build\n";
+ return;
#endif
}
else
{
- Botan::AutoSeeded_RNG rng;
- output() << Botan::hex_encode(rng.random_vec(bytes)) << "\n";
+ rng.reset(new Botan::AutoSeeded_RNG);
+ }
+
+ for(const std::string& req : get_arg_list("bytes"))
+ {
+ output() << Botan::hex_encode(rng->random_vec(Botan::to_u32bit(req))) << "\n";
}
}
};