mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
very hash in one pass
This commit is contained in:
parent
e461982a31
commit
e8d80e16ba
14
ElGamal.h
14
ElGamal.h
@ -60,15 +60,13 @@ namespace crypto
|
|||||||
{
|
{
|
||||||
CryptoPP::Integer x(key, 256), a(zeroPadding? encrypted +1 : encrypted, 256),
|
CryptoPP::Integer x(key, 256), a(zeroPadding? encrypted +1 : encrypted, 256),
|
||||||
b(zeroPadding? encrypted + 258 :encrypted + 256, 256);
|
b(zeroPadding? encrypted + 258 :encrypted + 256, 256);
|
||||||
uint8_t m[255], hash[32];
|
uint8_t m[255];
|
||||||
a_times_b_mod_c (b, a_exp_b_mod_c (a, elgp - x - 1, elgp), elgp).Encode (m, 255);
|
a_times_b_mod_c (b, a_exp_b_mod_c (a, elgp - x - 1, elgp), elgp).Encode (m, 255);
|
||||||
CryptoPP::SHA256().CalculateDigest(hash, m+33, 222);
|
if (!CryptoPP::SHA256().VerifyDigest (m + 1, m + 33, 222))
|
||||||
for (int i = 0; i < 32; i++)
|
{
|
||||||
if (hash[i] != m[i+1])
|
LogPrint ("ElGamal decrypt hash doesn't match");
|
||||||
{
|
return false;
|
||||||
LogPrint ("ElGamal decrypt hash doesn't match");
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy (data, m + 33, 222);
|
memcpy (data, m + 33, 222);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user