简体   繁体   中英

Verify p2p node

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM