reduced memory usage

This commit is contained in:
orignal 2015-03-10 15:38:37 -04:00
parent 3e889ee06c
commit 5bc854bedc

View File

@ -18,10 +18,12 @@ namespace crypto
{ {
public: public:
ElGamalEncryption (const uint8_t * key): 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))
{ {
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) void Encrypt (const uint8_t * data, int len, uint8_t * encrypted, bool zeroPadding = false)
@ -50,8 +52,7 @@ namespace crypto
private: private:
CryptoPP::AutoSeededRandomPool rnd; CryptoPP::Integer a, b1;
CryptoPP::Integer y, k, a, b1;
}; };
inline bool ElGamalDecrypt (const uint8_t * key, const uint8_t * encrypted, inline bool ElGamalDecrypt (const uint8_t * key, const uint8_t * encrypted,