juney1110 / lidgren-network-gen3

Automatically exported from code.google.com/p/lidgren-network-gen3
0 stars 0 forks source link

Encryption problem #141

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Peer_1 send encrypted data to Peer_2, then program of Peer_2 will crash.

What is the expected output? What do you see instead?
Peer_2 will receive plain text, but Peer_2 crash directly.

What version of the product are you using? On what operating system?
The version of the product is 20121027(may be rev326), and OS is win7 64bit

Please provide any additional information below.
Solution 1:
When I implement the INetEncryption, i must modify "msg.Data.Length = length of 
encrypted data" in Encrypt method. 
Maybe it reference msg.data.length to send data of NetBuffer...

P.S. Please forgive my poor English. : )

Original issue reported on code.google.com by rockers7...@gmail.com on 24 Nov 2012 at 1:18

GoogleCodeExporter commented 9 years ago
Actually, the best way to fix this problem, I see, is to change the following 
code

public byte[] Data
{
    get { return m_data; }
    set { m_data = value; }
}

from NetBuffer to the followin code

public byte[] Data
{
    get { return m_data; }
    set { m_data = value; LengthBytes = value.Length; }
}

and replace the following code

/// <summary>
/// Encrypt outgoing message
/// </summary>
public bool Encrypt(NetOutgoingMessage msg)
{
    ...
    msg.m_data = memoryStream.ToArray();
    ...
}

from each encription method file with the following code

/// <summary>
/// Encrypt outgoing message
/// </summary>
public bool Encrypt(NetOutgoingMessage msg)
{
    ...
    msg.Data = memoryStream.ToArray();
    ...
}

That would fix this issue.

Original comment by negrdroc...@gmail.com on 10 Jan 2013 at 2:45

GoogleCodeExporter commented 9 years ago
Just spent 4 hrs banging my head against a wall with AES and then I discovered 
this too.  Which I'd read the issues list first!

Original comment by max.kauf...@gmail.com on 10 Oct 2014 at 2:40

GoogleCodeExporter commented 9 years ago
Wow, this issue really snuck under the radar. Possibly since encryption is a 
community contribution. Fixed in rev 379.

Original comment by lidg...@gmail.com on 10 Oct 2014 at 7:36