Monday, November 7, 2011

In defense of Applied Cryptography

Over the weekend I found myself re-reading a few bits of Bruce Schneier's Applied Cryptography for a historical research project, and it reminded me what a fantastically wonderful, completely insane piece of writing it is. I'm sure Bruce Schneier needs no additional validation in his life, but I do think it's worth saying a few words about the book -- and why we need more works like it in our field.

I should preface this all by saying that Applied Cryptography is probably one of the most influential crypto books ever written. It certainly played a part in getting me interested in the field. If you don't own a copy, you should, if only to be awed by Bruce's knowledge of bizarre, historical ciphers and all of the ways they've been broken. (Though the most recent edition is from 1996, so don't go looking for up to date information in it.)

Much the way a hard-core Nirvana fan will roll their eyes if you mention "Nevermind", people in the crypto research community tend to get a little bent out of shape if someone references Applied Cryptography. This is not because AC is a lousy book, or because the material is inaccessible or wrong. Quite the contrary. Rather, the case against Applied Cryptography is that it made cryptography too damned accessible. And that has led to a whole lot of fail, some on a pretty grand scale.

The detailed argument goes something like this: Applied Cryptography demystified cryptography for a lot of people. By doing so, it empowered them to experiment with crypto techniques, and to implement their own code. No problem so far.

Unfortunately, some readers, abetted by Bruce's detailed explanations and convenient source code examples, felt that they were now ready to implement crypto professionally. Inevitably their code made its way into commercial products, which shipped full of horribly ridiculous, broken crypto implementations. This is the part that was not so good. We're probably still dealing with the blowback today.

Just for one modest example, take this fragment of code spotted in a Diebold voting machine, circa 2003:

// LCG - Linear Conguential Generator - used to generate ballot serial numbers 
// A psuedo-random-sequence generator  
// (per Applied Cryptography, by Bruce Schneier, Wiley, 1996) 
#define LCG_MULTIPLIER 1366 
#define LCG_INCREMENTOR 150889 ...
Thanks to Applied Cryptography, the Diebold coders were able to write a perfectly functional Linear Congruential Generator in no time at all. You certainly can't blame Bruce for anything here -- the LCG code is fine. It's certainly not his fault that Diebold missed the part where he warned never to use LCGs for security applications. Whoops!

Although it's all said with love, some people really do blame Applied Cryptography for this sort of thing. Even Bruce has at various points himself apologized for this aspect of the book.

(Not coincidentally, you'll notice that his more recent books are nowhere near as brazenly useful as AC. Where Practical Cryptography is all crapped up with grave warnings about the dangers of rolling your own crypto implementations, Applied Cryptography just laid it all out there sans apology, like a copy of the Anarchist Cookbook left open in a middle school library.)

But I said that I'm writing this post to praise the book, not to damn it with faint praise.

What's magical about Applied Cryptography is really two things. First of all, it's an incredible historical document. If there's a cipher that was used in the period 1970-1996, you'll read about it in Applied Cryptography. Even if the cipher was based on the cryptographic equivalent of an abacus, even if it was broken in the same conference in which it was published, Bruce will still give you a full design description and the address of the guy who owns the patent.

And you have to love the understated way in which he sums up his opinions. Take, for example, the section on the FEAL cipher. After four dense paragraphs in which he lays out not one, but eleven devastating attacks culminating in the total demolition of FEAL (and possibly, the ritual suicide of its designers), he could have written something terrible, capping it with three exclamation points. Instead, he leaves it with the following, dry remark:
Whenever someone discovers a new cryptanalytic attack, he always seems to try it out on FEAL first.
All joking aside, I've found Applied Cryptography (and its massive bibliography) to be incredibly useful, particularly when examining historical crypto software, and (most importantly) when finding prior art to current crypto patents. Applied Cryptography is like a key to a time period that's not well covered by Google Scholar or other Internet search tools. It's helped me through more than one trip to the library.

The other magical thing about AC is that you really feel that after writing it, Bruce must have been a few pounds lighter -- and some of that weight was his soul. I'm not saying he's soulless! (Though he does work for BT now, doesn't he?) It's just that there's just no way to read through this monster of a book, with its enormous compendium of bibliographies and source code, and imagine someone writing this thing just for the money or even for the fame. In my opinion it's an achievement of practical cryptography that has not been matched either before or since.

And that's too bad, because someone really should try.

No comments:

Post a Comment