From a34d1de10e1137f4831c1c6415ee36d83196378a Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 19 Mar 2014 22:03:50 -0400 Subject: [PATCH] use PrivateKeys for local destination --- Streaming.cpp | 15 ++++----------- Streaming.h | 7 +++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Streaming.cpp b/Streaming.cpp index eedef81e..305b8832 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -302,8 +302,7 @@ namespace stream StreamingDestination::StreamingDestination (): m_LeaseSet (nullptr) { m_Keys = i2p::data::CreateRandomKeys (); - m_Identity = m_Keys; - m_IdentHash = i2p::data::CalculateIdentHash (m_Identity); + 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)); m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this); @@ -313,13 +312,7 @@ namespace stream { std::ifstream s(fullPath.c_str (), std::ifstream::binary); if (s.is_open ()) - { - i2p::data::PrivateKeys keys; - s.read ((char *)&keys, sizeof (keys)); - // TODO: use PrivateKeys - m_Identity = keys.pub; - memcpy (m_Keys.privateKey, keys.privateKey, 276); - } + s.read ((char *)&m_Keys, sizeof (m_Keys)); else LogPrint ("Can't open file ", fullPath); m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this); @@ -391,8 +384,8 @@ namespace stream uint8_t * buf = m->GetPayload () + sizeof (I2NPDatabaseStoreMsg); size_t size = 0; - memcpy (buf + size, &m_Identity, sizeof (m_Identity)); - size += sizeof (m_Identity); // destination + memcpy (buf + size, &m_Keys.pub, sizeof (m_Keys.pub)); + size += sizeof (m_Keys.pub); // destination memcpy (buf + size, m_Pool->GetEncryptionPublicKey (), 256); size += 256; // encryption key memset (buf + size, 0, 128); diff --git a/Streaming.h b/Streaming.h index 36140d0b..18ca01f9 100644 --- a/Streaming.h +++ b/Streaming.h @@ -110,8 +110,8 @@ namespace stream StreamingDestination (const std::string& fullPath); ~StreamingDestination (); - const i2p::data::Keys& GetKeys () const { return m_Keys; }; - const i2p::data::Identity& GetIdentity () const { return m_Identity; }; + const i2p::data::PrivateKeys& GetKeys () const { return m_Keys; }; + const i2p::data::Identity& GetIdentity () const { return m_Keys.pub; }; I2NPMessage * GetLeaseSet (); i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; }; void Sign (uint8_t * buf, int len, uint8_t * signature) const; @@ -130,8 +130,7 @@ namespace stream private: std::map m_Streams; - i2p::data::Keys m_Keys; - i2p::data::Identity m_Identity; + i2p::data::PrivateKeys m_Keys; i2p::data::IdentHash m_IdentHash; i2p::tunnel::TunnelPool * m_Pool;