From a04abd304aa1027c5c4638f311ac826b496b1ccd Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 2 Jun 2022 18:23:51 -0400 Subject: [PATCH] don't send own hash for peer test msg 1 --- libi2pd/SSU2.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libi2pd/SSU2.cpp b/libi2pd/SSU2.cpp index ba092e10..2263b044 100644 --- a/libi2pd/SSU2.cpp +++ b/libi2pd/SSU2.cpp @@ -1576,14 +1576,20 @@ namespace transport const uint8_t * routerHash, const uint8_t * signedData, size_t signedDataLen) { buf[0] = eSSU2BlkPeerTest; - size_t payloadSize = 3/* msg, code, flag */ + 32/* router hash */ + signedDataLen; + size_t payloadSize = 3/* msg, code, flag */ + signedDataLen; + if (routerHash) payloadSize += 32; // router hash if (payloadSize + 3 > len) return 0; htobe16buf (buf + 1, payloadSize); // size buf[3] = msg; // msg buf[4] = 0; // code, TODO: buf[5] = 0; //flag - memcpy (buf + 6, routerHash, 32); // router hash - memcpy (buf + 38, signedData, signedDataLen); + size_t offset = 6; + if (routerHash) + { + memcpy (buf + offset, routerHash, 32); // router hash + offset += 32; + } + memcpy (buf + offset, signedData, signedDataLen); return payloadSize + 3; } @@ -1607,8 +1613,7 @@ namespace transport s.Insert (GetRemoteIdentity ()->GetIdentHash (), 32); // bhash s.Insert (signedData, 7 + asz); // ver, nonce, ts, asz, Alice's endpoint s.Sign (i2p::context.GetPrivateKeys (), signedData + 7 + asz); - return CreatePeerTestBlock (buf, len, 1, i2p::context.GetIdentHash (), - signedData, 7 + asz + i2p::context.GetIdentity ()->GetSignatureLen ()); + return CreatePeerTestBlock (buf, len, 1, nullptr, signedData, 7 + asz + i2p::context.GetIdentity ()->GetSignatureLen ()); } std::shared_ptr SSU2Session::ExtractRouterInfo (const uint8_t * buf, size_t size)