views:

31

answers:

1

Hey guys, I have been working on a p2p namespace for some of my programs. I created a system to encrypt/decrypt the packets send/received with the class. I was using the basic public private key system: 1) encrypt the data with Symmetric encryption 2) encrypt the symmetric key with RSA. Then do the opposite when you decrypted..

I was wondering though, how would you verify if the packet was coming from where it said it was. I was going to use a basic certificate system (where you encrypt with your private RSA key, then they decrypt it with your public key), but I don't know how to do this with C#. I am using the RSACryptoServiceProvider class.

Does anyone know how do this? Thanks, Max

A: 

The standard protocol for sending packets securely is SSL/TLS. The RFCs for TLS and DTLS (and a fix for a recent flaw) are the way to go. They should also be considered a resource for those learning and looking for ideas.

It sounds like you're a looking for a MAC. A very efficient set of crypto primitives that perform both encryption and MACing at the same time are the AEAD ciphers, see for example CCM and GCM block cipher modes.

I do not believe .NET supports any AEAD ciphers. You can also use the slower but perfectly adequate HMAC algorithm which is supported in .NET, or you can use the bouncycastle C# library which does support AEAD ciphers.

GregS
Thanks for the answer, but I'm not much of a cryptographer, could you "dumb it down" a bit for me ;)I need a way for one computer to know that a packet is from the sender it says it is. A MAC wouldn't work (I was able to understand that for the most part), I am already sending md5 hashes over.Thanks, Max
mazzzzz
All the more reason to use a canned solution like SSL. It is too hard to dumb down, I think. It requires some study before being understood. Perhaps someone else can do better.
GregS
So, just so you can say it bluntly, there is no .net library to encrypt data with a private key, and decrypt it with a public key?Thanks for the patience,Max
mazzzzz