mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
use VerifyDigest for verification
This commit is contained in:
parent
0972782553
commit
5221e09b67
@ -76,11 +76,7 @@ namespace datagram
|
|||||||
|
|
||||||
bool verified = false;
|
bool verified = false;
|
||||||
if (identity.GetSigningKeyType () == i2p::data::SIGNING_KEY_TYPE_DSA_SHA1)
|
if (identity.GetSigningKeyType () == i2p::data::SIGNING_KEY_TYPE_DSA_SHA1)
|
||||||
{
|
verified = CryptoPP::SHA256().VerifyDigest (signature, buf + headerLen, len - headerLen);
|
||||||
uint8_t hash[32];
|
|
||||||
CryptoPP::SHA256().CalculateDigest (hash, buf + headerLen, len - headerLen);
|
|
||||||
verified = identity.Verify (hash, 32, signature);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
verified = identity.Verify (buf + headerLen, len - headerLen, signature);
|
verified = identity.Verify (buf + headerLen, len - headerLen, signature);
|
||||||
|
|
||||||
|
@ -418,9 +418,7 @@ namespace garlic
|
|||||||
buf++; // flag
|
buf++; // flag
|
||||||
|
|
||||||
// payload
|
// payload
|
||||||
uint8_t hash[32];
|
if (!CryptoPP::SHA256().VerifyDigest (payloadHash, buf, payloadSize)) // payload hash doesn't match
|
||||||
CryptoPP::SHA256().CalculateDigest(hash, buf, payloadSize);
|
|
||||||
if (memcmp (hash, payloadHash, 32)) // payload hash doesn't match
|
|
||||||
{
|
{
|
||||||
LogPrint ("Wrong payload hash");
|
LogPrint ("Wrong payload hash");
|
||||||
return;
|
return;
|
||||||
|
@ -255,11 +255,10 @@ namespace transport
|
|||||||
|
|
||||||
m_Decryption.Decrypt((uint8_t *)&m_Establisher->phase2.encrypted, sizeof(m_Establisher->phase2.encrypted), (uint8_t *)&m_Establisher->phase2.encrypted);
|
m_Decryption.Decrypt((uint8_t *)&m_Establisher->phase2.encrypted, sizeof(m_Establisher->phase2.encrypted), (uint8_t *)&m_Establisher->phase2.encrypted);
|
||||||
// verify
|
// verify
|
||||||
uint8_t xy[512], hxy[32];
|
uint8_t xy[512];
|
||||||
memcpy (xy, m_DHKeysPair->publicKey, 256);
|
memcpy (xy, m_DHKeysPair->publicKey, 256);
|
||||||
memcpy (xy + 256, m_Establisher->phase2.pubKey, 256);
|
memcpy (xy + 256, m_Establisher->phase2.pubKey, 256);
|
||||||
CryptoPP::SHA256().CalculateDigest(hxy, xy, 512);
|
if (!CryptoPP::SHA256().VerifyDigest(m_Establisher->phase2.encrypted.hxy, xy, 512))
|
||||||
if (memcmp (hxy, m_Establisher->phase2.encrypted.hxy, 32))
|
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Incorrect hash");
|
LogPrint (eLogError, "Incorrect hash");
|
||||||
transports.ReuseDHKeysPair (m_DHKeysPair);
|
transports.ReuseDHKeysPair (m_DHKeysPair);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user