Encryption Implementation Really Matters
Written by Walter ConwayA 403 Labs QSA, PCI Columnist Walt Conway has worked in payments and technology for more than 30 years, 10 of them with Visa.
Last week’s column on encryption generated a lot of discussion (be sure to read the many thoughtful comments posted to the story, too) that requires some follow-up. I was wrong on one important point, and we need to correct that. And on the broader issue of the proper application of encryption, there are wider cryptosystem issues every retail CIO needs to address.
First, let’s deal with the correction. The premise of my PCI column last week was that retailers may be making a mistake by encrypting the expiration date in their cardholder databases. The reasoning was that the limited number of possible expiration date values opens retailers to the risk of having their entire cardholder database compromised because their encryption keys could be disclosed by a determined and sophisticated attack on the expiration date alone.
(Related Column: Evan Schuman’s Editor’s Note About The Reaction To The Encryption Column: The Danger Of Assuming Perfection.)
As several readers pointed out in comments and E-mail messages, this assumption is wrong. What I described is called a known-plaintext attack, and today’s cryptographic systems are designed with this attack in mind. Cryptanalysis against modern, properly implemented cryptosystems requires a very (if unfeasibly) large number of known plaintexts for this type of attack to work. That is, an encrypted but easily determined expiration date does not automatically present a key disclosure vulnerability in a properly implemented cryptographic system.
It all depends on the implementation.
The key phrase is “properly implemented.” What does that phrase mean? Quoting from one insightful (and anonymous) comment: “That is done by using an Initialization Vector (IV) and choosing a secure operational mode (not ECB) for the cipher. An IV is a block of random data the same size as the encryption block size, and it becomes your first encrypted block. In any of the chaining modes of operation, this first block of random data is mixed in with the data before the next block is encrypted to produce the second block, which is your real data encrypted, but is now randomized. When you decrypt, you simply skip the first block you decrypt, as it’s the random IV value you started with, and begin with the next block. Every new encryption must use a new random IV, as repeated use of the IV defeats the purpose.”
Although some may disagree with the details, the point is that it is not easy to implement a cryptosystem properly, as several readers noted. Cryptography is a particularly opaque subject to non-specialists. Unfortunately, many of these same non-specialists are either building cryptosystems to protect their cardholder data or trying to purchase a product that does it for them. They have to. As QSAs and PA-QSAs, my colleagues and I see this situation every day. Many of the people implementing cryptography don’t know much more than the names of some “good” algorithms and the idea that a bigger key length is better.