2020-05-22 13:18:41 +00:00
|
|
|
/*
|
2024-02-16 19:49:12 +00:00
|
|
|
* Copyright (c) 2013-2024, The PurpleI2P Project
|
2020-05-22 13:18:41 +00:00
|
|
|
*
|
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3
|
|
|
|
*
|
|
|
|
* See full license text in LICENSE file at top of project tree
|
|
|
|
*/
|
|
|
|
|
2013-11-23 21:35:15 +00:00
|
|
|
#ifndef GARLIC_H__
|
|
|
|
#define GARLIC_H__
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
2020-01-28 15:03:51 +00:00
|
|
|
#include <unordered_map>
|
2014-05-12 02:37:33 +00:00
|
|
|
#include <list>
|
2013-11-24 23:10:27 +00:00
|
|
|
#include <string>
|
2014-03-13 01:13:54 +00:00
|
|
|
#include <thread>
|
2014-08-25 17:07:14 +00:00
|
|
|
#include <mutex>
|
2014-10-07 01:18:20 +00:00
|
|
|
#include <memory>
|
2015-11-03 14:15:49 +00:00
|
|
|
#include "Crypto.h"
|
2013-11-23 21:35:15 +00:00
|
|
|
#include "I2NPProtocol.h"
|
2013-11-24 23:10:27 +00:00
|
|
|
#include "LeaseSet.h"
|
2014-03-13 01:13:54 +00:00
|
|
|
#include "Queue.h"
|
2014-10-06 20:49:41 +00:00
|
|
|
#include "Identity.h"
|
2013-11-23 21:35:15 +00:00
|
|
|
|
|
|
|
namespace i2p
|
2016-02-11 03:51:08 +00:00
|
|
|
{
|
|
|
|
namespace tunnel
|
2018-01-06 03:48:51 +00:00
|
|
|
{
|
2016-02-11 03:51:08 +00:00
|
|
|
class OutboundTunnel;
|
|
|
|
}
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2013-11-24 23:10:27 +00:00
|
|
|
namespace garlic
|
2013-11-23 21:35:15 +00:00
|
|
|
{
|
2018-01-06 03:48:51 +00:00
|
|
|
|
|
|
|
enum GarlicDeliveryType
|
|
|
|
{
|
|
|
|
eGarlicDeliveryTypeLocal = 0,
|
2013-11-23 21:35:15 +00:00
|
|
|
eGarlicDeliveryTypeDestination = 1,
|
2018-01-06 03:48:51 +00:00
|
|
|
eGarlicDeliveryTypeRouter = 2,
|
2013-11-23 21:35:15 +00:00
|
|
|
eGarlicDeliveryTypeTunnel = 3
|
2018-01-06 03:48:51 +00:00
|
|
|
};
|
2013-11-23 21:35:15 +00:00
|
|
|
|
|
|
|
struct ElGamalBlock
|
|
|
|
{
|
|
|
|
uint8_t sessionKey[32];
|
|
|
|
uint8_t preIV[32];
|
|
|
|
uint8_t padding[158];
|
2018-01-06 03:48:51 +00:00
|
|
|
};
|
2013-11-24 23:10:27 +00:00
|
|
|
|
2018-01-06 03:48:51 +00:00
|
|
|
const int INCOMING_TAGS_EXPIRATION_TIMEOUT = 960; // 16 minutes
|
2014-10-17 01:11:02 +00:00
|
|
|
const int OUTGOING_TAGS_EXPIRATION_TIMEOUT = 720; // 12 minutes
|
2018-01-06 03:48:51 +00:00
|
|
|
const int OUTGOING_TAGS_CONFIRMATION_TIMEOUT = 10; // 10 seconds
|
2015-03-22 18:59:27 +00:00
|
|
|
const int LEASET_CONFIRMATION_TIMEOUT = 4000; // in milliseconds
|
2018-01-06 03:48:51 +00:00
|
|
|
const int ROUTING_PATH_EXPIRATION_TIMEOUT = 30; // 30 seconds
|
|
|
|
const int ROUTING_PATH_MAX_NUM_TIMES_USED = 100; // how many times might be used
|
|
|
|
|
|
|
|
struct SessionTag: public i2p::data::Tag<32>
|
2014-10-17 15:26:57 +00:00
|
|
|
{
|
|
|
|
SessionTag (const uint8_t * buf, uint32_t ts = 0): Tag<32>(buf), creationTime (ts) {};
|
|
|
|
SessionTag () = default;
|
|
|
|
SessionTag (const SessionTag& ) = default;
|
|
|
|
SessionTag& operator= (const SessionTag& ) = default;
|
|
|
|
#ifndef _WIN32
|
2018-01-06 03:48:51 +00:00
|
|
|
SessionTag (SessionTag&& ) = default;
|
|
|
|
SessionTag& operator= (SessionTag&& ) = default;
|
2014-10-17 15:26:57 +00:00
|
|
|
#endif
|
2018-01-06 03:48:51 +00:00
|
|
|
uint32_t creationTime; // seconds since epoch
|
2014-10-17 15:26:57 +00:00
|
|
|
};
|
2016-02-11 03:51:08 +00:00
|
|
|
|
2017-04-03 19:05:10 +00:00
|
|
|
// AESDecryption is associated with session tags and store key
|
|
|
|
class AESDecryption: public i2p::crypto::CBCDecryption
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
AESDecryption (const uint8_t * key): m_Key (key)
|
|
|
|
{
|
|
|
|
SetKey (key);
|
2018-01-06 03:48:51 +00:00
|
|
|
}
|
2017-04-03 19:05:10 +00:00
|
|
|
const i2p::crypto::AESKey& GetKey () const { return m_Key; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
i2p::crypto::AESKey m_Key;
|
|
|
|
};
|
|
|
|
|
2016-02-11 03:51:08 +00:00
|
|
|
struct GarlicRoutingPath
|
|
|
|
{
|
|
|
|
std::shared_ptr<i2p::tunnel::OutboundTunnel> outboundTunnel;
|
|
|
|
std::shared_ptr<const i2p::data::Lease> remoteLease;
|
2016-02-12 03:18:44 +00:00
|
|
|
int rtt; // RTT
|
2016-02-11 03:51:08 +00:00
|
|
|
uint32_t updateTime; // seconds since epoch
|
2018-01-06 03:48:51 +00:00
|
|
|
int numTimesUsed;
|
|
|
|
};
|
2017-04-03 19:05:10 +00:00
|
|
|
|
2014-10-08 01:08:00 +00:00
|
|
|
class GarlicDestination;
|
2020-01-16 19:31:01 +00:00
|
|
|
class GarlicRoutingSession
|
2013-11-24 23:10:27 +00:00
|
|
|
{
|
2020-03-01 10:25:50 +00:00
|
|
|
protected:
|
|
|
|
|
2015-03-22 18:59:27 +00:00
|
|
|
enum LeaseSetUpdateStatus
|
|
|
|
{
|
|
|
|
eLeaseSetUpToDate = 0,
|
|
|
|
eLeaseSetUpdated,
|
2015-04-06 00:07:32 +00:00
|
|
|
eLeaseSetSubmitted,
|
|
|
|
eLeaseSetDoNotSend
|
2015-03-22 18:59:27 +00:00
|
|
|
};
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2013-11-24 23:10:27 +00:00
|
|
|
public:
|
|
|
|
|
2020-01-16 19:59:19 +00:00
|
|
|
GarlicRoutingSession (GarlicDestination * owner, bool attachLeaseSet);
|
2020-01-16 19:31:01 +00:00
|
|
|
GarlicRoutingSession ();
|
|
|
|
virtual ~GarlicRoutingSession ();
|
|
|
|
virtual std::shared_ptr<I2NPMessage> WrapSingleMessage (std::shared_ptr<const I2NPMessage> msg) = 0;
|
2020-03-01 10:25:50 +00:00
|
|
|
virtual bool CleanupUnconfirmedTags () { return false; }; // for I2CP, override in ElGamalAESSession
|
2020-03-08 22:13:41 +00:00
|
|
|
virtual bool MessageConfirmed (uint32_t msgID);
|
2020-05-02 15:13:40 +00:00
|
|
|
virtual bool IsRatchets () const { return false; };
|
2020-10-27 12:32:38 +00:00
|
|
|
virtual bool IsReadyToSend () const { return true; };
|
2021-11-27 20:30:35 +00:00
|
|
|
virtual bool IsTerminated () const { return !GetOwner (); };
|
2020-07-15 20:20:35 +00:00
|
|
|
virtual uint64_t GetLastActivityTimestamp () const { return 0; }; // non-zero for rathets only
|
2020-03-01 10:25:50 +00:00
|
|
|
|
2018-01-06 03:48:51 +00:00
|
|
|
void SetLeaseSetUpdated ()
|
|
|
|
{
|
|
|
|
if (m_LeaseSetUpdateStatus != eLeaseSetDoNotSend) m_LeaseSetUpdateStatus = eLeaseSetUpdated;
|
2015-04-06 00:07:32 +00:00
|
|
|
};
|
2016-09-07 17:25:11 +00:00
|
|
|
bool IsLeaseSetNonConfirmed () const { return m_LeaseSetUpdateStatus == eLeaseSetSubmitted; };
|
2016-10-23 00:08:15 +00:00
|
|
|
bool IsLeaseSetUpdated () const { return m_LeaseSetUpdateStatus == eLeaseSetUpdated; };
|
2018-01-06 03:48:51 +00:00
|
|
|
uint64_t GetLeaseSetSubmissionTime () const { return m_LeaseSetSubmissionTime; }
|
2020-03-14 20:35:34 +00:00
|
|
|
void CleanupUnconfirmedLeaseSet (uint64_t ts);
|
2020-03-01 10:25:50 +00:00
|
|
|
|
2016-02-11 03:51:08 +00:00
|
|
|
std::shared_ptr<GarlicRoutingPath> GetSharedRoutingPath ();
|
|
|
|
void SetSharedRoutingPath (std::shared_ptr<GarlicRoutingPath> path);
|
2016-08-27 17:17:34 +00:00
|
|
|
|
2020-01-16 19:31:01 +00:00
|
|
|
GarlicDestination * GetOwner () const { return m_Owner; }
|
2016-11-16 19:43:29 +00:00
|
|
|
void SetOwner (GarlicDestination * owner) { m_Owner = owner; }
|
2020-03-01 10:25:50 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
LeaseSetUpdateStatus GetLeaseSetUpdateStatus () const { return m_LeaseSetUpdateStatus; }
|
|
|
|
void SetLeaseSetUpdateStatus (LeaseSetUpdateStatus status) { m_LeaseSetUpdateStatus = status; }
|
|
|
|
uint32_t GetLeaseSetUpdateMsgID () const { return m_LeaseSetUpdateMsgID; }
|
|
|
|
void SetLeaseSetUpdateMsgID (uint32_t msgID) { m_LeaseSetUpdateMsgID = msgID; }
|
|
|
|
void SetLeaseSetSubmissionTime (uint64_t ts) { m_LeaseSetSubmissionTime = ts; }
|
2014-01-18 15:34:57 +00:00
|
|
|
|
2020-03-08 22:13:41 +00:00
|
|
|
std::shared_ptr<I2NPMessage> CreateEncryptedDeliveryStatusMsg (uint32_t msgID);
|
2020-03-01 10:25:50 +00:00
|
|
|
|
2013-11-24 23:10:27 +00:00
|
|
|
private:
|
|
|
|
|
2014-10-08 01:08:00 +00:00
|
|
|
GarlicDestination * m_Owner;
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2015-03-22 18:59:27 +00:00
|
|
|
LeaseSetUpdateStatus m_LeaseSetUpdateStatus;
|
|
|
|
uint32_t m_LeaseSetUpdateMsgID;
|
|
|
|
uint64_t m_LeaseSetSubmissionTime; // in milliseconds
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2016-02-11 03:51:08 +00:00
|
|
|
std::shared_ptr<GarlicRoutingPath> m_SharedRoutingPath;
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2016-01-24 03:53:19 +00:00
|
|
|
public:
|
2020-03-01 10:25:50 +00:00
|
|
|
|
2016-01-24 03:53:19 +00:00
|
|
|
// for HTTP only
|
2020-01-16 19:31:01 +00:00
|
|
|
virtual size_t GetNumOutgoingTags () const { return 0; };
|
2018-01-06 03:48:51 +00:00
|
|
|
};
|
2020-03-01 10:25:50 +00:00
|
|
|
//using GarlicRoutingSessionPtr = std::shared_ptr<GarlicRoutingSession>;
|
|
|
|
typedef std::shared_ptr<GarlicRoutingSession> GarlicRoutingSessionPtr; // TODO: replace to using after switch to 4.8
|
2020-01-16 19:31:01 +00:00
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
class ElGamalAESSession: public GarlicRoutingSession, public std::enable_shared_from_this<ElGamalAESSession>
|
|
|
|
{
|
|
|
|
struct UnconfirmedTags
|
|
|
|
{
|
|
|
|
UnconfirmedTags (int n): numTags (n), tagsCreationTime (0) { sessionTags = new SessionTag[numTags]; };
|
|
|
|
~UnconfirmedTags () { delete[] sessionTags; };
|
|
|
|
uint32_t msgID;
|
|
|
|
int numTags;
|
|
|
|
SessionTag * sessionTags;
|
|
|
|
uint32_t tagsCreationTime;
|
|
|
|
};
|
2020-01-16 19:31:01 +00:00
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
public:
|
2020-01-16 19:31:01 +00:00
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
ElGamalAESSession (GarlicDestination * owner, std::shared_ptr<const i2p::data::RoutingDestination> destination,
|
2020-01-16 19:31:01 +00:00
|
|
|
int numTags, bool attachLeaseSet);
|
|
|
|
ElGamalAESSession (const uint8_t * sessionKey, const SessionTag& sessionTag); // one time encryption
|
|
|
|
~ElGamalAESSession () {};
|
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
std::shared_ptr<I2NPMessage> WrapSingleMessage (std::shared_ptr<const I2NPMessage> msg);
|
|
|
|
|
|
|
|
bool MessageConfirmed (uint32_t msgID);
|
2020-01-16 19:31:01 +00:00
|
|
|
bool CleanupExpiredTags (); // returns true if something left
|
|
|
|
bool CleanupUnconfirmedTags (); // returns true if something has been deleted
|
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
private:
|
2020-01-16 19:31:01 +00:00
|
|
|
|
|
|
|
size_t CreateAESBlock (uint8_t * buf, std::shared_ptr<const I2NPMessage> msg);
|
|
|
|
size_t CreateGarlicPayload (uint8_t * payload, std::shared_ptr<const I2NPMessage> msg, UnconfirmedTags * newTags);
|
|
|
|
size_t CreateGarlicClove (uint8_t * buf, std::shared_ptr<const I2NPMessage> msg, bool isDestination);
|
|
|
|
size_t CreateDeliveryStatusClove (uint8_t * buf, uint32_t msgID);
|
|
|
|
|
|
|
|
void TagsConfirmed (uint32_t msgID);
|
|
|
|
UnconfirmedTags * GenerateSessionTags ();
|
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
std::shared_ptr<const i2p::data::RoutingDestination> m_Destination;
|
|
|
|
|
|
|
|
i2p::crypto::AESKey m_SessionKey;
|
2020-01-16 19:31:01 +00:00
|
|
|
std::list<SessionTag> m_SessionTags;
|
|
|
|
int m_NumTags;
|
|
|
|
std::map<uint32_t, std::unique_ptr<UnconfirmedTags> > m_UnconfirmedTagsMsgs; // msgID->tags
|
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
i2p::crypto::CBCEncryption m_Encryption;
|
|
|
|
|
|
|
|
public:
|
2020-01-16 19:31:01 +00:00
|
|
|
|
|
|
|
// for HTTP only
|
2020-03-01 10:25:50 +00:00
|
|
|
size_t GetNumOutgoingTags () const { return m_SessionTags.size (); };
|
|
|
|
};
|
|
|
|
typedef std::shared_ptr<ElGamalAESSession> ElGamalAESSessionPtr;
|
2016-01-25 18:34:04 +00:00
|
|
|
|
2020-03-01 10:25:50 +00:00
|
|
|
class ECIESX25519AEADRatchetSession;
|
|
|
|
typedef std::shared_ptr<ECIESX25519AEADRatchetSession> ECIESX25519AEADRatchetSessionPtr;
|
2021-01-04 23:20:16 +00:00
|
|
|
class ReceiveRatchetTagSet;
|
|
|
|
typedef std::shared_ptr<ReceiveRatchetTagSet> ReceiveRatchetTagSetPtr;
|
2020-04-24 19:46:02 +00:00
|
|
|
struct ECIESX25519AEADRatchetIndexTagset
|
2020-03-01 10:25:50 +00:00
|
|
|
{
|
|
|
|
int index;
|
2024-02-16 19:49:12 +00:00
|
|
|
ReceiveRatchetTagSetPtr tagset; // null if used
|
2020-02-03 21:21:07 +00:00
|
|
|
};
|
2020-01-16 20:45:22 +00:00
|
|
|
|
2014-10-07 20:18:13 +00:00
|
|
|
class GarlicDestination: public i2p::data::LocalDestination
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2017-03-11 21:48:54 +00:00
|
|
|
GarlicDestination ();
|
2014-10-07 20:18:13 +00:00
|
|
|
~GarlicDestination ();
|
|
|
|
|
2016-11-29 03:47:37 +00:00
|
|
|
void CleanUp ();
|
2018-01-06 03:48:51 +00:00
|
|
|
void SetNumTags (int numTags) { m_NumTags = numTags; };
|
2020-02-05 20:48:51 +00:00
|
|
|
int GetNumTags () const { return m_NumTags; };
|
2020-06-13 00:42:54 +00:00
|
|
|
void SetNumRatchetInboundTags (int numTags) { m_NumRatchetInboundTags = numTags; };
|
|
|
|
int GetNumRatchetInboundTags () const { return m_NumRatchetInboundTags; };
|
2018-01-06 03:48:51 +00:00
|
|
|
std::shared_ptr<GarlicRoutingSession> GetRoutingSession (std::shared_ptr<const i2p::data::RoutingDestination> destination, bool attachLeaseSet);
|
2016-02-07 22:45:11 +00:00
|
|
|
void CleanupExpiredTags ();
|
2016-01-25 18:34:04 +00:00
|
|
|
void RemoveDeliveryStatusSession (uint32_t msgID);
|
2020-11-06 02:21:46 +00:00
|
|
|
std::shared_ptr<I2NPMessage> WrapMessageForRouter (std::shared_ptr<const i2p::data::RouterInfo> router,
|
|
|
|
std::shared_ptr<I2NPMessage> msg);
|
2014-10-07 20:18:13 +00:00
|
|
|
|
|
|
|
void AddSessionKey (const uint8_t * key, const uint8_t * tag); // one tag
|
2021-07-12 23:40:40 +00:00
|
|
|
void AddECIESx25519Key (const uint8_t * key, uint64_t tag); // one tag
|
2014-12-08 20:36:00 +00:00
|
|
|
virtual bool SubmitSessionKey (const uint8_t * key, const uint8_t * tag); // from different thread
|
2022-03-28 16:15:40 +00:00
|
|
|
virtual void SubmitECIESx25519Key (const uint8_t * key, uint64_t tag); // from different thread
|
2020-03-14 13:33:48 +00:00
|
|
|
void DeliveryStatusSent (GarlicRoutingSessionPtr session, uint32_t msgID);
|
2021-01-04 23:20:16 +00:00
|
|
|
uint64_t AddECIESx25519SessionNextTag (ReceiveRatchetTagSetPtr tagset);
|
2020-01-29 17:54:26 +00:00
|
|
|
void AddECIESx25519Session (const uint8_t * staticKey, ECIESX25519AEADRatchetSessionPtr session);
|
2020-05-05 17:01:23 +00:00
|
|
|
void RemoveECIESx25519Session (const uint8_t * staticKey);
|
2020-02-03 21:21:07 +00:00
|
|
|
void HandleECIESx25519GarlicClove (const uint8_t * buf, size_t len);
|
2021-07-18 22:45:08 +00:00
|
|
|
uint8_t * GetPayloadBuffer ();
|
2021-11-27 20:30:35 +00:00
|
|
|
|
2015-06-16 14:14:14 +00:00
|
|
|
virtual void ProcessGarlicMessage (std::shared_ptr<I2NPMessage> msg);
|
2018-01-06 03:48:51 +00:00
|
|
|
virtual void ProcessDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg);
|
2014-10-08 16:11:39 +00:00
|
|
|
virtual void SetLeaseSetUpdated ();
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2016-05-25 19:10:28 +00:00
|
|
|
virtual std::shared_ptr<const i2p::data::LocalLeaseSet> GetLeaseSet () = 0; // TODO
|
2015-04-05 16:54:15 +00:00
|
|
|
virtual std::shared_ptr<i2p::tunnel::TunnelPool> GetTunnelPool () const = 0;
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2014-10-08 18:17:17 +00:00
|
|
|
protected:
|
|
|
|
|
2021-07-12 23:40:40 +00:00
|
|
|
void AddECIESx25519Key (const uint8_t * key, const uint8_t * tag); // one tag
|
2021-07-07 00:15:55 +00:00
|
|
|
bool HandleECIESx25519TagMessage (uint8_t * buf, size_t len); // return true if found
|
2020-01-07 20:20:55 +00:00
|
|
|
virtual void HandleI2NPMessage (const uint8_t * buf, size_t len) = 0; // called from clove only
|
2021-07-21 02:00:06 +00:00
|
|
|
virtual bool HandleCloveI2NPMessage (I2NPMessageType typeID, const uint8_t * payload, size_t len, uint32_t msgID) = 0;
|
2015-06-16 14:14:14 +00:00
|
|
|
void HandleGarlicMessage (std::shared_ptr<I2NPMessage> msg);
|
2020-01-06 19:37:40 +00:00
|
|
|
void HandleDeliveryStatusMessage (uint32_t msgID);
|
2017-04-03 19:05:10 +00:00
|
|
|
|
|
|
|
void SaveTags ();
|
2018-01-06 03:48:51 +00:00
|
|
|
void LoadTags ();
|
2017-04-03 19:05:10 +00:00
|
|
|
|
2014-10-07 20:18:13 +00:00
|
|
|
private:
|
|
|
|
|
2018-01-06 03:48:51 +00:00
|
|
|
void HandleAESBlock (uint8_t * buf, size_t len, std::shared_ptr<AESDecryption> decryption,
|
2015-02-05 23:53:43 +00:00
|
|
|
std::shared_ptr<i2p::tunnel::InboundTunnel> from);
|
|
|
|
void HandleGarlicPayload (uint8_t * buf, size_t len, std::shared_ptr<i2p::tunnel::InboundTunnel> from);
|
2014-10-07 20:18:13 +00:00
|
|
|
|
|
|
|
private:
|
2017-03-11 21:48:54 +00:00
|
|
|
|
2014-10-07 20:18:13 +00:00
|
|
|
// outgoing sessions
|
2016-01-24 01:52:21 +00:00
|
|
|
int m_NumTags;
|
2014-10-07 20:18:13 +00:00
|
|
|
std::mutex m_SessionsMutex;
|
2020-01-28 15:03:51 +00:00
|
|
|
std::unordered_map<i2p::data::IdentHash, ElGamalAESSessionPtr> m_Sessions;
|
2020-03-01 10:25:50 +00:00
|
|
|
std::unordered_map<i2p::data::Tag<32>, ECIESX25519AEADRatchetSessionPtr> m_ECIESx25519Sessions; // static key -> session
|
2021-07-18 22:45:08 +00:00
|
|
|
uint8_t * m_PayloadBuffer; // for ECIESX25519AEADRatchet
|
2014-10-07 20:18:13 +00:00
|
|
|
// incoming
|
2020-06-13 00:42:54 +00:00
|
|
|
int m_NumRatchetInboundTags;
|
2020-01-28 15:31:35 +00:00
|
|
|
std::unordered_map<SessionTag, std::shared_ptr<AESDecryption>, std::hash<i2p::data::Tag<32> > > m_Tags;
|
2020-03-01 10:25:50 +00:00
|
|
|
std::unordered_map<uint64_t, ECIESX25519AEADRatchetIndexTagset> m_ECIESx25519Tags; // session tag -> session
|
2021-01-04 23:20:16 +00:00
|
|
|
ReceiveRatchetTagSetPtr m_LastTagset; // tagset last message came for
|
2014-10-08 01:47:32 +00:00
|
|
|
// DeliveryStatus
|
2016-11-18 16:16:55 +00:00
|
|
|
std::mutex m_DeliveryStatusSessionsMutex;
|
2020-03-08 22:13:41 +00:00
|
|
|
std::unordered_map<uint32_t, GarlicRoutingSessionPtr> m_DeliveryStatusSessions; // msgID -> session
|
2018-01-06 03:48:51 +00:00
|
|
|
|
2016-01-24 03:53:19 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
// for HTTP only
|
2018-01-06 03:48:51 +00:00
|
|
|
size_t GetNumIncomingTags () const { return m_Tags.size (); }
|
2020-04-30 00:50:31 +00:00
|
|
|
size_t GetNumIncomingECIESx25519Tags () const { return m_ECIESx25519Tags.size (); }
|
2016-01-24 03:53:19 +00:00
|
|
|
const decltype(m_Sessions)& GetSessions () const { return m_Sessions; };
|
2020-04-30 00:50:31 +00:00
|
|
|
const decltype(m_ECIESx25519Sessions)& GetECIESx25519Sessions () const { return m_ECIESx25519Sessions; }
|
2017-04-03 19:05:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void CleanUpTagsFiles ();
|
2018-01-06 03:48:51 +00:00
|
|
|
|
|
|
|
}
|
2013-11-24 23:10:27 +00:00
|
|
|
}
|
2013-11-23 21:35:15 +00:00
|
|
|
|
|
|
|
#endif
|