Browse Source

don't save received IV

pull/93/head
orignal 10 years ago
parent
commit
6dbf8d1457
  1. 4
      SSU.cpp
  2. 2
      SSU.h
  3. 28
      SSUData.cpp

4
SSU.cpp

@ -87,10 +87,6 @@ namespace ssu
{ {
if (m_State == eSessionStateEstablished) if (m_State == eSessionStateEstablished)
ScheduleTermination (); ScheduleTermination ();
/* // check for duplicate
const uint8_t * iv = ((SSUHeader *)buf)->iv;
if (m_ReceivedIVs.count (iv)) return; // duplicate detected
m_ReceivedIVs.insert (iv);*/
if (m_IsSessionKey && Validate (buf, len, m_MacKey)) // try session key first if (m_IsSessionKey && Validate (buf, len, m_MacKey)) // try session key first
DecryptSessionKey (buf, len); DecryptSessionKey (buf, len);

2
SSU.h

@ -116,7 +116,6 @@ namespace ssu
private: private:
typedef i2p::data::Tag<16> IV;
friend class SSUData; // TODO: change in later friend class SSUData; // TODO: change in later
SSUServer& m_Server; SSUServer& m_Server;
boost::asio::ip::udp::endpoint m_RemoteEndpoint; boost::asio::ip::udp::endpoint m_RemoteEndpoint;
@ -132,7 +131,6 @@ namespace ssu
i2p::crypto::CBCDecryption m_SessionKeyDecryption; i2p::crypto::CBCDecryption m_SessionKeyDecryption;
uint8_t m_SessionKey[32], m_MacKey[32]; uint8_t m_SessionKey[32], m_MacKey[32];
std::list<i2p::I2NPMessage *> m_DelayedMessages; std::list<i2p::I2NPMessage *> m_DelayedMessages;
std::set<IV> m_ReceivedIVs;
SSUData m_Data; SSUData m_Data;
size_t m_NumSentBytes, m_NumReceivedBytes; size_t m_NumSentBytes, m_NumReceivedBytes;
}; };

28
SSUData.cpp

@ -354,32 +354,18 @@ namespace ssu
if (ecode != boost::asio::error::operation_aborted) if (ecode != boost::asio::error::operation_aborted)
{ {
uint32_t ts = i2p::util::GetSecondsSinceEpoch (); uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
for (auto it = m_SentMessages.begin (); it != m_SentMessages.end ();) for (auto it : m_SentMessages)
{ {
if (ts >= it->second->nextResendTime) if (ts >= it.second->nextResendTime && it.second->numResends < MAX_NUM_RESENDS)
{ {
bool isEmpty = true; for (auto f: it.second->fragments)
for (auto f: it->second->fragments) if (f) m_Session.Send (f->buf, f->len); // resend
if (f)
{
isEmpty = false;
m_Session.Send (f->buf, f->len); // resend
}
it->second->numResends++; it.second->numResends++;
if (isEmpty || it->second->numResends >= MAX_NUM_RESENDS) it.second->nextResendTime += it.second->numResends*RESEND_INTERVAL;
{
delete it->second;
it = m_SentMessages.erase (it);
}
else
it++;
} }
else
it++;
} }
if (!m_SentMessages.empty ()) ScheduleResend ();
ScheduleResend ();
} }
} }
} }

Loading…
Cancel
Save