diff options
author | lloyd <[email protected]> | 2008-06-10 18:14:54 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-06-10 18:14:54 +0000 |
commit | 54fecdc60438d15f970055bb691e18c6469e1785 (patch) | |
tree | 1bd44b39489876256adf3d9a0f4ae88e88cfc9d5 /src | |
parent | dec416d649715617e0eb66b18d69f6dbe9c308b3 (diff) |
PK_Encryptor::encrypt now takes a RandomNumberGenerator reference, instead
of using the global RNG object.
Diffstat (limited to 'src')
-rw-r--r-- | src/dlies.cpp | 3 | ||||
-rw-r--r-- | src/keypair.cpp | 2 | ||||
-rw-r--r-- | src/pk_filts.cpp | 4 | ||||
-rw-r--r-- | src/pubkey.cpp | 18 |
4 files changed, 16 insertions, 11 deletions
diff --git a/src/dlies.cpp b/src/dlies.cpp index d8352ae94..22e606403 100644 --- a/src/dlies.cpp +++ b/src/dlies.cpp @@ -24,7 +24,8 @@ DLIES_Encryptor::DLIES_Encryptor(const PK_Key_Agreement_Key& k, /************************************************* * DLIES Encryption * *************************************************/ -SecureVector<byte> DLIES_Encryptor::enc(const byte in[], u32bit length) const +SecureVector<byte> DLIES_Encryptor::enc(const byte in[], u32bit length, + RandomNumberGenerator&) const { if(length > maximum_input_size()) throw Invalid_Argument("DLIES: Plaintext too large"); diff --git a/src/keypair.cpp b/src/keypair.cpp index e16656dbc..242937668 100644 --- a/src/keypair.cpp +++ b/src/keypair.cpp @@ -26,7 +26,7 @@ void check_key(RandomNumberGenerator& rng, SecureVector<byte> message(enc->maximum_input_size() - 1); rng.randomize(message, message.size()); - SecureVector<byte> ciphertext = enc->encrypt(message); + SecureVector<byte> ciphertext = enc->encrypt(message, rng); if(ciphertext == message) throw Self_Test_Failure("Encryption key pair consistency failure"); diff --git a/src/pk_filts.cpp b/src/pk_filts.cpp index e72c92ef1..6da6dabfd 100644 --- a/src/pk_filts.cpp +++ b/src/pk_filts.cpp @@ -4,6 +4,7 @@ *************************************************/ #include <botan/pk_filts.h> +#include <botan/libstate.h> namespace Botan { @@ -20,7 +21,8 @@ void PK_Encryptor_Filter::write(const byte input[], u32bit length) *************************************************/ void PK_Encryptor_Filter::end_msg() { - send(cipher->encrypt(buffer, buffer.size())); + send(cipher->encrypt(buffer, buffer.size(), + global_state().prng_reference())); buffer.destroy(); } diff --git a/src/pubkey.cpp b/src/pubkey.cpp index dc14c66b7..80f49fcad 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -18,17 +18,19 @@ namespace Botan { /************************************************* * Encrypt a message * *************************************************/ -SecureVector<byte> PK_Encryptor::encrypt(const byte in[], u32bit len) const +SecureVector<byte> PK_Encryptor::encrypt(const byte in[], u32bit len, + RandomNumberGenerator& rng) const { - return enc(in, len); + return enc(in, len, rng); } /************************************************* * Encrypt a message * *************************************************/ -SecureVector<byte> PK_Encryptor::encrypt(const MemoryRegion<byte>& in) const +SecureVector<byte> PK_Encryptor::encrypt(const MemoryRegion<byte>& in, + RandomNumberGenerator& rng) const { - return enc(in.begin(), in.size()); + return enc(in.begin(), in.size(), rng); } /************************************************* @@ -59,11 +61,11 @@ PK_Encryptor_MR_with_EME::PK_Encryptor_MR_with_EME(const PK_Encrypting_Key& k, /************************************************* * Encrypt a message * *************************************************/ -SecureVector<byte> PK_Encryptor_MR_with_EME::enc(const byte msg[], - u32bit length) const +SecureVector<byte> +PK_Encryptor_MR_with_EME::enc(const byte msg[], + u32bit length, + RandomNumberGenerator& rng) const { - RandomNumberGenerator& rng = global_state().prng_reference(); - SecureVector<byte> message; if(encoder) message = encoder->encode(msg, length, key.max_input_bits(), rng); |