Browse Source

very hash in one pass

pull/200/head
orignal 10 years ago
parent
commit
e8d80e16ba
  1. 6
      ElGamal.h

6
ElGamal.h

@ -60,11 +60,9 @@ 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"); LogPrint ("ElGamal decrypt hash doesn't match");
return false; return false;

Loading…
Cancel
Save