mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
copy constructor for PrivateKeys
This commit is contained in:
parent
4fef0dd1cb
commit
4f429b3e06
16
Identity.cpp
16
Identity.cpp
@ -22,14 +22,14 @@ namespace data
|
||||
|
||||
bool Identity::FromBase64 (const std::string& s)
|
||||
{
|
||||
size_t count = Base64ToByteStream (s.c_str(), s.length(), reinterpret_cast<uint8_t*> (this), sizeof (Identity));
|
||||
size_t count = Base64ToByteStream (s.c_str(), s.length(), publicKey, sizeof (Identity));
|
||||
return count == sizeof(Identity);
|
||||
}
|
||||
|
||||
IdentHash Identity::Hash()
|
||||
IdentHash Identity::Hash() const
|
||||
{
|
||||
IdentHash hash;
|
||||
CryptoPP::SHA256().CalculateDigest(reinterpret_cast<uint8_t*>(&hash), reinterpret_cast<uint8_t*> (this), sizeof (Identity));
|
||||
CryptoPP::SHA256().CalculateDigest(hash, publicKey, sizeof (Identity));
|
||||
return hash;
|
||||
}
|
||||
|
||||
@ -40,11 +40,11 @@ namespace data
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool IdentHash::FromBase32(const std::string& s)
|
||||
{
|
||||
size_t count = Base32ToByteStream(s.c_str(), s.length(), m_Hash, sizeof(m_Hash));
|
||||
return count == sizeof(m_Hash);
|
||||
}
|
||||
bool IdentHash::FromBase32(const std::string& s)
|
||||
{
|
||||
size_t count = Base32ToByteStream(s.c_str(), s.length(), m_Hash, sizeof(m_Hash));
|
||||
return count == sizeof(m_Hash);
|
||||
}
|
||||
|
||||
Keys CreateRandomKeys ()
|
||||
{
|
||||
|
@ -34,8 +34,8 @@ namespace data
|
||||
uint8_t certificate[3];
|
||||
|
||||
Identity& operator=(const Keys& keys);
|
||||
bool FromBase64(const std::string&);
|
||||
IdentHash Hash();
|
||||
bool FromBase64(const std::string& );
|
||||
IdentHash Hash() const;
|
||||
};
|
||||
|
||||
struct PrivateKeys // for eepsites
|
||||
@ -44,6 +44,10 @@ namespace data
|
||||
uint8_t privateKey[256];
|
||||
uint8_t signingPrivateKey[20];
|
||||
|
||||
PrivateKeys () = default;
|
||||
PrivateKeys (const PrivateKeys& ) = default;
|
||||
PrivateKeys (const Keys& keys) { *this = keys; };
|
||||
|
||||
PrivateKeys& operator=(const Keys& keys);
|
||||
};
|
||||
|
||||
|
@ -334,6 +334,7 @@ namespace stream
|
||||
StreamingDestination::StreamingDestination (): m_LeaseSet (nullptr)
|
||||
{
|
||||
m_Keys = i2p::data::CreateRandomKeys ();
|
||||
|
||||
m_IdentHash = m_Keys.pub.Hash ();
|
||||
m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag,
|
||||
CryptoPP::Integer (m_Keys.signingPrivateKey, 20));
|
||||
@ -349,6 +350,10 @@ namespace stream
|
||||
s.read ((char *)&m_Keys, sizeof (m_Keys));
|
||||
else
|
||||
LogPrint ("Can't open file ", fullPath);
|
||||
|
||||
m_IdentHash = m_Keys.pub.Hash ();
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user