Suppose I have a system whereby parties are identified by their public key (with some pre-selected asymmetric key algorithm). Suppose I have a party PUB1 which wants to establish a secure channel with a party PUB2. This necessarily means that party PUB1 already has PUB2's public key.

Given an untrusted medium with possibility of MITM, how can the parties establish a secure channel (no eavesdropping, no MITM) while mutually authenticating each other as the party that owns PRIV1/PRIV2 secrets matching the PUB1/PUB2 identity?

I understand that Diffie-Hellman with public keys can do exactly this – is that correct? Are there standard implementations for .NET which have built-in support for this mode of operation?

3 Answers 3


Yes, Diffie-Hellman with pre-shared public keys provides a mutually authenticated channel. However, if you use it, you will be guilty of using your own cryptographic implementation and in part your own cryptographic protocol, which is not nearly as big a sin as using your own cryptographic algorithm, but still best avoided. Unless you have a good reason not to, use SSL (with pre-shared, self-signed certificates, or for more flexibility with certificates signed by an in-house CA).

  • I was hoping that since Diffie-Hellman with pre-shared public keys is mentioned in at least one source, it's at least somewhat analyzed by experts, or maybe even implemented...
    – RomanSt
    Commented Jul 3, 2012 at 21:26

To authenticate the message, simply have PUB1 encrypt the message being sent with his private key and append it to the end of the message in plaintext. PUB2 will use the public key of PUB1 to decrypt the appended ciphertext to confirm the identity of PUB1.

If you want to establish a secure channel to transfer data, an asymmetric key algorithm can be used to establish a key for use in a symmetric key algorithm. - aka Hybrid Cryptosystems.

I have no personal experience with .NET implementation, so i cannot comment on that.

  • You cannot encrypt data with private keys; you can only sign messages (which I think is what you mean here) and decrypt.
    – gregmac
    Commented Feb 6, 2015 at 23:04

Yes and no, Diffie-Hellman key exchange does not alone provide any authentication.

However only the matching key will encrypt/decrypt the data, the public key section on Wikipedia is saying how to add such abilities. Basically send a random message encrypted with one public key to the other party who decrypts it (proving he has the private key) and re-encrypts it with the original senders public key and sends it back, I suggest repeating it the other way around, then do Diffie-Hellman as normal to get symmetric session keys.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .