diff options
author | lloyd <[email protected]> | 2008-06-20 11:32:06 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-06-20 11:32:06 +0000 |
commit | 8f32a90b0aa6ab873c1d5337947e3642c640e3a4 (patch) | |
tree | 05a0bddb2a7174d666e91075a81b5ed4642eac62 /src/pkcs8.cpp | |
parent | 79c7591a0946bb20fd50de136970cc0b1454430a (diff) |
Use RNG& argument for PKCS8::encrypt_key and PKCS8::PEM_encode
Diffstat (limited to 'src/pkcs8.cpp')
-rw-r--r-- | src/pkcs8.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pkcs8.cpp b/src/pkcs8.cpp index 330437894..fe5041a62 100644 --- a/src/pkcs8.cpp +++ b/src/pkcs8.cpp @@ -12,7 +12,6 @@ #include <botan/oids.h> #include <botan/pem.h> #include <botan/pbe.h> -#include <botan/libstate.h> #include <memory> namespace Botan { @@ -35,7 +34,6 @@ SecureVector<byte> PKCS8_extract(DataSource& source, .decode(key_data, OCTET_STRING) .verify_end(); - return key_data; } @@ -162,7 +160,9 @@ void encode(const Private_Key& key, Pipe& pipe, X509_Encoding encoding) /************************************************* * Encode and encrypt a PKCS #8 private key * *************************************************/ -void encrypt_key(const Private_Key& key, Pipe& pipe, +void encrypt_key(const Private_Key& key, + Pipe& pipe, + RandomNumberGenerator& rng, const std::string& pass, const std::string& pbe_algo, X509_Encoding encoding) { @@ -174,7 +174,7 @@ void encrypt_key(const Private_Key& key, Pipe& pipe, raw_key.end_msg(); PBE* pbe = get_pbe(((pbe_algo != "") ? pbe_algo : DEFAULT_PBE)); - pbe->new_params(global_state().prng_reference()); + pbe->new_params(rng); pbe->set_key(pass); Pipe key_encrytor(pbe); @@ -209,7 +209,9 @@ std::string PEM_encode(const Private_Key& key) /************************************************* * Encrypt and PEM encode a PKCS #8 private key * *************************************************/ -std::string PEM_encode(const Private_Key& key, const std::string& pass, +std::string PEM_encode(const Private_Key& key, + RandomNumberGenerator& rng, + const std::string& pass, const std::string& pbe_algo) { if(pass == "") @@ -217,7 +219,7 @@ std::string PEM_encode(const Private_Key& key, const std::string& pass, Pipe pem; pem.start_msg(); - encrypt_key(key, pem, pass, pbe_algo, PEM); + encrypt_key(key, pem, rng, pass, pbe_algo, PEM); pem.end_msg(); return pem.read_all_as_string(); } |