mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-08-27 09:20:05 +00:00
GetGarlicKey return [key,tag] pair. Remove replyIV
This commit is contained in:
+1
-2
@@ -120,8 +120,7 @@ namespace tunnel
|
||||
if (m_Config->GetLastHop () && m_Config->GetLastHop ()->ident->GetIdentHash () != m_Config->GetLastHop ()->nextIdent)
|
||||
{
|
||||
// add garlic key/tag for reply
|
||||
uint8_t key[32];
|
||||
uint64_t tag = m_Config->GetLastHop ()->GetGarlicKey (key);
|
||||
auto [key, tag] = m_Config->GetLastHop ()->GetGarlicKey ();
|
||||
if (m_Pool && m_Pool->GetLocalDestination ())
|
||||
m_Pool->GetLocalDestination ()->SubmitECIESx25519Key (key, tag);
|
||||
else
|
||||
|
||||
@@ -75,14 +75,6 @@ namespace tunnel
|
||||
}
|
||||
}
|
||||
|
||||
void TunnelHopConfig::DecryptRecord (uint8_t * records, int index) const
|
||||
{
|
||||
uint8_t * record = records + index*TUNNEL_BUILD_RECORD_SIZE;
|
||||
i2p::crypto::CBCDecryption decryption;
|
||||
decryption.SetKey (replyKey);
|
||||
decryption.Decrypt(record, TUNNEL_BUILD_RECORD_SIZE, replyIV, record);
|
||||
}
|
||||
|
||||
void ShortECIESTunnelHopConfig::EncryptECIES (const uint8_t * plainText, uint8_t * encrypted)
|
||||
{
|
||||
if (!ident) return;
|
||||
@@ -169,12 +161,9 @@ namespace tunnel
|
||||
i2p::crypto::ChaCha20 (record, SHORT_TUNNEL_BUILD_RECORD_SIZE, replyKey, nonce, record);
|
||||
}
|
||||
|
||||
uint64_t ShortECIESTunnelHopConfig::GetGarlicKey (uint8_t * key) const
|
||||
std::pair<const uint8_t *, uint64_t> ShortECIESTunnelHopConfig::GetGarlicKey () const
|
||||
{
|
||||
uint64_t tag;
|
||||
memcpy (&tag, m_CK, 8);
|
||||
memcpy (key, m_CK + 32, 32);
|
||||
return tag;
|
||||
return { m_CK + 32, buf64toh (m_CK) };
|
||||
}
|
||||
|
||||
void ShortPhonyTunnelHopConfig::CreateBuildRequestRecord (uint8_t * records, uint32_t replyMsgID)
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace tunnel
|
||||
uint8_t layerKey[32];
|
||||
uint8_t ivKey[32];
|
||||
uint8_t replyKey[32];
|
||||
uint8_t replyIV[16];
|
||||
bool isGateway, isEndpoint;
|
||||
|
||||
TunnelHopConfig * next, * prev;
|
||||
@@ -43,8 +42,8 @@ namespace tunnel
|
||||
virtual uint8_t GetRetCode (const uint8_t * records) const = 0;
|
||||
virtual void CreateBuildRequestRecord (uint8_t * records, uint32_t replyMsgID) = 0;
|
||||
virtual bool DecryptBuildResponseRecord (uint8_t * records) const = 0;
|
||||
virtual void DecryptRecord (uint8_t * records, int index) const; // AES
|
||||
virtual uint64_t GetGarlicKey (uint8_t * key) const { return 0; }; // return tag
|
||||
virtual void DecryptRecord (uint8_t * records, int index) const = 0;
|
||||
virtual std::pair<const uint8_t *, uint64_t> GetGarlicKey () const { return { nullptr, 0}; }; // return [key,tag]
|
||||
};
|
||||
|
||||
struct ShortECIESTunnelHopConfig: public TunnelHopConfig, public i2p::crypto::NoiseSymmetricState
|
||||
@@ -59,7 +58,7 @@ namespace tunnel
|
||||
void CreateBuildRequestRecord (uint8_t * records, uint32_t replyMsgID) override;
|
||||
bool DecryptBuildResponseRecord (uint8_t * records) const override;
|
||||
void DecryptRecord (uint8_t * records, int index) const override; // Chacha20
|
||||
uint64_t GetGarlicKey (uint8_t * key) const override;
|
||||
std::pair<const uint8_t *, uint64_t> GetGarlicKey () const override;
|
||||
};
|
||||
|
||||
struct ShortPhonyTunnelHopConfig: public TunnelHopConfig
|
||||
|
||||
Reference in New Issue
Block a user