diff options
author | lloyd <[email protected]> | 2013-12-25 19:57:13 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2013-12-25 19:57:13 +0000 |
commit | a4a59c29500bbae02273bfb75ddb8318a449e851 (patch) | |
tree | 7779f1c9b2708e55eb0f7ad1d5208753a1966ce1 /src/pubkey/elgamal | |
parent | 4d2242a5e920ba14e37c69a8962b34d08cd485f6 (diff) |
Remove global_rng calls for setting up blinding, instead require a RNG
be passed to the engine. Currently pubkey.cpp just passes along the
global_rng but eventually we'll break this API and require a RNG to
the constructor.
Diffstat (limited to 'src/pubkey/elgamal')
-rw-r--r-- | src/pubkey/elgamal/elgamal.cpp | 6 | ||||
-rw-r--r-- | src/pubkey/elgamal/elgamal.h | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/pubkey/elgamal/elgamal.cpp b/src/pubkey/elgamal/elgamal.cpp index 837528af8..3e22aee1a 100644 --- a/src/pubkey/elgamal/elgamal.cpp +++ b/src/pubkey/elgamal/elgamal.cpp @@ -7,7 +7,6 @@ #include <botan/elgamal.h> #include <botan/numthry.h> -#include <botan/libstate.h> #include <botan/keypair.h> #include <botan/internal/workfactor.h> @@ -98,14 +97,15 @@ ElGamal_Encryption_Operation::encrypt(const byte msg[], size_t msg_len, return output; } -ElGamal_Decryption_Operation::ElGamal_Decryption_Operation(const ElGamal_PrivateKey& key) +ElGamal_Decryption_Operation::ElGamal_Decryption_Operation(const ElGamal_PrivateKey& key, + RandomNumberGenerator& rng) { const BigInt& p = key.group_p(); powermod_x_p = Fixed_Exponent_Power_Mod(key.get_x(), p); mod_p = Modular_Reducer(p); - BigInt k(global_state().global_rng(), std::min<size_t>(160, p.bits() - 1)); + BigInt k(rng, p.bits() - 1); blinder = Blinder(k, powermod_x_p(k), p); } diff --git a/src/pubkey/elgamal/elgamal.h b/src/pubkey/elgamal/elgamal.h index 957aa4656..9566bcca6 100644 --- a/src/pubkey/elgamal/elgamal.h +++ b/src/pubkey/elgamal/elgamal.h @@ -81,7 +81,8 @@ class BOTAN_DLL ElGamal_Decryption_Operation : public PK_Ops::Decryption public: size_t max_input_bits() const { return mod_p.get_modulus().bits() - 1; } - ElGamal_Decryption_Operation(const ElGamal_PrivateKey& key); + ElGamal_Decryption_Operation(const ElGamal_PrivateKey& key, + RandomNumberGenerator& rng); secure_vector<byte> decrypt(const byte msg[], size_t msg_len); private: |