mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
Garlic session per destination
This commit is contained in:
parent
e0e5e8ad36
commit
7f92a847c2
5 changed files with 238 additions and 33 deletions
53
Garlic.h
53
Garlic.h
|
@ -2,10 +2,19 @@
|
|||
#define GARLIC_H__
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <cryptopp/modes.h>
|
||||
#include <cryptopp/aes.h>
|
||||
#include <cryptopp/osrng.h>
|
||||
#include "I2NPProtocol.h"
|
||||
#include "LeaseSet.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace garlic
|
||||
{
|
||||
|
||||
enum GarlicDeliveryType
|
||||
{
|
||||
eGarlicDeliveryTypeLocal = 0,
|
||||
|
@ -22,9 +31,49 @@ namespace i2p
|
|||
uint8_t padding[158];
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
|
||||
I2NPMessage * WrapI2NPMessage (const uint8_t * encryptionKey, I2NPMessage * msg);
|
||||
size_t CreateGarlicPayload (uint8_t * payload, I2NPMessage * msg);
|
||||
class GarlicRoutingSession
|
||||
{
|
||||
public:
|
||||
|
||||
GarlicRoutingSession (const i2p::data::RoutingDestination * destination, int numTags);
|
||||
~GarlicRoutingSession ();
|
||||
I2NPMessage * WrapSingleMessage (I2NPMessage * msg);
|
||||
int GetNumRemainingSessionTags () const { return m_NumTags - m_NextTag; };
|
||||
|
||||
private:
|
||||
|
||||
size_t CreateAESBlock (uint8_t * buf, I2NPMessage * msg);
|
||||
size_t CreateGarlicPayload (uint8_t * payload, I2NPMessage * msg);
|
||||
|
||||
private:
|
||||
|
||||
const i2p::data::RoutingDestination * m_Destination;
|
||||
uint8_t m_SessionKey[32];
|
||||
int m_NumTags, m_NextTag;
|
||||
uint8_t * m_SessionTags; // m_NumTags*32 bytes
|
||||
|
||||
CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption m_Encryption;
|
||||
CryptoPP::AutoSeededRandomPool m_Rnd;
|
||||
};
|
||||
|
||||
class GarlicRouting
|
||||
{
|
||||
public:
|
||||
|
||||
GarlicRouting ();
|
||||
~GarlicRouting ();
|
||||
|
||||
I2NPMessage * WrapSingleMessage (const i2p::data::RoutingDestination * destination, I2NPMessage * msg);
|
||||
|
||||
private:
|
||||
|
||||
std::map<std::string, GarlicRoutingSession *> m_Sessions;
|
||||
};
|
||||
|
||||
extern GarlicRouting routing;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue