aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffi
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-01 21:43:32 -0400
committerJack Lloyd <[email protected]>2018-08-01 21:43:32 -0400
commita7f646c2de170b16d40498500e1ae96ee5fd030f (patch)
treedf4af032ce3ee9866bff6fa6834af227c8d554db /src/lib/ffi
parent2504351f6df8ff07df131dcee3248f4b9595e2d7 (diff)
Avoid requirement to set rng in botan_privkey_load
Diffstat (limited to 'src/lib/ffi')
-rw-r--r--src/lib/ffi/ffi.h8
-rw-r--r--src/lib/ffi/ffi_pkey.cpp8
2 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h
index 5e27962d8..549b09957 100644
--- a/src/lib/ffi/ffi.h
+++ b/src/lib/ffi/ffi.h
@@ -790,10 +790,12 @@ BOTAN_PUBLIC_API(2,5) int botan_privkey_create_elgamal(
/*
* Input currently assumed to be PKCS #8 structure;
* Set password to NULL to indicate no encryption expected
+* The rng parameter is unused and may be set to null
*/
-BOTAN_PUBLIC_API(2,0) int botan_privkey_load(botan_privkey_t* key, botan_rng_t rng,
- const uint8_t bits[], size_t len,
- const char* password);
+BOTAN_PUBLIC_API(2,0) int botan_privkey_load(botan_privkey_t* key,
+ botan_rng_t rng,
+ const uint8_t bits[], size_t len,
+ const char* password);
BOTAN_PUBLIC_API(2,0) int botan_privkey_destroy(botan_privkey_t key);
diff --git a/src/lib/ffi/ffi_pkey.cpp b/src/lib/ffi/ffi_pkey.cpp
index ae7e61433..fe5a47db1 100644
--- a/src/lib/ffi/ffi_pkey.cpp
+++ b/src/lib/ffi/ffi_pkey.cpp
@@ -58,22 +58,22 @@ int botan_privkey_load(botan_privkey_t* key, botan_rng_t rng_obj,
const uint8_t bits[], size_t len,
const char* password)
{
+ BOTAN_UNUSED(rng_obj);
+
*key = nullptr;
return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int {
Botan::DataSource_Memory src(bits, len);
- Botan::RandomNumberGenerator& rng = safe_get(rng_obj);
-
std::unique_ptr<Botan::Private_Key> pkcs8;
if(password == nullptr)
{
- pkcs8.reset(Botan::PKCS8::load_key(src, rng));
+ pkcs8 = Botan::PKCS8::load_key(src);
}
else
{
- pkcs8.reset(Botan::PKCS8::load_key(src, rng, static_cast<std::string>(password)));
+ pkcs8 = Botan::PKCS8::load_key(src, std::string(password));
}
if(pkcs8)