mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
moved encryption keys from TunnelPool to StreamingDestination
This commit is contained in:
parent
9f0c0b3b35
commit
c600be59b1
|
@ -119,6 +119,8 @@ namespace data
|
|||
public:
|
||||
|
||||
virtual const IdentHash& GetIdentHash () const = 0;
|
||||
virtual const uint8_t * GetEncryptionPrivateKey () const = 0;
|
||||
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
|
||||
virtual void UpdateLeaseSet () = 0; // LeaseSet must be updated
|
||||
};
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@ namespace i2p
|
|||
// implements LocalDestination
|
||||
void UpdateLeaseSet () {};
|
||||
const i2p::data::IdentHash& GetIdentHash () const { return m_RouterInfo.GetIdentHash (); };
|
||||
|
||||
const uint8_t * GetEncryptionPrivateKey () const { return GetPrivateKey (); };
|
||||
const uint8_t * GetEncryptionPublicKey () const { return m_Keys.publicKey; };
|
||||
|
||||
private:
|
||||
|
||||
void CreateNewRouter ();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <cryptopp/dh.h>
|
||||
#include <cryptopp/gzip.h>
|
||||
#include "Log.h"
|
||||
#include "RouterInfo.h"
|
||||
|
@ -347,6 +348,8 @@ namespace stream
|
|||
m_IdentHash = i2p::data::CalculateIdentHash (m_Keys.pub);
|
||||
m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag,
|
||||
CryptoPP::Integer (m_Keys.signingPrivateKey, 20));
|
||||
CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
|
||||
dh.GenerateKeyPair(i2p::context.GetRandomNumberGenerator (), m_EncryptionPrivateKey, m_EncryptionPublicKey);
|
||||
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (*this);
|
||||
}
|
||||
|
||||
|
@ -357,6 +360,8 @@ namespace stream
|
|||
s.read ((char *)&m_Keys, sizeof (m_Keys));
|
||||
else
|
||||
LogPrint ("Can't open file ", fullPath);
|
||||
CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
|
||||
dh.GenerateKeyPair(i2p::context.GetRandomNumberGenerator (), m_EncryptionPrivateKey, m_EncryptionPublicKey);
|
||||
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (*this);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,8 @@ namespace stream
|
|||
// implements LocalDestination
|
||||
void UpdateLeaseSet ();
|
||||
const i2p::data::IdentHash& GetIdentHash () const { return m_IdentHash; };
|
||||
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
|
||||
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionPublicKey; };
|
||||
|
||||
private:
|
||||
|
||||
|
@ -149,7 +151,8 @@ namespace stream
|
|||
std::map<uint32_t, Stream *> m_Streams;
|
||||
i2p::data::PrivateKeys m_Keys;
|
||||
i2p::data::IdentHash m_IdentHash;
|
||||
|
||||
uint8_t m_EncryptionPublicKey[256], m_EncryptionPrivateKey[256];
|
||||
|
||||
i2p::tunnel::TunnelPool * m_Pool;
|
||||
I2NPMessage * m_LeaseSet;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <cryptopp/dh.h>
|
||||
#include "I2PEndian.h"
|
||||
#include "CryptoConst.h"
|
||||
#include "Tunnel.h"
|
||||
|
@ -15,9 +14,6 @@ namespace tunnel
|
|||
TunnelPool::TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels):
|
||||
m_LocalDestination (localDestination), m_NumTunnels (numTunnels), m_LastOutboundTunnel (nullptr)
|
||||
{
|
||||
CryptoPP::AutoSeededRandomPool rnd;
|
||||
CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
|
||||
dh.GenerateKeyPair(i2p::context.GetRandomNumberGenerator (), m_EncryptionPrivateKey, m_EncryptionPublicKey);
|
||||
}
|
||||
|
||||
TunnelPool::~TunnelPool ()
|
||||
|
|
|
@ -25,8 +25,8 @@ namespace tunnel
|
|||
TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels = 5);
|
||||
~TunnelPool ();
|
||||
|
||||
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
|
||||
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionPublicKey; };
|
||||
const uint8_t * GetEncryptionPrivateKey () const { return m_LocalDestination.GetEncryptionPrivateKey (); };
|
||||
const uint8_t * GetEncryptionPublicKey () const { return m_LocalDestination.GetEncryptionPublicKey (); };
|
||||
|
||||
void CreateTunnels ();
|
||||
void TunnelCreated (InboundTunnel * createdTunnel);
|
||||
|
@ -47,7 +47,6 @@ namespace tunnel
|
|||
|
||||
private:
|
||||
|
||||
uint8_t m_EncryptionPublicKey[256], m_EncryptionPrivateKey[256];
|
||||
i2p::data::LocalDestination& m_LocalDestination;
|
||||
int m_NumTunnels;
|
||||
std::set<InboundTunnel *, TunnelCreationTimeCmp> m_InboundTunnels; // recent tunnel appears first
|
||||
|
|
Loading…
Reference in a new issue