Browse Source

use PrivateKeys for local destination

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

15
Streaming.cpp

@ -302,8 +302,7 @@ namespace stream @@ -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 @@ -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 @@ -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);

7
Streaming.h

@ -110,8 +110,8 @@ namespace stream @@ -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 @@ -130,8 +130,7 @@ namespace stream
private:
std::map<uint32_t, Stream *> 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;

Loading…
Cancel
Save