21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The primary disadvantages of CTR mode are:<br />

• Flipping bits in the plaintext is very easy because flipping a ciphertext bit flips<br />

the corresponding plaintext bit (this problem is shared with all stream cipher<br />

modes). As with other encryption algorithms, message integrity checks are absolutely<br />

necessary for adequate security.<br />

• Reusing {key, counter} pairs is disastrous. Generally, if there is any significant<br />

risk of reusing a {key, nonce} pair (e.g., across reboot), it is best to avoid ever<br />

reusing a single key across multiple messages (or data streams). (See Recipe 4.11<br />

for advice if you wish to use one base secret and derive multiple secrets from it.)<br />

• CTR mode has inadequate security when using ciphers with 64-bit blocks,<br />

unless you use a large random nonce and a small counter, which drastically limits<br />

the number of messages that can be sent. For this reason, OCB is probably<br />

still preferable for such ciphers, but CTR is clearly better for 128-bit block<br />

ciphers.<br />

The primary advantages of CTR mode are:<br />

• The keystream can be precomputed.<br />

• The keystream computation can be done in parallel.<br />

• Random access into the keystream is possible. (The 1,024th byte can be<br />

decrypted with only a single raw encryption operation.)<br />

• For ciphers where raw encryption and decryption require separate algorithms<br />

(particularly AES), only a single algorithm is necessary. In such a case, the faster<br />

of the two algorithms can be used (though you will get incompatible results if<br />

you use decryption where someone else uses encryption).<br />

• CTR mode leaks incredibly little information about the key. After 264 encryptions,<br />

an attacker would learn about a bit’s worth of information on a 128-bit<br />

key.<br />

CTR mode is old and simple, and its security properties are well understood. It has<br />

recently gained a lot of favor in the cryptographic community over other solutions<br />

for using block ciphers in streaming modes, particularly as the world moves to AES<br />

with its 128-bit blocks.<br />

Many of the “better” modes that provide built-in integrity checking, such as CWC<br />

and CCM mode, use CTR mode as a component because of its desirable properties.<br />

We discuss CTR mode in Recipe 5.9.<br />

Output Feedback (OFB) mode<br />

OFB mode is another streaming mode, much like CTR mode. The keystream is generated<br />

by continually encrypting the last block of keystream to produce the next<br />

block. The first block of keystream is generated by encrypting a nonce. OFB mode<br />

166 | Chapter 5: Symmetric Encryption<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!