|
|
@ -431,7 +431,8 @@ namespace garlic |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GarlicDestination::GarlicDestination (): m_NumTags (32), // 32 tags by default
|
|
|
|
GarlicDestination::GarlicDestination (): m_NumTags (32), // 32 tags by default
|
|
|
|
m_PayloadBuffer (nullptr), m_NumRatchetInboundTags (0) // 0 means standard
|
|
|
|
m_PayloadBuffer (nullptr), m_NumRatchetInboundTags (0), // 0 means standard
|
|
|
|
|
|
|
|
m_NumUsedECIESx25519Tags (0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -599,6 +600,7 @@ namespace garlic |
|
|
|
LogPrint (eLogError, "Garlic: Can't handle ECIES-X25519-AEAD-Ratchet message"); |
|
|
|
LogPrint (eLogError, "Garlic: Can't handle ECIES-X25519-AEAD-Ratchet message"); |
|
|
|
m_ECIESx25519Tags.erase (it); |
|
|
|
m_ECIESx25519Tags.erase (it); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_NumUsedECIESx25519Tags++; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -883,6 +885,26 @@ namespace garlic |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
numExpiredTags = 0; |
|
|
|
numExpiredTags = 0; |
|
|
|
|
|
|
|
if (m_NumUsedECIESx25519Tags > ECIESX25519_TAGSET_MAX_NUM_TAGS) // too many used tags
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::unordered_map<uint64_t, ECIESX25519AEADRatchetIndexTagset> oldTags; |
|
|
|
|
|
|
|
std::swap (m_ECIESx25519Tags, oldTags); // re-create
|
|
|
|
|
|
|
|
for (auto& it: oldTags) |
|
|
|
|
|
|
|
if (it.second.tagset) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (it.second.tagset->IsExpired (ts) || it.second.tagset->IsIndexExpired (it.second.index)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
it.second.tagset->DeleteSymmKey (it.second.index); |
|
|
|
|
|
|
|
numExpiredTags++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (it.second.tagset->IsSessionTerminated()) |
|
|
|
|
|
|
|
numExpiredTags++; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
m_ECIESx25519Tags.emplace (it); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
for (auto it = m_ECIESx25519Tags.begin (); it != m_ECIESx25519Tags.end ();) |
|
|
|
for (auto it = m_ECIESx25519Tags.begin (); it != m_ECIESx25519Tags.end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!it->second.tagset) |
|
|
|
if (!it->second.tagset) |
|
|
@ -897,10 +919,7 @@ namespace garlic |
|
|
|
it = m_ECIESx25519Tags.erase (it); |
|
|
|
it = m_ECIESx25519Tags.erase (it); |
|
|
|
numExpiredTags++; |
|
|
|
numExpiredTags++; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else if (it->second.tagset->IsSessionTerminated()) |
|
|
|
{ |
|
|
|
|
|
|
|
auto session = it->second.tagset->GetSession (); |
|
|
|
|
|
|
|
if (!session || session->IsTerminated()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
it = m_ECIESx25519Tags.erase (it); |
|
|
|
it = m_ECIESx25519Tags.erase (it); |
|
|
|
numExpiredTags++; |
|
|
|
numExpiredTags++; |
|
|
@ -909,6 +928,7 @@ namespace garlic |
|
|
|
++it; |
|
|
|
++it; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_NumUsedECIESx25519Tags = 0; |
|
|
|
if (numExpiredTags > 0) |
|
|
|
if (numExpiredTags > 0) |
|
|
|
LogPrint (eLogDebug, "Garlic: ", numExpiredTags, " ECIESx25519 tags expired for ", GetIdentHash().ToBase64 ()); |
|
|
|
LogPrint (eLogDebug, "Garlic: ", numExpiredTags, " ECIESx25519 tags expired for ", GetIdentHash().ToBase64 ()); |
|
|
|
if (m_LastTagset && m_LastTagset->IsExpired (ts)) |
|
|
|
if (m_LastTagset && m_LastTagset->IsExpired (ts)) |
|
|
|