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