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
33
LeaseSet.cpp
Normal file
33
LeaseSet.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <cryptopp/sha.h>
|
||||
#include "Log.h"
|
||||
#include "RouterInfo.h"
|
||||
#include "LeaseSet.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
LeaseSet::LeaseSet (const uint8_t * buf, int len)
|
||||
{
|
||||
#pragma pack(1)
|
||||
struct H
|
||||
{
|
||||
RouterIdentity destination;
|
||||
uint8_t encryptionKey[256];
|
||||
uint8_t signingKey[128];
|
||||
uint8_t num;
|
||||
};
|
||||
#pragma pack ()
|
||||
|
||||
const H * header = (const H *)buf;
|
||||
CryptoPP::SHA256().CalculateDigest(m_IdentHash, (uint8_t *)&header->destination, sizeof (RouterIdentity));
|
||||
memcpy (m_EncryptionKey, header->encryptionKey, 256);
|
||||
LogPrint ("LeaseSet num=", (int)header->num);
|
||||
|
||||
for (int i = 0; i < header->num; i++)
|
||||
{
|
||||
m_Leases.push_back (*(Lease *)(buf + sizeof (H)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue