Security Engineering. Ross Anderson

Читать онлайн.
Название Security Engineering
Автор произведения Ross Anderson
Жанр Зарубежная компьютерная литература
Серия
Издательство Зарубежная компьютерная литература
Год выпуска 0
isbn 9781119642817



Скачать книгу

of the Linux penguin, in clear and ECB encrypted."/>

      5.5.2 Cipher block chaining

      This mode disguises patterns in the plaintext: the encryption of each block depends on all the previous blocks. The input initialisation vector (IV) ensures that stereotyped plaintext message headers won't leak information by encrypting to identical ciphertexts, just as with a stream cipher.

Schematic illustration of the Cipher Block Chaining (CBC) mode.

      5.5.3 Counter encryption

      Feedback modes of block cipher encryption are falling from fashion, and not just because of cryptographic issues. They are hard to parallelise. With CBC, a whole block of the cipher must be computed between each block input and each block output. This can be inconvenient in high-speed applications, such as protecting traffic on backbone links. As silicon is cheap, we would rather pipeline our encryption chip, so that it encrypts a new block (or generates a new block of keystream) in as few clock ticks as possible.

      The simplest solution is to use AES as a stream cipher. We generate a keystream by encrypting a counter starting at an initialisation vector: upper K Subscript i Baseline equals left-brace upper I upper V plus i right-brace Subscript upper K, thus expanding the key upper K into a long stream of blocks upper K Subscript i of keystream, which is typically combined with the blocks of a message upper M Subscript i using exclusive-or to give ciphertext upper C Subscript i Baseline equals upper M Subscript i Baseline circled-plus upper K Subscript i.

      Additive stream ciphers have two systemic vulnerabilities, as we noted in section 5.2.2 above. The first is an attack in depth: if the same keystream is used twice, then the xor of the two ciphertexts is the xor of the two plaintexts, from which plaintext can often be deduced, as with Venona. The second is that they fail to protect message integrity. Suppose that a stream cipher were used to encipher fund transfer messages. These messages are highly structured; you might know, for example, that bytes 37–42 contain the sum being transferred. You could then cause the data traffic from a local bank to go via your computer, for example by an SS7 exploit. You go into the bank and send $500 to an accomplice. The ciphertext upper C Subscript i Baseline equals upper M Subscript i Baseline circled-plus upper K Subscript i, duly arrives in your machine. You know upper M Subscript i for bytes 37–42, so you can recover upper K Subscript i and construct a modified message which instructs the receiving bank to pay not $500 but $500,000! This is an example of an attack in depth; it is the price not just of the perfect secrecy we get from the one-time pad, but of much more humble stream ciphers, too.

      The usual way of dealing with this is to add an authentication code, and the most common standard uses a technique called Galois counter mode, which I describe later.

      5.5.4 Legacy stream cipher modes

      You may find two old stream-cipher modes of operation, output feedback mode (OFB) and less frequently ciphertext feedback mode (CFB).

      Output feedback mode consists of repeatedly encrypting an initial value and using this as a keystream in a stream cipher. Writing IV for the initialization vector, we will have upper K Baseline 1 equals left-brace upper I upper V right-brace Subscript upper K and upper K i equals left-brace upper I upper V right-brace Subscript upper K left-parenthesis i minus 1 right-parenthesis. However an n-bit block cipher in OFB mode will typically have a cycle length of 2 Superscript n slash 2 blocks, after which the birthday theorem will see to it that we loop back to the IV. So we may have a cycle-length problem if we use a 64-bit block cipher such as triple-DES on a high-speed link: once we've called a little over 2 Superscript 32 pseudorandom 64-bit values, the odds favour a match. (In CBC mode, too, the birthday theorem ensures that after about 2 Superscript n slash 2 blocks, we will start to see repeats.) Counter mode encryption, however, has a guaranteed cycle length of 2 Superscript n rather than 2 Superscript n slash 2, and as we noted above is easy to parallelise. Despite this OFB is still used, as counter mode only became a NIST standard in 2002.

      Cipher feedback mode is another kind of stream cipher, designed for use in radio systems that have to resist jamming. It was designed to be self-synchronizing, in that even if we get a burst error and drop a few bits, the system will recover synchronization after one block length. This is achieved by using our block cipher to encrypt the last n bits of ciphertext, adding the last output bit to the next plaintext bit, and shifting the ciphertext along one bit. But this costs one block cipher operation per bit and has very bad error amplification properties; nowadays people tend to use dedicated link layer protocols for synchronization and error correction rather than trying to combine them with the cryptography at the traffic layer.