1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 15:16:33 +09:00

Net encryption generalized to support more algorithms

This commit is contained in:
lidgren
2011-04-16 22:37:15 +00:00
parent 6976177f94
commit a4503d22e1
11 changed files with 317 additions and 63 deletions

View File

@@ -104,17 +104,9 @@ namespace Lidgren.Network
m_isFragment = false;
}
public void Decrypt(NetXtea tea)
public bool Decrypt(INetEncryption encryption)
{
// requires blocks of 8 bytes
int blocks = m_bitLength / 64;
if (blocks * 64 != m_bitLength)
throw new NetException("Wrong message length for XTEA decrypt! Length is " + m_bitLength + " bits");
byte[] result = new byte[m_data.Length];
for (int i = 0; i < blocks; i++)
tea.DecryptBlock(m_data, (i * 8), result, (i * 8));
m_data = result;
return encryption.Decrypt(this);
}
/// <summary>