Diffie Hellman key exchange using Microsoft’s CryptoAPI

I mentioned a while ago that I was working on implementing Diffie Hellman key exchange using the Microsoft CryptoAPI. It turns out that despite the mightly strong drugs that the Microsoft hackers who wrote the API were snorting, I managed to prevail…

If you want to know how to do this yourself, I recommend that you start off by trawling the Microsoft MSDN Newsgroups. Unfortunately, I don’t think I can show you my code, what with it being proprietary and all.

The hard bit is, how do you test something like this? Sure, the encrypt routine produces something interesting looking when you’ve exchanged keys, but there’s no gaurantee that it’s not just using the default encryption key or something. I’ll need to think about that bit some more.

(I’ve developed a new way of working at home which is very nice. I leave the work laptop and external hard disk on my desk, and then I can wander around the house with my personal laptop. The personal laptop has wireless and runs at a much higher resolution, which means I get more screen space for hacking. I use remote desktop protocol to get to the work machine so that I am still using the right version of the compiler and everything. It’s quite liberating.)