Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top