fallback to non-PQ crypto if MTU is too small

This commit is contained in:
orignal
2026-03-14 19:56:18 -04:00
parent 6df4138178
commit 1a237d3ff9
2 changed files with 18 additions and 1 deletions

View File

@@ -3407,5 +3407,21 @@ namespace transport
{
return m_RemoteEndpoint.address ().is_v4 () ? i2p::data::RouterInfo::eSSU2V4 : i2p::data::RouterInfo::eSSU2V6;
}
void SSU2Session::SetVersion (uint8_t version)
{
switch (version)
{
case 3:
m_Version = 3;
break;
case 4:
m_Version = (m_MaxPayloadSize >= SSU2_MLKEM768_MIN_PAYLOAD_SIZE) ? 4: 2;
break;
default:
m_Version = 2;
}
m_Version = (version >= 2 && version <= 4) ? version : 2;
}
}
}

View File

@@ -38,6 +38,7 @@ namespace transport
const int SSU2_PEER_TEST_EXPIRATION_TIMEOUT = 60; // 60 seconds
const size_t SSU2_MAX_PACKET_SIZE = 1500;
const size_t SSU2_MIN_PACKET_SIZE = 1280;
const size_t SSU2_MLKEM768_MIN_PAYLOAD_SIZE = 1258;
const int SSU2_HANDSHAKE_RESEND_INTERVAL = 1000; // in milliseconds
const int SSU2_MAX_NUM_RESENDS = 5;
const int SSU2_RESEND_ATTEMPT_MIN_INTERVAL = 3; // in milliseconds
@@ -247,7 +248,7 @@ namespace transport
std::shared_ptr<const i2p::data::RouterInfo::Address> addr = nullptr);
virtual ~SSU2Session ();
void SetVersion (uint8_t version) { m_Version = (version >= 2 && version <= 4) ? version : 2; };
void SetVersion (uint8_t version);
void SetRemoteEndpoint (const boost::asio::ip::udp::endpoint& ep) { m_RemoteEndpoint = ep; };
const boost::asio::ip::udp::endpoint& GetRemoteEndpoint () const { return m_RemoteEndpoint; };
i2p::data::RouterInfo::CompatibleTransports GetRemoteTransports () const { return m_RemoteTransports; };