I started reading Schneier et al.’s “Cryptography Engineering” last week. It’s a great book and a helpful reminder for many of the small details that make cryptography a difficult subject. One of the running goals of the book is to talk about how two parties can communicate securely with a security level of . This means that, in the best case, any viable attack requires at least units of work, which is well beyond practicality.

One mathematical hurdle we struggle with is the birthday paradox. It says that given randomly selected values, the probability that any two of them are equal is roughly . This means that for block ciphers with a block size of bits, there is a probability that two ciphertexts will collide (be equal). Depending on the mode in which this cipher is used, this can reveal quite a lot of information. For example, if CBC mode is used, then a collision in two ciphertext blocks means that there is a collision in the plaintext. Specifically, if blocks and collide, then it follows that the inputs to these independent encryptions are identical. Therefore, we know that . This holds because is a PRP, or pseudorandom permutation. If we replaced with a PRF , the same would not be true. This is because it is possible for where .

If the simpler CTR mode was used with this block cipher, then the collision reveals significantly less information. (In fact, using CTR mode with a PRF is secure up to blocks, unlike CBC mode [1].) Specifically, if collides with , then by the permutation properties of it follows that iff , which is not possible since and is unique. Therefore, while it is not straightforward to learn specific values of the plaintext, it is possible to distinguish the cipher in CTR mode from an ideal block cipher. To do so, one would encrypt blocks of identical plaintext using CTR mode. If a collision occurs, which will happen with relatively high probability after that amount of encryptions with the same key, then the cipher is clearly a PRP in CTR mode.

Why is this important when most block ciphers we use have a 128-bt block size, and therefore a security boundary? Well, not all block ciphers in use have such a large block size. 3DES, for example, has a 64-bit block size. This means that the CBC attack variant is possible after collecting blocks of ciphertext encrypted with the same key. The recent Sweet32 attack [2] examined this particular attack and its practicality on lightweight ciphers such as 3DES, PRESENT [3], and HIGHT [4]. With web services that offer 3DES as a possible cipher and without any bounds on session (and key) lifetime, this means that cleverly placed code to record encrypted blocks can be used to carry out this type of leakage attack.

The authors of the Sweet32 paper say that the proper mitigation strategy is to use a 128-bit block cipher such as AES. It’s standardized, optimized, and well-understood. However, for legacy reasons, there are devices that simply cannot use this mode. In this case, special care has to be taken to ensure that the amount of data encrypted with the same key is less than the birthday bound ( in the 3DES case). Re-keying is an important part of session management [5] as it can significantly increase the security properties of the encryption scheme in use. (This is intuitive since re-keying is basically refreshing the birthday bound count back to zero.)

So what can you take away from this attack? For starters, you should be using modern cryptographic algorithms where possible. Second, you should be managing your secrets properly. One-time keys are the best we can do from a security perspective. And since generating them is difficult, we should limit the amount of times we use our ephemeral keys. And last but certainly not least, you should be mindful of the ways in which you use cryptography, even if a certain approach is considered best practice.

- [1] M. Bellare, A. Desai, E. Jokipii, and P. Rogaway. A concrete security treatment of symmetric encryption. In 38th FOCS, pages 394–403. IEEE Computer Society Press, Oct. 1997.
- [2] https://sweet32.info/SWEET32_CCS16.pdf
- [3] A. Bogdanov, L. R. Knudsen, G. Leander, C. Paar, A. Poschmann, M. J. B. Robshaw, Y. Seurin, and C. Vikkelsoe. PRESENT: An ultra-lightweight block cipher. In P. Paillier and I. Verbauwhede, editors, CHES 2007, volume 4727 of LNCS, pages 450–466. Springer, Heidelberg, Sept. 2007.
- [4] D. Hong, J. Sung, S. Hong, J. Lim, S. Lee, B.-S. Koo, C. Lee, D. Chang, J. Lee, K. Jeong, H. Kim, J. Kim, and S. Chee. HIGHT: A new block cipher suitable for low-resource device. In L. Goubin and M. Matsui, editors, CHES 2006, volume 4249 of LNCS, pages 46–59. Springer, Heidelberg, Oct. 2006.
- [5] https://cseweb.ucsd.edu/~mihir/papers/rekey.pdf