|
|
@ -1,5 +1,5 @@ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2013-2021, The PurpleI2P Project |
|
|
|
* Copyright (c) 2013-2022, The PurpleI2P Project |
|
|
|
* |
|
|
|
* |
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3 |
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3 |
|
|
|
* |
|
|
|
* |
|
|
@ -195,8 +195,9 @@ namespace transport |
|
|
|
MixHash (m3p2, m3p2Len); //h = SHA256(h || ciphertext)
|
|
|
|
MixHash (m3p2, m3p2Len); //h = SHA256(h || ciphertext)
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool NTCP2Establisher::ProcessSessionRequestMessage (uint16_t& paddingLen) |
|
|
|
bool NTCP2Establisher::ProcessSessionRequestMessage (uint16_t& paddingLen, bool& clockSkew) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
clockSkew = false; |
|
|
|
// decrypt X
|
|
|
|
// decrypt X
|
|
|
|
i2p::crypto::CBCDecryption decryption; |
|
|
|
i2p::crypto::CBCDecryption decryption; |
|
|
|
decryption.SetKey (i2p::context.GetIdentHash ()); |
|
|
|
decryption.SetKey (i2p::context.GetIdentHash ()); |
|
|
@ -232,7 +233,8 @@ namespace transport |
|
|
|
if (tsA < ts - NTCP2_CLOCK_SKEW || tsA > ts + NTCP2_CLOCK_SKEW) |
|
|
|
if (tsA < ts - NTCP2_CLOCK_SKEW || tsA > ts + NTCP2_CLOCK_SKEW) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "NTCP2: SessionRequest time difference ", (int)(ts - tsA), " exceeds clock skew"); |
|
|
|
LogPrint (eLogWarning, "NTCP2: SessionRequest time difference ", (int)(ts - tsA), " exceeds clock skew"); |
|
|
|
return false; |
|
|
|
clockSkew = true; |
|
|
|
|
|
|
|
// we send SessionCreate to let Alice know our time and then close session
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -476,9 +478,16 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogDebug, "NTCP2: SessionRequest received ", bytes_transferred); |
|
|
|
LogPrint (eLogDebug, "NTCP2: SessionRequest received ", bytes_transferred); |
|
|
|
uint16_t paddingLen = 0; |
|
|
|
uint16_t paddingLen = 0; |
|
|
|
if (m_Establisher->ProcessSessionRequestMessage (paddingLen)) |
|
|
|
bool clockSkew = false; |
|
|
|
|
|
|
|
if (m_Establisher->ProcessSessionRequestMessage (paddingLen, clockSkew)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (paddingLen > 0) |
|
|
|
if (clockSkew) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// we don't care about padding, send SessionCreated and close session
|
|
|
|
|
|
|
|
SendSessionCreated (); |
|
|
|
|
|
|
|
m_Server.GetService ().post (std::bind (&NTCP2Session::Terminate, shared_from_this ())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (paddingLen > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (paddingLen <= NTCP2_SESSION_REQUEST_MAX_SIZE - 64) // session request is 287 bytes max
|
|
|
|
if (paddingLen <= NTCP2_SESSION_REQUEST_MAX_SIZE - 64) // session request is 287 bytes max
|
|
|
|
{ |
|
|
|
{ |
|
|
@ -891,7 +900,7 @@ namespace transport |
|
|
|
case eNTCP2BlkTermination: |
|
|
|
case eNTCP2BlkTermination: |
|
|
|
if (size >= 9) |
|
|
|
if (size >= 9) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogDebug, "NTCP2: Rermination. reason=", (int)(frame[offset + 8])); |
|
|
|
LogPrint (eLogDebug, "NTCP2: Termination. reason=", (int)(frame[offset + 8])); |
|
|
|
Terminate (); |
|
|
|
Terminate (); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|