mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
verify adler checksum
This commit is contained in:
parent
e624cb31bd
commit
b48682012d
2 changed files with 9 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "I2PEndian.h"
|
#include "I2PEndian.h"
|
||||||
#include <cryptopp/dh.h>
|
#include <cryptopp/dh.h>
|
||||||
|
#include <cryptopp/adler32.h>
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
|
@ -587,7 +588,13 @@ namespace transport
|
||||||
if (m_NextMessageOffset >= m_NextMessage->len + 4) // +checksum
|
if (m_NextMessageOffset >= m_NextMessage->len + 4) // +checksum
|
||||||
{
|
{
|
||||||
// we have a complete I2NP message
|
// we have a complete I2NP message
|
||||||
m_Handler.PutNextMessage (m_NextMessage);
|
if (CryptoPP::Adler32().VerifyDigest (m_NextMessage->buf + m_NextMessageOffset - 4, m_NextMessage->buf, m_NextMessageOffset - 4))
|
||||||
|
m_Handler.PutNextMessage (m_NextMessage);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogPrint (eLogWarning, "Incorrect adler checksum of NTCP message. Dropped");
|
||||||
|
DeleteI2NPMessage (m_NextMessage);
|
||||||
|
}
|
||||||
m_NextMessage = nullptr;
|
m_NextMessage = nullptr;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -629,7 +636,7 @@ namespace transport
|
||||||
int padding = 0;
|
int padding = 0;
|
||||||
if (rem > 0) padding = 16 - rem;
|
if (rem > 0) padding = 16 - rem;
|
||||||
// TODO: fill padding
|
// TODO: fill padding
|
||||||
m_Adler.CalculateDigest (sendBuffer + len + 2 + padding, sendBuffer, len + 2+ padding);
|
CryptoPP::Adler32().CalculateDigest (sendBuffer + len + 2 + padding, sendBuffer, len + 2+ padding);
|
||||||
|
|
||||||
int l = len + padding + 6;
|
int l = len + padding + 6;
|
||||||
m_Encryption.Encrypt(sendBuffer, l, sendBuffer);
|
m_Encryption.Encrypt(sendBuffer, l, sendBuffer);
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <cryptopp/modes.h>
|
#include <cryptopp/modes.h>
|
||||||
#include <cryptopp/aes.h>
|
#include <cryptopp/aes.h>
|
||||||
#include <cryptopp/adler32.h>
|
|
||||||
#include "aes.h"
|
#include "aes.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
|
@ -116,7 +115,6 @@ namespace transport
|
||||||
|
|
||||||
i2p::crypto::CBCDecryption m_Decryption;
|
i2p::crypto::CBCDecryption m_Decryption;
|
||||||
i2p::crypto::CBCEncryption m_Encryption;
|
i2p::crypto::CBCEncryption m_Encryption;
|
||||||
CryptoPP::Adler32 m_Adler;
|
|
||||||
|
|
||||||
struct Establisher
|
struct Establisher
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue