Re: How to encrypt TCP data?



On Sep 6, 5:09 pm, Eric <englere_...@xxxxxxxxx> wrote:
On Sep 4, 12:32 pm, ElderUberGeek <aribl...@xxxxxxxxx> wrote:

One component is written in C# and one in VC++ (both VS2005).

I forgot to point out that most encryption is done by blocks. I also
use this in TCP, so I blocked up my data packets and I apply
encryption to each one separately. I call these my logical blocks and
they are 100K bytes in size. Once it goes thru Ethernet it'll get
broken into much small blocks. So when you read the data you'll have
to piece together the blocks so you can decrypt the same logical block
that you encrpyted.

To make the job of logical packet reassembly easier, I am sending the
block size as the first 4 bytes of each logical block. The receiver
gets that first, and then he knows how many bytes to expect. The last
block in a transfer will often be smaller, and that's why you need a
method of telling the receiver how many bytes to expect.

There are more efficient ways to do it. I wanted to make it work in a
number of scenerios, and I needed to get it done soon, so I just use
this methodology. I also included a flag in my common code to indicate
if it should be sent unencrypted. That makes the code useful in more
situations.

Eric

.



Relevant Pages