mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
verify checksum
This commit is contained in:
parent
46ce01c89d
commit
3a864cb6c5
@ -19,6 +19,17 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
LogPrint ("TunnelMessage: zero found at ", (int)(zero-decrypted));
|
LogPrint ("TunnelMessage: zero found at ", (int)(zero-decrypted));
|
||||||
uint8_t * fragment = zero + 1;
|
uint8_t * fragment = zero + 1;
|
||||||
|
// verify checksum
|
||||||
|
memcpy (msg->GetPayload () + TUNNEL_DATA_MSG_SIZE, msg->GetPayload () + 4, 16); // copy iv to the end
|
||||||
|
uint8_t hash[32];
|
||||||
|
CryptoPP::SHA256().CalculateDigest (hash, fragment, TUNNEL_DATA_MSG_SIZE -(fragment - msg->GetPayload ()) + 16); // payload + iv
|
||||||
|
if (memcmp (hash, decrypted, 4))
|
||||||
|
{
|
||||||
|
LogPrint ("TunnelMessage: checksum verification failed");
|
||||||
|
i2p::DeleteI2NPMessage (msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// process fragments
|
||||||
while (fragment < decrypted + TUNNEL_DATA_ENCRYPTED_SIZE)
|
while (fragment < decrypted + TUNNEL_DATA_ENCRYPTED_SIZE)
|
||||||
{
|
{
|
||||||
uint8_t flag = fragment[0];
|
uint8_t flag = fragment[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user