|
|
@ -117,14 +117,14 @@ namespace garlic |
|
|
|
return session->HandleNextMessage (buf, len, shared_from_this (), index); |
|
|
|
return session->HandleNextMessage (buf, len, shared_from_this (), index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DatabaseLookupTagSet::DatabaseLookupTagSet (GarlicDestination * destination, const uint8_t * key): |
|
|
|
SymmetricKeyTagSet::SymmetricKeyTagSet (GarlicDestination * destination, const uint8_t * key): |
|
|
|
ReceiveRatchetTagSet (nullptr), m_Destination (destination) |
|
|
|
ReceiveRatchetTagSet (nullptr), m_Destination (destination) |
|
|
|
{ |
|
|
|
{ |
|
|
|
memcpy (m_Key, key, 32); |
|
|
|
memcpy (m_Key, key, 32); |
|
|
|
Expire (); |
|
|
|
Expire (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool DatabaseLookupTagSet::HandleNextMessage (uint8_t * buf, size_t len, int index) |
|
|
|
bool SymmetricKeyTagSet::HandleNextMessage (uint8_t * buf, size_t len, int index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (len < 24) return false; |
|
|
|
if (len < 24) return false; |
|
|
|
uint8_t nonce[12]; |
|
|
|
uint8_t nonce[12]; |
|
|
@ -133,18 +133,18 @@ namespace garlic |
|
|
|
len -= 16; // poly1305
|
|
|
|
len -= 16; // poly1305
|
|
|
|
if (!i2p::crypto::AEADChaCha20Poly1305 (buf + offset, len - offset, buf, 8, m_Key, nonce, buf + offset, len - offset, false)) // decrypt
|
|
|
|
if (!i2p::crypto::AEADChaCha20Poly1305 (buf + offset, len - offset, buf, 8, m_Key, nonce, buf + offset, len - offset, false)) // decrypt
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "Garlic: Lookup reply AEAD decryption failed"); |
|
|
|
LogPrint (eLogWarning, "Garlic: Symmetric key tagset AEAD decryption failed"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
// we assume 1 I2NP block with delivery type local
|
|
|
|
// we assume 1 I2NP block with delivery type local
|
|
|
|
if (offset + 3 > len) |
|
|
|
if (offset + 3 > len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "Garlic: Lookup reply is too short ", len); |
|
|
|
LogPrint (eLogWarning, "Garlic: Symmetric key tagset is too short ", len); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (buf[offset] != eECIESx25519BlkGalicClove) |
|
|
|
if (buf[offset] != eECIESx25519BlkGalicClove) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "Garlic: Lookup reply unexpected block ", (int)buf[offset]); |
|
|
|
LogPrint (eLogWarning, "Garlic: Symmetric key tagset unexpected block ", (int)buf[offset]); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
offset++; |
|
|
|
offset++; |
|
|
@ -152,7 +152,7 @@ namespace garlic |
|
|
|
offset += 2; |
|
|
|
offset += 2; |
|
|
|
if (offset + size > len) |
|
|
|
if (offset + size > len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "Garlic: Lookup reply block is too long ", size); |
|
|
|
LogPrint (eLogWarning, "Garlic: Symmetric key tagset block is too long ", size); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (m_Destination) |
|
|
|
if (m_Destination) |
|
|
|