Over the weekend, Paul Maher posted an article in which he asked if developers needed to understand cryptography.
I responded in his comments, but it needs a bit more detail than I provided in the comments.
I’m all for developers learning about crypto. But developers also need to understand that it’s all well and good for them to understand crypto, as long as they don’t ever actually attempt to IMPLEMENT crypto.
Because if they do attempt to implement crypo, they’re going to get it wrong.
There have been WAY too many examples of this. From the initial Microsoft PPTP implementation, to Netscape’s SSL implementation (I can’t find the reference right now, but the original Netscape SSL implementation used an easily discovered initialization vector which rendered the encryption essentially useless), to the authentication scheme for Dark Age of Camelot, the list goes on. All of the above issues have long been fixed, but that doesn’t matter, because they all share a common flaw.
The root cause of each of these failures was a developer that thought they understood crypto but didn’t REALLY understand it.
Whenever a developer decides that they can implement crypto, they need to stop and rethink what they’re doing, because they ARE going to get it wrong.
It makes sense for a developer to understand the relative strengths and weaknesses of different crypto solutions, to understand why SHA-1 is better than MD5, etc.
But developers also need to understand that doing cryptography right requires special skills that most developers don’t have.
Instead of attempting to roll their own crypto, they should rely on the cryptographic solutions that are built into the platform (CryptoAPI is your friend). If you stick to existing implementations, you’re less likely to mess it up.
And whatever you do, don’t attempt to roll your own authentication scheme – for every way you can mess up crypto, there are a dozen ways you can mess up authentication. See this wonderful dialog (I’ve referenced it before) for an example of the kind of pitfalls you can hit designing an authentication system.
So it makes sense for a developer to LEARN crypto. But developers shouldn’t believe that they can IMPLEMENT crypto. Because (with very few exceptions) they can’t.
So feel free to learn about crypto – there’s a lot of great stuff there. I highly recommend Simon Singh’s “The Code Book” (or the YA version of the same book) And of course Schneier’s Applied Cryptography is a classic.
But recognise that just because you’ve read a couple of books about cryptography, in general you’re not competent to actually implement cryptography.