mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
process extended indetities for LeaseSets
This commit is contained in:
parent
b77325c689
commit
2aaac1a0d5
5 changed files with 172 additions and 17 deletions
22
LeaseSet.cpp
22
LeaseSet.cpp
|
@ -62,15 +62,17 @@ namespace data
|
|||
|
||||
void LeaseSet::ReadFromBuffer ()
|
||||
{
|
||||
const LeaseSetHeader * header = (const LeaseSetHeader *)m_Buffer;
|
||||
m_Identity = header->destination;
|
||||
m_IdentHash = m_Identity.Hash();
|
||||
memcpy (m_EncryptionKey, header->encryptionKey, 256);
|
||||
LogPrint ("LeaseSet num=", (int)header->num);
|
||||
size_t size = m_Identity.FromBuffer (m_Buffer, m_BufferLen);
|
||||
memcpy (m_EncryptionKey, m_Buffer + size, 256);
|
||||
size += 256; // encryption key
|
||||
size += m_Identity.GetSigningPublicKeyLen (); // unused signing key
|
||||
uint8_t num = m_Buffer[size];
|
||||
size++; // num
|
||||
LogPrint ("LeaseSet num=", (int)num);
|
||||
|
||||
// process leases
|
||||
const uint8_t * leases = m_Buffer + sizeof (LeaseSetHeader);
|
||||
for (int i = 0; i < header->num; i++)
|
||||
const uint8_t * leases = m_Buffer + size;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
Lease lease = *(Lease *)leases;
|
||||
lease.tunnelID = be32toh (lease.tunnelID);
|
||||
|
@ -88,11 +90,7 @@ namespace data
|
|||
}
|
||||
|
||||
// verify
|
||||
CryptoPP::DSA::PublicKey pubKey;
|
||||
pubKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag,
|
||||
CryptoPP::Integer (m_Identity.signingKey, 128));
|
||||
CryptoPP::DSA::Verifier verifier (pubKey);
|
||||
if (!verifier.VerifyMessage (m_Buffer, leases - m_Buffer, leases, 40))
|
||||
if (!m_Identity.Verify (m_Buffer, leases - m_Buffer, leases))
|
||||
LogPrint ("LeaseSet verification failed");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue