forked from PurpleI2P/i2pd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
238 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef LEASE_SET_H__ | ||
#define LEASE_SET_H__ | ||
|
||
#include <inttypes.h> | ||
#include <list> | ||
|
||
namespace i2p | ||
{ | ||
namespace data | ||
{ | ||
#pragma pack(1) | ||
struct Lease | ||
{ | ||
uint8_t tunnelGateway[32]; | ||
uint32_t tunnelID; | ||
uint64_t endDate; | ||
}; | ||
#pragma pack() | ||
|
||
class RoutingDestination // TODO: move to separate file later | ||
{ | ||
public: | ||
virtual const uint8_t * GetIdentHash () const = 0; | ||
virtual const uint8_t * GetEncryptionPublicKey () const = 0; | ||
}; | ||
|
||
class LeaseSet: public RoutingDestination | ||
{ | ||
public: | ||
|
||
LeaseSet (const uint8_t * buf, int len); | ||
|
||
// implements RoutingDestination | ||
const uint8_t * GetIdentHash () const { return m_IdentHash; }; | ||
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionKey; }; | ||
|
||
private: | ||
|
||
std::list<Lease> m_Leases; | ||
uint8_t m_IdentHash[32]; | ||
uint8_t m_EncryptionKey[256]; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters