|
|
@ -31,7 +31,7 @@ namespace data |
|
|
|
m_Buffer = new uint8_t[MAX_RI_BUFFER_SIZE]; |
|
|
|
m_Buffer = new uint8_t[MAX_RI_BUFFER_SIZE]; |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
m_BufferLen = len; |
|
|
|
m_BufferLen = len; |
|
|
|
ReadFromBuffer (); |
|
|
|
ReadFromBuffer (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RouterInfo::~RouterInfo () |
|
|
|
RouterInfo::~RouterInfo () |
|
|
@ -51,7 +51,7 @@ namespace data |
|
|
|
m_Properties.clear (); |
|
|
|
m_Properties.clear (); |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
m_BufferLen = len; |
|
|
|
m_BufferLen = len; |
|
|
|
ReadFromBuffer (); |
|
|
|
ReadFromBuffer (true); |
|
|
|
// don't delete buffer until save to file
|
|
|
|
// don't delete buffer until save to file
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -90,13 +90,15 @@ namespace data |
|
|
|
void RouterInfo::ReadFromFile () |
|
|
|
void RouterInfo::ReadFromFile () |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (LoadFile ()) |
|
|
|
if (LoadFile ()) |
|
|
|
ReadFromBuffer (); |
|
|
|
ReadFromBuffer (false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RouterInfo::ReadFromBuffer () |
|
|
|
void RouterInfo::ReadFromBuffer (bool verifySignature) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream str (std::string ((char *)m_Buffer, m_BufferLen)); |
|
|
|
std::stringstream str (std::string ((char *)m_Buffer, m_BufferLen)); |
|
|
|
ReadFromStream (str); |
|
|
|
ReadFromStream (str); |
|
|
|
|
|
|
|
if (verifySignature) |
|
|
|
|
|
|
|
{ |
|
|
|
// verify signature
|
|
|
|
// verify signature
|
|
|
|
CryptoPP::DSA::PublicKey pubKey; |
|
|
|
CryptoPP::DSA::PublicKey pubKey; |
|
|
|
pubKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag, CryptoPP::Integer (m_RouterIdentity.signingKey, 128)); |
|
|
|
pubKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag, CryptoPP::Integer (m_RouterIdentity.signingKey, 128)); |
|
|
@ -107,6 +109,7 @@ namespace data |
|
|
|
LogPrint ("signature verification failed"); |
|
|
|
LogPrint ("signature verification failed"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RouterInfo::ReadFromStream (std::istream& s) |
|
|
|
void RouterInfo::ReadFromStream (std::istream& s) |
|
|
|
{ |
|
|
|
{ |
|
|
|