mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 00:34:20 +00:00
send peer test by Alice
This commit is contained in:
parent
654fe138a8
commit
45d1571559
31
SSU.cpp
31
SSU.cpp
@ -731,6 +731,33 @@ namespace ssu
|
||||
m_Server.Send (buf, 80, e);
|
||||
}
|
||||
|
||||
void SSUSession::SendPeerTest ()
|
||||
{
|
||||
auto introKey = GetIntroKey ();
|
||||
if (!introKey)
|
||||
{
|
||||
LogPrint ("SSU is not supported. Can't send peer test");
|
||||
return;
|
||||
}
|
||||
uint8_t buf[80 + 18];
|
||||
uint8_t * payload = buf + sizeof (SSUHeader);
|
||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||
uint32_t nonce = 0;
|
||||
rnd.GenerateWord32 (nonce);
|
||||
*(uint32_t *)payload = htobe32 (nonce);
|
||||
payload += 4; // nonce
|
||||
*payload = 4;
|
||||
payload++; // size
|
||||
memset (payload, 0, 6); // address and port always zero for Alice
|
||||
payload += 6; // address and port
|
||||
memcpy (payload, introKey, 32); // intro key
|
||||
uint8_t iv[16];
|
||||
rnd.GenerateBlock (iv, 16); // random iv
|
||||
// encrypt message with session key
|
||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_PEER_TEST, buf, 80, m_SessionKey, iv, m_MacKey);
|
||||
m_Server.Send (buf, 80, m_RemoteEndpoint);
|
||||
}
|
||||
|
||||
void SSUSession::SendMsgAck (uint32_t msgID)
|
||||
{
|
||||
uint8_t buf[48 + 18]; // actual length is 44 = 37 + 7 but pad it to multiple of 16
|
||||
@ -822,8 +849,8 @@ namespace ssu
|
||||
len = 0;
|
||||
fragmentNum++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SSUSession::Send (uint8_t type, const uint8_t * payload, size_t len)
|
||||
{
|
||||
uint8_t buf[SSU_MTU + 18];
|
||||
|
3
SSU.h
3
SSU.h
@ -80,7 +80,8 @@ namespace ssu
|
||||
boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; };
|
||||
const i2p::data::RouterInfo * GetRemoteRouter () const { return m_RemoteRouter; };
|
||||
void SendI2NPMessage (I2NPMessage * msg);
|
||||
|
||||
void SendPeerTest (); // Alice
|
||||
|
||||
private:
|
||||
|
||||
void CreateAESandMacKey (uint8_t * pubKey, uint8_t * aesKey, uint8_t * macKey);
|
||||
|
Loading…
x
Reference in New Issue
Block a user