aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-12-14 08:57:49 -0500
committerJack Lloyd <[email protected]>2020-12-14 08:59:58 -0500
commit2dd662b85abfe545bfe12c4952a8f61a45de8ca3 (patch)
tree6aba3751cc8255d3dec5f46dbc3290036be355d1 /src/cli
parent9b5e3fb65e660d6b4830acdd50bda8f0165c5181 (diff)
Avoid using deprecated functions for key loading
Also update the documentation a bit, this area is really out of date
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/pubkey.cpp4
-rw-r--r--src/cli/tls_helpers.h6
-rw-r--r--src/cli/tls_server.cpp2
-rw-r--r--src/cli/x509.cpp11
4 files changed, 13 insertions, 10 deletions
diff --git a/src/cli/pubkey.cpp b/src/cli/pubkey.cpp
index 1c5aaab5f..e70e616f8 100644
--- a/src/cli/pubkey.cpp
+++ b/src/cli/pubkey.cpp
@@ -309,11 +309,11 @@ class PKCS8_Tool final : public Command
if(pass_in.empty())
{
- key.reset(Botan::PKCS8::load_key(key_src, rng()));
+ key = Botan::PKCS8::load_key(key_src);
}
else
{
- key.reset(Botan::PKCS8::load_key(key_src, rng(), pass_in));
+ key = Botan::PKCS8::load_key(key_src, pass_in);
}
const std::chrono::milliseconds pbe_millis(get_arg_sz("pbe-millis"));
diff --git a/src/cli/tls_helpers.h b/src/cli/tls_helpers.h
index f23a70798..c973d685d 100644
--- a/src/cli/tls_helpers.h
+++ b/src/cli/tls_helpers.h
@@ -55,13 +55,13 @@ class Basic_Credentials_Manager : public Botan::Credentials_Manager
#endif
}
- Basic_Credentials_Manager(Botan::RandomNumberGenerator& rng,
- const std::string& server_crt,
+ Basic_Credentials_Manager(const std::string& server_crt,
const std::string& server_key)
{
Certificate_Info cert;
- cert.key.reset(Botan::PKCS8::load_key(server_key, rng));
+ Botan::DataSource_Stream key_in(server_key);
+ cert.key = Botan::PKCS8::load_key(key_in);
Botan::DataSource_Stream in(server_crt);
while(!in.end_of_data())
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp
index c39061e64..2d882f3dc 100644
--- a/src/cli/tls_server.cpp
+++ b/src/cli/tls_server.cpp
@@ -82,7 +82,7 @@ class TLS_Server final : public Command, public Botan::TLS::Callbacks
Botan::TLS::Session_Manager_In_Memory session_manager(rng()); // TODO sqlite3
- Basic_Credentials_Manager creds(rng(), server_crt, server_key);
+ Basic_Credentials_Manager creds(server_crt, server_key);
output() << "Listening for new connections on " << transport << " port " << port << std::endl;
diff --git a/src/cli/x509.cpp b/src/cli/x509.cpp
index 64e66366e..a11411dfd 100644
--- a/src/cli/x509.cpp
+++ b/src/cli/x509.cpp
@@ -109,13 +109,14 @@ class Sign_Cert final : public Command
const std::string hash = get_arg("hash");
std::unique_ptr<Botan::Private_Key> key;
+ Botan::DataSource_Stream key_stream(key_file);
if(!pass.empty())
{
- key.reset(Botan::PKCS8::load_key(key_file, rng(), pass));
+ key = Botan::PKCS8::load_key(key_stream, pass);
}
else
{
- key.reset(Botan::PKCS8::load_key(key_file, rng()));
+ key = Botan::PKCS8::load_key(key_stream);
}
if(!key)
@@ -312,7 +313,8 @@ class Gen_Self_Signed final : public Command
{
const std::string key_file = get_arg("key");
const std::string passphrase = get_passphrase_arg("Passphrase for " + key_file, "key-pass");
- std::unique_ptr<Botan::Private_Key> key(Botan::PKCS8::load_key(key_file, rng(), passphrase));
+ Botan::DataSource_Stream key_stream(key_file);
+ std::unique_ptr<Botan::Private_Key> key = Botan::PKCS8::load_key(key_stream, passphrase);
if(!key)
{
@@ -373,7 +375,8 @@ class Generate_PKCS10 final : public Command
void go() override
{
- std::unique_ptr<Botan::Private_Key> key(Botan::PKCS8::load_key(get_arg("key"), rng(), get_arg("key-pass")));
+ Botan::DataSource_Stream key_stream(get_arg("key"));
+ std::unique_ptr<Botan::Private_Key> key = Botan::PKCS8::load_key(key_stream, get_arg("key-pass"));
if(!key)
{