Browse Source

moved encryption keys from TunnelPool to StreamingDestination

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

2
Identity.h

@ -119,6 +119,8 @@ namespace data @@ -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
};
}

4
RouterContext.h

@ -32,7 +32,9 @@ namespace i2p @@ -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 ();

5
Streaming.cpp

@ -1,5 +1,6 @@ @@ -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 @@ -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 @@ -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);
}

5
Streaming.h

@ -139,6 +139,8 @@ namespace stream @@ -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 @@ -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;

4
TunnelPool.cpp

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
#include <cryptopp/dh.h>
#include "I2PEndian.h"
#include "CryptoConst.h"
#include "Tunnel.h"
@ -15,9 +14,6 @@ namespace tunnel @@ -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 ()

5
TunnelPool.h

@ -25,8 +25,8 @@ namespace tunnel @@ -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 @@ -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…
Cancel
Save