mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-19 21:25:30 +00:00
use seesion key only for SesssionDestroy message
This commit is contained in:
parent
40d5489429
commit
702b352be9
22
SSU.cpp
22
SSU.cpp
@ -58,6 +58,7 @@ namespace ssu
|
|||||||
case eSessionStateConfirmedSent:
|
case eSessionStateConfirmedSent:
|
||||||
case eSessionStateEstablished:
|
case eSessionStateEstablished:
|
||||||
// most common case
|
// most common case
|
||||||
|
ScheduleTermination ();
|
||||||
ProcessMessage (buf, len, senderEndpoint);
|
ProcessMessage (buf, len, senderEndpoint);
|
||||||
break;
|
break;
|
||||||
// establishing or testing
|
// establishing or testing
|
||||||
@ -164,12 +165,6 @@ namespace ssu
|
|||||||
case PAYLOAD_TYPE_SESSION_CREATED:
|
case PAYLOAD_TYPE_SESSION_CREATED:
|
||||||
ProcessSessionCreated (buf, len);
|
ProcessSessionCreated (buf, len);
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_SESSION_DESTROYED:
|
|
||||||
{
|
|
||||||
LogPrint ("SSU session destroy with into key received");
|
|
||||||
m_Server.DeleteSession (this); // delete this
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PAYLOAD_TYPE_PEER_TEST:
|
case PAYLOAD_TYPE_PEER_TEST:
|
||||||
LogPrint ("SSU peer test received");
|
LogPrint ("SSU peer test received");
|
||||||
// TODO:
|
// TODO:
|
||||||
@ -605,7 +600,6 @@ namespace ssu
|
|||||||
|
|
||||||
void SSUSession::ProcessData (uint8_t * buf, size_t len)
|
void SSUSession::ProcessData (uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
ScheduleTermination ();
|
|
||||||
//uint8_t * start = buf;
|
//uint8_t * start = buf;
|
||||||
uint8_t flag = *buf;
|
uint8_t flag = *buf;
|
||||||
buf++;
|
buf++;
|
||||||
@ -806,22 +800,12 @@ namespace ssu
|
|||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
rnd.GenerateBlock (iv, 16); // random iv
|
rnd.GenerateBlock (iv, 16); // random iv
|
||||||
if (m_State == eSessionStateEstablished)
|
if (m_State == eSessionStateEstablished)
|
||||||
|
{
|
||||||
// encrypt message with session key
|
// encrypt message with session key
|
||||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48, m_SessionKey, iv, m_MacKey);
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48, m_SessionKey, iv, m_MacKey);
|
||||||
else
|
|
||||||
{
|
|
||||||
auto introKey = GetIntroKey ();
|
|
||||||
if (introKey)
|
|
||||||
// encrypt message with intro key
|
|
||||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48, introKey, iv, introKey);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogPrint ("SSU: can't send SessionDestroyed message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_Server.Send (buf, 48, m_RemoteEndpoint);
|
m_Server.Send (buf, 48, m_RemoteEndpoint);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SSUSession::Send (i2p::I2NPMessage * msg)
|
void SSUSession::Send (i2p::I2NPMessage * msg)
|
||||||
{
|
{
|
||||||
|
2
SSU.h
2
SSU.h
@ -30,7 +30,7 @@ namespace ssu
|
|||||||
|
|
||||||
const size_t SSU_MTU = 1484;
|
const size_t SSU_MTU = 1484;
|
||||||
const int SSU_CONNECT_TIMEOUT = 5; // 5 seconds
|
const int SSU_CONNECT_TIMEOUT = 5; // 5 seconds
|
||||||
const int SSU_TERMINATION_TIMEOUT = 270; // 4.5 minutes
|
const int SSU_TERMINATION_TIMEOUT = 330; // 5.5 minutes
|
||||||
|
|
||||||
// payload types (4 bits)
|
// payload types (4 bits)
|
||||||
const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;
|
const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user