aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffi/ffi_pkey.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/ffi/ffi_pkey.cpp b/src/lib/ffi/ffi_pkey.cpp
index 1577118b1..d4c629149 100644
--- a/src/lib/ffi/ffi_pkey.cpp
+++ b/src/lib/ffi/ffi_pkey.cpp
@@ -56,16 +56,21 @@ int botan_privkey_load(botan_privkey_t* key, botan_rng_t rng_obj,
{
*key = nullptr;
- if(password == nullptr)
- password = "";
-
return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() {
Botan::DataSource_Memory src(bits, len);
Botan::RandomNumberGenerator& rng = safe_get(rng_obj);
- std::unique_ptr<Botan::PKCS8_PrivateKey> pkcs8(
- Botan::PKCS8::load_key(src, rng, static_cast<std::string>(password)));
+ std::unique_ptr<Botan::PKCS8_PrivateKey> pkcs8;
+
+ if(password == nullptr)
+ {
+ pkcs8.reset(Botan::PKCS8::load_key(src, rng));
+ }
+ else
+ {
+ pkcs8.reset(Botan::PKCS8::load_key(src, rng, static_cast<std::string>(password)));
+ }
if(pkcs8)
{