diff options
author | Jack Lloyd <[email protected]> | 2015-12-30 23:35:16 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-12-30 23:35:16 -0500 |
commit | d4915aa4cd9c11879780267413f2980d0014240e (patch) | |
tree | 8663a7cde0ad9f7fc632c6c2f5ce33a733f8ed26 /src/cli/pubkey.cpp | |
parent | d27416e791c9aed684efe0d6071fe66a43cf7af0 (diff) |
Avoid having Command* objects be created until requested.
Avoids various static init and destruction hassles.
Diffstat (limited to 'src/cli/pubkey.cpp')
-rw-r--r-- | src/cli/pubkey.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/cli/pubkey.cpp b/src/cli/pubkey.cpp index fcda6d21e..93a36a9cc 100644 --- a/src/cli/pubkey.cpp +++ b/src/cli/pubkey.cpp @@ -46,9 +46,9 @@ class PK_Keygen : public Command public: PK_Keygen() : Command("keygen --algo=RSA --params= --passphrase= --pbe= --pbe-millis=300 --der-out") {} - std::unique_ptr<Botan::Private_Key> do_keygen(const std::string& algo, - const std::string& params, - Botan::RandomNumberGenerator& rng) + static std::unique_ptr<Botan::Private_Key> do_keygen(const std::string& algo, + const std::string& params, + Botan::RandomNumberGenerator& rng) { typedef std::function<std::unique_ptr<Botan::Private_Key> (std::string)> gen_fn; std::map<std::string, gen_fn> generators; @@ -129,7 +129,7 @@ class PK_Keygen : public Command } else { - write_output(Botan::PKCS8::BER_encode(*key, rng, pass, pbe_millis, pbe)); + write_output(Botan::PKCS8::BER_encode(*key, rng(), pass, pbe_millis, pbe)); } } else @@ -140,13 +140,13 @@ class PK_Keygen : public Command } else { - output() << Botan::PKCS8::PEM_encode(*key, rng, pass, pbe_millis, pbe); + output() << Botan::PKCS8::PEM_encode(*key, rng(), pass, pbe_millis, pbe); } } } }; -BOTAN_REGISTER_COMMAND(PK_Keygen); +BOTAN_REGISTER_COMMAND("keygen", PK_Keygen); namespace { @@ -186,11 +186,11 @@ class PK_Sign : public Command this->read_file(get_arg("file"), [&signer](const uint8_t b[], size_t l) { signer.update(b, l); }); - output() << Botan::base64_encode(signer.signature(rng)) << "\n"; + output() << Botan::base64_encode(signer.signature(rng())) << "\n"; } }; -BOTAN_REGISTER_COMMAND(PK_Sign); +BOTAN_REGISTER_COMMAND("sign", PK_Sign); class PK_Verify : public Command { @@ -219,7 +219,7 @@ class PK_Verify : public Command } }; -BOTAN_REGISTER_COMMAND(PK_Verify); +BOTAN_REGISTER_COMMAND("verify", PK_Verify); #if defined(BOTAN_HAS_DL_GROUP) @@ -249,7 +249,7 @@ class Gen_DL_Group : public Command } }; -BOTAN_REGISTER_COMMAND(Gen_DL_Group); +BOTAN_REGISTER_COMMAND("gen_dl_group", Gen_DL_Group); #endif @@ -310,7 +310,7 @@ class PKCS8_Tool : public Command } }; -BOTAN_REGISTER_COMMAND(PKCS8_Tool); +BOTAN_REGISTER_COMMAND("pkcs8", PKCS8_Tool); } |