mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-21 16:49:10 +01:00
TunnelDecryption for transit tunnel
This commit is contained in:
parent
11ac6712e7
commit
7754968e7a
3 changed files with 6 additions and 15 deletions
|
@ -17,20 +17,12 @@ namespace tunnel
|
||||||
m_TunnelID (receiveTunnelID), m_NextTunnelID (nextTunnelID),
|
m_TunnelID (receiveTunnelID), m_NextTunnelID (nextTunnelID),
|
||||||
m_NextIdent (nextIdent), m_NumTransmittedBytes (0)
|
m_NextIdent (nextIdent), m_NumTransmittedBytes (0)
|
||||||
{
|
{
|
||||||
m_ECBEncryption.SetKey (ivKey);
|
m_Encryption.SetKeys (layerKey, ivKey);
|
||||||
m_CBCEncryption.SetKey (layerKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransitTunnel::EncryptTunnelMsg (I2NPMessage * tunnelMsg)
|
void TransitTunnel::EncryptTunnelMsg (I2NPMessage * tunnelMsg)
|
||||||
{
|
{
|
||||||
uint8_t * payload = tunnelMsg->GetPayload () + 4;
|
m_Encryption.Encrypt (tunnelMsg->GetPayload () + 4);
|
||||||
|
|
||||||
m_ECBEncryption.Encrypt ((i2p::crypto::ChipherBlock *)payload, (i2p::crypto::ChipherBlock *)payload); // iv
|
|
||||||
|
|
||||||
m_CBCEncryption.SetIV (payload);
|
|
||||||
m_CBCEncryption.Encrypt (payload + 16, TUNNEL_DATA_ENCRYPTED_SIZE, payload + 16); // payload
|
|
||||||
|
|
||||||
m_ECBEncryption.Encrypt((i2p::crypto::ChipherBlock *)payload, (i2p::crypto::ChipherBlock *)payload); // double iv encryption
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransitTunnel::HandleTunnelDataMsg (i2p::I2NPMessage * tunnelMsg)
|
void TransitTunnel::HandleTunnelDataMsg (i2p::I2NPMessage * tunnelMsg)
|
||||||
|
|
|
@ -37,8 +37,7 @@ namespace tunnel
|
||||||
i2p::data::IdentHash m_NextIdent;
|
i2p::data::IdentHash m_NextIdent;
|
||||||
size_t m_NumTransmittedBytes;
|
size_t m_NumTransmittedBytes;
|
||||||
|
|
||||||
i2p::crypto::ECBEncryption m_ECBEncryption;
|
i2p::crypto::TunnelEncryption m_Encryption;
|
||||||
i2p::crypto::CBCEncryption m_CBCEncryption;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TransitTunnelGateway: public TransitTunnel
|
class TransitTunnelGateway: public TransitTunnel
|
||||||
|
|
4
aes.h
4
aes.h
|
@ -143,7 +143,7 @@ namespace crypto
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void SetKeys (uint8_t * layerKey, uint8_t * ivKey)
|
void SetKeys (const uint8_t * layerKey, const uint8_t * ivKey)
|
||||||
{
|
{
|
||||||
m_LayerEncryption.SetKey (layerKey);
|
m_LayerEncryption.SetKey (layerKey);
|
||||||
m_IVEncryption.SetKey (ivKey);
|
m_IVEncryption.SetKey (ivKey);
|
||||||
|
@ -165,7 +165,7 @@ namespace crypto
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void SetKeys (uint8_t * layerKey, uint8_t * ivKey)
|
void SetKeys (const uint8_t * layerKey, const uint8_t * ivKey)
|
||||||
{
|
{
|
||||||
m_LayerDecryption.SetKey (layerKey);
|
m_LayerDecryption.SetKey (layerKey);
|
||||||
m_IVDecryption.SetKey (ivKey);
|
m_IVDecryption.SetKey (ivKey);
|
||||||
|
|
Loading…
Add table
Reference in a new issue