mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-16 00:12:43 +00:00
reduced memory usage
This commit is contained in:
parent
3e889ee06c
commit
5bc854bedc
11
ElGamal.h
11
ElGamal.h
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user