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 .) 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  examined this particular attack and its practicality on lightweight ciphers such as 3DES, PRESENT , and HIGHT . 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  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.