From 702b352be9a64560481989391ae6d180c3335e8b Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 8 Apr 2014 13:25:19 -0400 Subject: [PATCH] use seesion key only for SesssionDestroy message --- SSU.cpp | 22 +++------------------- SSU.h | 2 +- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/SSU.cpp b/SSU.cpp index 1d1581a0..7d21c8ca 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -58,6 +58,7 @@ namespace ssu case eSessionStateConfirmedSent: case eSessionStateEstablished: // most common case + ScheduleTermination (); ProcessMessage (buf, len, senderEndpoint); break; // establishing or testing @@ -164,12 +165,6 @@ namespace ssu case PAYLOAD_TYPE_SESSION_CREATED: ProcessSessionCreated (buf, len); 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: LogPrint ("SSU peer test received"); // TODO: @@ -605,7 +600,6 @@ namespace ssu void SSUSession::ProcessData (uint8_t * buf, size_t len) { - ScheduleTermination (); //uint8_t * start = buf; uint8_t flag = *buf; buf++; @@ -806,21 +800,11 @@ namespace ssu CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); rnd.GenerateBlock (iv, 16); // random iv if (m_State == eSessionStateEstablished) + { // encrypt message with session key 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) diff --git a/SSU.h b/SSU.h index 196da273..e680c7f1 100644 --- a/SSU.h +++ b/SSU.h @@ -30,7 +30,7 @@ namespace ssu const size_t SSU_MTU = 1484; 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) const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;