From a7f646c2de170b16d40498500e1ae96ee5fd030f Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 1 Aug 2018 21:43:32 -0400 Subject: Avoid requirement to set rng in botan_privkey_load --- src/lib/ffi/ffi.h | 8 +++++--- src/lib/ffi/ffi_pkey.cpp | 8 ++++---- 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 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(password))); + pkcs8 = Botan::PKCS8::load_key(src, std::string(password)); } if(pkcs8) -- cgit v1.2.3