3

Taken from http://en.wikipedia.org/wiki/Public-key_cryptography enter image description here

In the Diffie–Hellman key exchange scheme, each party generates a public/private key pair and distributes the public key. After obtaining an authentic copy of each other's public keys, Alice and Bob can compute a shared secret offline. The shared secret can be used, for instance, as the key for a symmetric cipher.

My question is, given the arbitrary public key (Bob's) and arbitrary private key (Alice's), how can we implement this function (derive the shared secret key offline) in C#?

private static SecretKey generateSharedSecret(PrivateKey private_key, PublicKey public_key)  
{
    //combine the keys
    return secretKey;
}
Dennis
  • 3,528
  • 4
  • 28
  • 40
  • 1
    See this: https://msdn.microsoft.com/en-us/library/system.security.cryptography.ecdiffiehellmancng(v=vs.110).aspx and https://www.codeproject.com/Articles/24632/Shared-Key-Generation-using-Diffie-Hellman – zaitsman Feb 28 '17 at 10:43
  • 1
    By using [ECDiffieHellmanCng](https://msdn.microsoft.com/en-us/library/system.security.cryptography.ecdiffiehellmancng(v=vs.110).aspx)object, for example – Tinwor Feb 28 '17 at 10:44
  • 1
    Ask this on the Security or CompSci site. It's off-topic here. – H H Feb 28 '17 at 11:18

0 Answers0