mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-05 09:54:15 +00:00
zero-length address in RelayRequest
This commit is contained in:
parent
2f882a8fe7
commit
4a39dd4818
39
SSU.cpp
39
SSU.cpp
@ -383,29 +383,20 @@ namespace ssu
|
|||||||
{
|
{
|
||||||
buf += 4; // relay tag
|
buf += 4; // relay tag
|
||||||
uint8_t size = *buf;
|
uint8_t size = *buf;
|
||||||
if (size == 4)
|
buf++; // size
|
||||||
{
|
buf += size; // address
|
||||||
buf++; // size
|
buf += 2; // port
|
||||||
boost::asio::ip::address_v4 address (be32toh (*(uint32_t* )buf));
|
uint8_t challengeSize = *buf;
|
||||||
buf += 4; // address
|
buf++; // challenge size
|
||||||
uint16_t port = be16toh (*(uint16_t *)buf);
|
buf += challengeSize;
|
||||||
buf += 2; // port
|
buf += 32; // introkey
|
||||||
uint8_t challengeSize = *buf;
|
uint32_t nonce = be32toh (*(uint32_t *)buf);
|
||||||
buf++; // challenge size
|
SendRelayResponse (nonce, session->m_RemoteEndpoint);
|
||||||
buf += challengeSize;
|
SendRelayIntro (session, m_RemoteEndpoint);
|
||||||
uint8_t * introKey = buf;
|
|
||||||
buf += 32; // introkey
|
|
||||||
uint32_t nonce = be32toh (*(uint32_t *)buf);
|
|
||||||
boost::asio::ip::udp::endpoint from (address, port);
|
|
||||||
SendRelayResponse (nonce, from, introKey, session->m_RemoteEndpoint);
|
|
||||||
SendRelayIntro (session, from);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
LogPrint ("Address size ", size, " is not supported");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::SendRelayResponse (uint32_t nonce, const boost::asio::ip::udp::endpoint& from, const uint8_t * introKey, const boost::asio::ip::udp::endpoint& to)
|
void SSUSession::SendRelayResponse (uint32_t nonce, const boost::asio::ip::udp::endpoint& to)
|
||||||
{
|
{
|
||||||
uint8_t buf[64 + 18];
|
uint8_t buf[64 + 18];
|
||||||
uint8_t * payload = buf + sizeof (SSUHeader);
|
uint8_t * payload = buf + sizeof (SSUHeader);
|
||||||
@ -419,17 +410,17 @@ namespace ssu
|
|||||||
// Alice
|
// Alice
|
||||||
*payload = 4;
|
*payload = 4;
|
||||||
payload++; // size
|
payload++; // size
|
||||||
*(uint32_t *)payload = htobe32 (from.address ().to_v4 ().to_ulong ()); // Alice's IP
|
*(uint32_t *)payload = htobe32 (m_RemoteEndpoint.address ().to_v4 ().to_ulong ()); // Alice's IP
|
||||||
payload += 4; // address
|
payload += 4; // address
|
||||||
*(uint16_t *)payload = htobe16 (from.port ()); // Alice's port
|
*(uint16_t *)payload = htobe16 (m_RemoteEndpoint.port ()); // Alice's port
|
||||||
payload += 2; // port
|
payload += 2; // port
|
||||||
*(uint32_t *)payload = htobe32 (nonce);
|
*(uint32_t *)payload = htobe32 (nonce);
|
||||||
|
|
||||||
uint8_t iv[16];
|
uint8_t iv[16];
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
rnd.GenerateBlock (iv, 16); // random iv
|
rnd.GenerateBlock (iv, 16); // random iv
|
||||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_RESPONSE, buf, 64, introKey, iv, introKey);
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_RESPONSE, buf, 64, m_SessionKey, iv, m_MacKey);
|
||||||
m_Server.Send (buf, 64, from);
|
Send (buf, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::SendRelayIntro (SSUSession * session, const boost::asio::ip::udp::endpoint& from)
|
void SSUSession::SendRelayIntro (SSUSession * session, const boost::asio::ip::udp::endpoint& from)
|
||||||
|
2
SSU.h
2
SSU.h
@ -91,7 +91,7 @@ namespace ssu
|
|||||||
void ProcessSessionConfirmed (uint8_t * buf, size_t len);
|
void ProcessSessionConfirmed (uint8_t * buf, size_t len);
|
||||||
void SendSessionConfirmed (const uint8_t * y, const uint8_t * ourAddress);
|
void SendSessionConfirmed (const uint8_t * y, const uint8_t * ourAddress);
|
||||||
void ProcessRelayRequest (uint8_t * buf, size_t len);
|
void ProcessRelayRequest (uint8_t * buf, size_t len);
|
||||||
void SendRelayResponse (uint32_t nonce, const boost::asio::ip::udp::endpoint& from, const uint8_t * introKey, const boost::asio::ip::udp::endpoint& to);
|
void SendRelayResponse (uint32_t nonce, const boost::asio::ip::udp::endpoint& to);
|
||||||
void SendRelayIntro (SSUSession * session, const boost::asio::ip::udp::endpoint& from);
|
void SendRelayIntro (SSUSession * session, const boost::asio::ip::udp::endpoint& from);
|
||||||
void ProcessRelayResponse (uint8_t * buf, size_t len);
|
void ProcessRelayResponse (uint8_t * buf, size_t len);
|
||||||
void ProcessRelayIntro (uint8_t * buf, size_t len);
|
void ProcessRelayIntro (uint8_t * buf, size_t len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user