mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
use i for intro key for SSU
This commit is contained in:
parent
4211c733a2
commit
ea1f2d4e26
@ -260,7 +260,7 @@ namespace data
|
||||
else if (!strcmp (key, "key"))
|
||||
{
|
||||
if (address->ssu)
|
||||
isIntroKey = (Base64ToByteStream (value, strlen (value), address->ssu->key, 32) == 32);
|
||||
isIntroKey = (Base64ToByteStream (value, strlen (value), address->i, 32) == 32);
|
||||
else
|
||||
LogPrint (eLogWarning, "RouterInfo: Unexpected field 'key' for NTCP");
|
||||
}
|
||||
@ -592,9 +592,9 @@ namespace data
|
||||
addr->ssu.reset (new SSUExt ());
|
||||
addr->ssu->mtu = mtu;
|
||||
if (key)
|
||||
memcpy (addr->ssu->key, key, 32);
|
||||
memcpy (addr->i, key, 32);
|
||||
else
|
||||
RAND_bytes (addr->ssu->key, 32);
|
||||
RAND_bytes (addr->i, 32);
|
||||
for (const auto& it: *m_Addresses) // don't insert same address twice
|
||||
if (*it == *addr) return;
|
||||
m_SupportedTransports |= addr->host.is_v6 () ? eSSUV6 : eSSUV4;
|
||||
@ -1175,7 +1175,7 @@ namespace data
|
||||
WriteString ("key", properties);
|
||||
properties << '=';
|
||||
char value[64];
|
||||
size_t l = ByteStreamToBase64 (address.ssu->key, 32, value, 64);
|
||||
size_t l = ByteStreamToBase64 (address.i, 32, value, 64);
|
||||
value[l] = 0;
|
||||
WriteString (value, properties);
|
||||
properties << ';';
|
||||
|
@ -109,7 +109,6 @@ namespace data
|
||||
struct SSUExt
|
||||
{
|
||||
int mtu;
|
||||
IntroKey key; // intro key for SSU
|
||||
std::vector<Introducer> introducers;
|
||||
};
|
||||
|
||||
@ -117,7 +116,7 @@ namespace data
|
||||
{
|
||||
TransportStyle transportStyle;
|
||||
boost::asio::ip::address host;
|
||||
Tag<32> s, i; // keys, i is first 16 bytes for NTCP2
|
||||
Tag<32> s, i; // keys, i is first 16 bytes for NTCP2 and 32 bytes intro key for SSU
|
||||
int port;
|
||||
uint64_t date;
|
||||
uint8_t caps;
|
||||
|
@ -31,7 +31,7 @@ namespace transport
|
||||
{
|
||||
// we are client
|
||||
auto address = IsV6 () ? router->GetSSUV6Address () : router->GetSSUAddress (true);
|
||||
if (address) m_IntroKey = address->ssu->key;
|
||||
if (address) m_IntroKey = address->i;
|
||||
m_Data.AdjustPacketSize (router); // mtu
|
||||
}
|
||||
else
|
||||
@ -39,7 +39,7 @@ namespace transport
|
||||
// we are server
|
||||
auto address = IsV6 () ? i2p::context.GetRouterInfo ().GetSSUV6Address () :
|
||||
i2p::context.GetRouterInfo ().GetSSUAddress (true);
|
||||
if (address) m_IntroKey = address->ssu->key;
|
||||
if (address) m_IntroKey = address->i;
|
||||
}
|
||||
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
|
||||
}
|
||||
@ -127,8 +127,8 @@ namespace transport
|
||||
LogPrint (eLogInfo, "SSU: SSU is not supported");
|
||||
return;
|
||||
}
|
||||
if (Validate (buf, len, address->ssu->key))
|
||||
Decrypt (buf, len, address->ssu->key);
|
||||
if (Validate (buf, len, address->i))
|
||||
Decrypt (buf, len, address->i);
|
||||
else
|
||||
{
|
||||
LogPrint (eLogWarning, "SSU: MAC verification failed ", len, " bytes from ", senderEndpoint);
|
||||
@ -436,7 +436,7 @@ namespace transport
|
||||
payload += 2;
|
||||
*payload = 0; // challenge
|
||||
payload++;
|
||||
memcpy (payload, (const uint8_t *)address->ssu->key, 32);
|
||||
memcpy (payload, (const uint8_t *)address->i, 32);
|
||||
payload += 32;
|
||||
htobe32buf (payload, nonce); // nonce
|
||||
|
||||
@ -1183,7 +1183,7 @@ namespace transport
|
||||
auto addr = address.is_v4 () ? i2p::context.GetRouterInfo ().GetSSUAddress (true) : // ipv4
|
||||
i2p::context.GetRouterInfo ().GetSSUV6Address ();
|
||||
if (addr)
|
||||
memcpy (payload, addr->ssu->key, 32); // intro key
|
||||
memcpy (payload, addr->i, 32); // intro key
|
||||
else
|
||||
LogPrint (eLogInfo, "SSU: SSU is not supported. Can't send peer test");
|
||||
}
|
||||
@ -1222,7 +1222,7 @@ namespace transport
|
||||
if (!nonce) nonce = 1;
|
||||
m_IsPeerTest = false;
|
||||
m_Server.NewPeerTest (nonce, ePeerTestParticipantAlice1, shared_from_this ());
|
||||
SendPeerTest (nonce, boost::asio::ip::address(), 0, address->ssu->key, false, false); // address and port always zero for Alice
|
||||
SendPeerTest (nonce, boost::asio::ip::address(), 0, address->i, false, false); // address and port always zero for Alice
|
||||
}
|
||||
|
||||
void SSUSession::SendKeepAlive ()
|
||||
|
Loading…
Reference in New Issue
Block a user