From 5bc854bedc71a94ff04318eafef6916aa137653e Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 10 Mar 2015 15:38:37 -0400 Subject: [PATCH] reduced memory usage --- ElGamal.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ElGamal.h b/ElGamal.h index e69c5993..d7105c41 100644 --- a/ElGamal.h +++ b/ElGamal.h @@ -18,10 +18,12 @@ namespace crypto { public: - ElGamalEncryption (const uint8_t * key): - y (key, 256), k (rnd, CryptoPP::Integer::One(), elgp-1), - a (a_exp_b_mod_c (elgg, k, elgp)), b1 (a_exp_b_mod_c (y, k, elgp)) + ElGamalEncryption (const uint8_t * key) { + CryptoPP::AutoSeededRandomPool rnd; + CryptoPP::Integer y (key, 256), k (rnd, CryptoPP::Integer::One(), elgp-1); + a = a_exp_b_mod_c (elgg, k, elgp); + b1 = a_exp_b_mod_c (y, k, elgp); } void Encrypt (const uint8_t * data, int len, uint8_t * encrypted, bool zeroPadding = false) @@ -50,8 +52,7 @@ namespace crypto private: - CryptoPP::AutoSeededRandomPool rnd; - CryptoPP::Integer y, k, a, b1; + CryptoPP::Integer a, b1; }; inline bool ElGamalDecrypt (const uint8_t * key, const uint8_t * encrypted,