|
|
@ -125,14 +125,16 @@ namespace transport |
|
|
|
m_NoiseState->MixKey (sharedSecret); |
|
|
|
m_NoiseState->MixKey (sharedSecret); |
|
|
|
// decrypt
|
|
|
|
// decrypt
|
|
|
|
uint8_t * payload = buf + 64; |
|
|
|
uint8_t * payload = buf + 64; |
|
|
|
m_NoiseState->MixHash (payload, 24); // h = SHA256(h || 24 byte encrypted payload from Session Request) for SessionCreated
|
|
|
|
std::vector<uint8_t> decryptedPayload(len - 80); |
|
|
|
if (!i2p::crypto::AEADChaCha20Poly1305 (payload, len - 80, m_NoiseState->m_H, 32, m_NoiseState->m_CK + 32, nonce, payload, len - 80, false)) |
|
|
|
if (!i2p::crypto::AEADChaCha20Poly1305 (payload, len - 80, m_NoiseState->m_H, 32, |
|
|
|
|
|
|
|
m_NoiseState->m_CK + 32, nonce, decryptedPayload.data (), decryptedPayload.size (), false)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "SSU2: SessionRequest AEAD verification failed "); |
|
|
|
LogPrint (eLogWarning, "SSU2: SessionRequest AEAD verification failed "); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_NoiseState->MixHash (payload, 24); // h = SHA256(h || 24 byte encrypted payload from Session Request) for SessionCreated
|
|
|
|
// payload
|
|
|
|
// payload
|
|
|
|
HandlePayload (payload, len - 80); |
|
|
|
HandlePayload (decryptedPayload.data (), decryptedPayload.size ()); |
|
|
|
|
|
|
|
|
|
|
|
m_Server.AddSession (m_SourceConnID, shared_from_this ()); |
|
|
|
m_Server.AddSession (m_SourceConnID, shared_from_this ()); |
|
|
|
SendSessionCreated (headerX + 16); |
|
|
|
SendSessionCreated (headerX + 16); |
|
|
@ -497,6 +499,9 @@ namespace transport |
|
|
|
boost::asio::buffer (payload, payloadLen) |
|
|
|
boost::asio::buffer (payload, payloadLen) |
|
|
|
}; |
|
|
|
}; |
|
|
|
boost::system::error_code ec; |
|
|
|
boost::system::error_code ec; |
|
|
|
|
|
|
|
if (to.address ().is_v6 ()) |
|
|
|
|
|
|
|
m_SocketV6.send_to (bufs, to, 0, ec); |
|
|
|
|
|
|
|
else |
|
|
|
m_Socket.send_to (bufs, to, 0, ec); |
|
|
|
m_Socket.send_to (bufs, to, 0, ec); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|