Browse Source

moved encryption keys from TunnelPool to StreamingDestination

pull/51/head
orignal 11 years ago
parent
commit
c600be59b1
  1. 2
      Identity.h
  2. 2
      RouterContext.h
  3. 5
      Streaming.cpp
  4. 3
      Streaming.h
  5. 4
      TunnelPool.cpp
  6. 5
      TunnelPool.h

2
Identity.h

@ -119,6 +119,8 @@ namespace data
public: public:
virtual const IdentHash& GetIdentHash () const = 0; 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 virtual void UpdateLeaseSet () = 0; // LeaseSet must be updated
}; };
} }

2
RouterContext.h

@ -32,6 +32,8 @@ namespace i2p
// implements LocalDestination // implements LocalDestination
void UpdateLeaseSet () {}; void UpdateLeaseSet () {};
const i2p::data::IdentHash& GetIdentHash () const { return m_RouterInfo.GetIdentHash (); }; 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: private:

5
Streaming.cpp

@ -1,5 +1,6 @@
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
#include <cryptopp/dh.h>
#include <cryptopp/gzip.h> #include <cryptopp/gzip.h>
#include "Log.h" #include "Log.h"
#include "RouterInfo.h" #include "RouterInfo.h"
@ -347,6 +348,8 @@ namespace stream
m_IdentHash = i2p::data::CalculateIdentHash (m_Keys.pub); m_IdentHash = i2p::data::CalculateIdentHash (m_Keys.pub);
m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag, m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag,
CryptoPP::Integer (m_Keys.signingPrivateKey, 20)); 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); m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (*this);
} }
@ -357,6 +360,8 @@ namespace stream
s.read ((char *)&m_Keys, sizeof (m_Keys)); s.read ((char *)&m_Keys, sizeof (m_Keys));
else else
LogPrint ("Can't open file ", fullPath); 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); m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (*this);
} }

3
Streaming.h

@ -139,6 +139,8 @@ namespace stream
// implements LocalDestination // implements LocalDestination
void UpdateLeaseSet (); void UpdateLeaseSet ();
const i2p::data::IdentHash& GetIdentHash () const { return m_IdentHash; }; 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: private:
@ -149,6 +151,7 @@ namespace stream
std::map<uint32_t, Stream *> m_Streams; std::map<uint32_t, Stream *> m_Streams;
i2p::data::PrivateKeys m_Keys; i2p::data::PrivateKeys m_Keys;
i2p::data::IdentHash m_IdentHash; i2p::data::IdentHash m_IdentHash;
uint8_t m_EncryptionPublicKey[256], m_EncryptionPrivateKey[256];
i2p::tunnel::TunnelPool * m_Pool; i2p::tunnel::TunnelPool * m_Pool;
I2NPMessage * m_LeaseSet; I2NPMessage * m_LeaseSet;

4
TunnelPool.cpp

@ -1,4 +1,3 @@
#include <cryptopp/dh.h>
#include "I2PEndian.h" #include "I2PEndian.h"
#include "CryptoConst.h" #include "CryptoConst.h"
#include "Tunnel.h" #include "Tunnel.h"
@ -15,9 +14,6 @@ namespace tunnel
TunnelPool::TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels): TunnelPool::TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels):
m_LocalDestination (localDestination), m_NumTunnels (numTunnels), m_LastOutboundTunnel (nullptr) 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 () TunnelPool::~TunnelPool ()

5
TunnelPool.h

@ -25,8 +25,8 @@ namespace tunnel
TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels = 5); TunnelPool (i2p::data::LocalDestination& localDestination, int numTunnels = 5);
~TunnelPool (); ~TunnelPool ();
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; }; const uint8_t * GetEncryptionPrivateKey () const { return m_LocalDestination.GetEncryptionPrivateKey (); };
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionPublicKey; }; const uint8_t * GetEncryptionPublicKey () const { return m_LocalDestination.GetEncryptionPublicKey (); };
void CreateTunnels (); void CreateTunnels ();
void TunnelCreated (InboundTunnel * createdTunnel); void TunnelCreated (InboundTunnel * createdTunnel);
@ -47,7 +47,6 @@ namespace tunnel
private: private:
uint8_t m_EncryptionPublicKey[256], m_EncryptionPrivateKey[256];
i2p::data::LocalDestination& m_LocalDestination; i2p::data::LocalDestination& m_LocalDestination;
int m_NumTunnels; int m_NumTunnels;
std::set<InboundTunnel *, TunnelCreationTimeCmp> m_InboundTunnels; // recent tunnel appears first std::set<InboundTunnel *, TunnelCreationTimeCmp> m_InboundTunnels; // recent tunnel appears first

Loading…
Cancel
Save