Browse Source

use PrivateKeys for local destination

pull/48/head
orignal 10 years ago
parent
commit
a34d1de10e
  1. 15
      Streaming.cpp
  2. 7
      Streaming.h

15
Streaming.cpp

@ -302,8 +302,7 @@ namespace stream
StreamingDestination::StreamingDestination (): m_LeaseSet (nullptr) StreamingDestination::StreamingDestination (): m_LeaseSet (nullptr)
{ {
m_Keys = i2p::data::CreateRandomKeys (); m_Keys = i2p::data::CreateRandomKeys ();
m_Identity = m_Keys; m_IdentHash = i2p::data::CalculateIdentHash (m_Keys.pub);
m_IdentHash = i2p::data::CalculateIdentHash (m_Identity);
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));
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this); m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this);
@ -313,13 +312,7 @@ namespace stream
{ {
std::ifstream s(fullPath.c_str (), std::ifstream::binary); std::ifstream s(fullPath.c_str (), std::ifstream::binary);
if (s.is_open ()) if (s.is_open ())
{ s.read ((char *)&m_Keys, sizeof (m_Keys));
i2p::data::PrivateKeys keys;
s.read ((char *)&keys, sizeof (keys));
// TODO: use PrivateKeys
m_Identity = keys.pub;
memcpy (m_Keys.privateKey, keys.privateKey, 276);
}
else else
LogPrint ("Can't open file ", fullPath); LogPrint ("Can't open file ", fullPath);
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this); m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this);
@ -391,8 +384,8 @@ namespace stream
uint8_t * buf = m->GetPayload () + sizeof (I2NPDatabaseStoreMsg); uint8_t * buf = m->GetPayload () + sizeof (I2NPDatabaseStoreMsg);
size_t size = 0; size_t size = 0;
memcpy (buf + size, &m_Identity, sizeof (m_Identity)); memcpy (buf + size, &m_Keys.pub, sizeof (m_Keys.pub));
size += sizeof (m_Identity); // destination size += sizeof (m_Keys.pub); // destination
memcpy (buf + size, m_Pool->GetEncryptionPublicKey (), 256); memcpy (buf + size, m_Pool->GetEncryptionPublicKey (), 256);
size += 256; // encryption key size += 256; // encryption key
memset (buf + size, 0, 128); memset (buf + size, 0, 128);

7
Streaming.h

@ -110,8 +110,8 @@ namespace stream
StreamingDestination (const std::string& fullPath); StreamingDestination (const std::string& fullPath);
~StreamingDestination (); ~StreamingDestination ();
const i2p::data::Keys& GetKeys () const { return m_Keys; }; const i2p::data::PrivateKeys& GetKeys () const { return m_Keys; };
const i2p::data::Identity& GetIdentity () const { return m_Identity; }; const i2p::data::Identity& GetIdentity () const { return m_Keys.pub; };
I2NPMessage * GetLeaseSet (); I2NPMessage * GetLeaseSet ();
i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; }; i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; };
void Sign (uint8_t * buf, int len, uint8_t * signature) const; void Sign (uint8_t * buf, int len, uint8_t * signature) const;
@ -130,8 +130,7 @@ namespace stream
private: private:
std::map<uint32_t, Stream *> m_Streams; std::map<uint32_t, Stream *> m_Streams;
i2p::data::Keys m_Keys; i2p::data::PrivateKeys m_Keys;
i2p::data::Identity m_Identity;
i2p::data::IdentHash m_IdentHash; i2p::data::IdentHash m_IdentHash;
i2p::tunnel::TunnelPool * m_Pool; i2p::tunnel::TunnelPool * m_Pool;

Loading…
Cancel
Save