mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
store remote IdentHash only
This commit is contained in:
parent
cfde1f8c27
commit
c065fae422
14
Garlic.cpp
14
Garlic.cpp
|
@ -18,7 +18,7 @@ namespace garlic
|
||||||
{
|
{
|
||||||
GarlicRoutingSession::GarlicRoutingSession (GarlicDestination * owner,
|
GarlicRoutingSession::GarlicRoutingSession (GarlicDestination * owner,
|
||||||
std::shared_ptr<const i2p::data::RoutingDestination> destination, int numTags, bool attachLeaseSet):
|
std::shared_ptr<const i2p::data::RoutingDestination> destination, int numTags, bool attachLeaseSet):
|
||||||
m_Owner (owner), m_Destination (destination), m_NumTags (numTags),
|
m_Owner (owner), m_IsDestination (destination->IsDestination ()), m_NumTags (numTags),
|
||||||
m_LeaseSetUpdateStatus (attachLeaseSet ? eLeaseSetUpdated : eLeaseSetDoNotSend),
|
m_LeaseSetUpdateStatus (attachLeaseSet ? eLeaseSetUpdated : eLeaseSetDoNotSend),
|
||||||
m_LeaseSetUpdateMsgID (0),
|
m_LeaseSetUpdateMsgID (0),
|
||||||
m_ElGamalEncryption (new i2p::crypto::ElGamalEncryption (destination->GetEncryptionPublicKey ()))
|
m_ElGamalEncryption (new i2p::crypto::ElGamalEncryption (destination->GetEncryptionPublicKey ()))
|
||||||
|
@ -26,10 +26,12 @@ namespace garlic
|
||||||
// create new session tags and session key
|
// create new session tags and session key
|
||||||
RAND_bytes (m_SessionKey, 32);
|
RAND_bytes (m_SessionKey, 32);
|
||||||
m_Encryption.SetKey (m_SessionKey);
|
m_Encryption.SetKey (m_SessionKey);
|
||||||
|
if (m_IsDestination)
|
||||||
|
m_DestinationIdent = destination->GetIdentHash ();
|
||||||
}
|
}
|
||||||
|
|
||||||
GarlicRoutingSession::GarlicRoutingSession (const uint8_t * sessionKey, const SessionTag& sessionTag):
|
GarlicRoutingSession::GarlicRoutingSession (const uint8_t * sessionKey, const SessionTag& sessionTag):
|
||||||
m_Owner (nullptr), m_Destination (nullptr), m_NumTags (1), m_LeaseSetUpdateStatus (eLeaseSetDoNotSend), m_LeaseSetUpdateMsgID (0)
|
m_Owner (nullptr), m_IsDestination (false), m_NumTags (1), m_LeaseSetUpdateStatus (eLeaseSetDoNotSend), m_LeaseSetUpdateMsgID (0)
|
||||||
{
|
{
|
||||||
memcpy (m_SessionKey, sessionKey, 32);
|
memcpy (m_SessionKey, sessionKey, 32);
|
||||||
m_Encryption.SetKey (m_SessionKey);
|
m_Encryption.SetKey (m_SessionKey);
|
||||||
|
@ -177,7 +179,7 @@ namespace garlic
|
||||||
if (!tagFound) // new session
|
if (!tagFound) // new session
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Garlic: No tags available, will use ElGamal");
|
LogPrint (eLogInfo, "Garlic: No tags available, will use ElGamal");
|
||||||
if (!m_Destination)
|
if (!m_ElGamalEncryption)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: Can't use ElGamal for unknown destination");
|
LogPrint (eLogError, "Garlic: Can't use ElGamal for unknown destination");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -297,7 +299,7 @@ namespace garlic
|
||||||
}
|
}
|
||||||
if (msg) // clove message ifself if presented
|
if (msg) // clove message ifself if presented
|
||||||
{
|
{
|
||||||
size += CreateGarlicClove (payload + size, msg, m_Destination ? m_Destination->IsDestination () : false);
|
size += CreateGarlicClove (payload + size, msg, m_IsDestination);
|
||||||
(*numCloves)++;
|
(*numCloves)++;
|
||||||
}
|
}
|
||||||
memset (payload + size, 0, 3); // certificate of message
|
memset (payload + size, 0, 3); // certificate of message
|
||||||
|
@ -315,11 +317,11 @@ namespace garlic
|
||||||
{
|
{
|
||||||
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 8000; // 8 sec
|
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 8000; // 8 sec
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
if (isDestination && m_Destination)
|
if (isDestination)
|
||||||
{
|
{
|
||||||
buf[size] = eGarlicDeliveryTypeDestination << 5;// delivery instructions flag destination
|
buf[size] = eGarlicDeliveryTypeDestination << 5;// delivery instructions flag destination
|
||||||
size++;
|
size++;
|
||||||
memcpy (buf + size, m_Destination->GetIdentHash (), 32);
|
memcpy (buf + size, m_DestinationIdent, 32);
|
||||||
size += 32;
|
size += 32;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
4
Garlic.h
4
Garlic.h
|
@ -127,7 +127,9 @@ namespace garlic
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GarlicDestination * m_Owner;
|
GarlicDestination * m_Owner;
|
||||||
std::shared_ptr<const i2p::data::RoutingDestination> m_Destination;
|
bool m_IsDestination; // destination or RouterInfo ?
|
||||||
|
i2p::data::IdentHash m_DestinationIdent;
|
||||||
|
|
||||||
i2p::crypto::AESKey m_SessionKey;
|
i2p::crypto::AESKey m_SessionKey;
|
||||||
std::list<SessionTag> m_SessionTags;
|
std::list<SessionTag> m_SessionTags;
|
||||||
int m_NumTags;
|
int m_NumTags;
|
||||||
|
|
Loading…
Reference in a new issue