21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

or similar mechanism is used. As with ECB, padding is required, unless messages are<br />

always block-aligned.<br />

CBC has been standardized by NIST.<br />

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

• Encryption cannot be parallelized (though decryption can be, and there are<br />

encryption workarounds that break interoperability; see Recipe 5.14).<br />

• There is no possibility of offline precomputation.<br />

• Capture replay of entire or partial messages can be possible without additional<br />

consideration.<br />

• The mode requires an initial input that must be random. It is not sufficient to<br />

use a unique but predictable value.<br />

• The mode leaks more information than is optimal. We wouldn’t use it to output<br />

more than 240 blocks.<br />

• The primary advantage of CBC mode is that it captures the desirable properties<br />

of ECB mode, while removing most of the drawbacks.<br />

We discuss CBC mode in Recipe 5.6.<br />

Counter (CTR) mode<br />

Whereas ECB and CBC are block-based modes, counter (CTR) mode and the rest of<br />

the modes described in this section simulate a stream cipher. That is, they use blockbased<br />

encryption as an underlying primitive to produce a pseudo-random stream of<br />

data, known as a keystream. The plaintext is turned into ciphertext by XOR’ing it<br />

with the keystream.<br />

CTR mode generates a block’s worth of keystream by encrypting a counter using<br />

ECB mode. The result of the encryption is a block of keystream. The counter is then<br />

incremented. Generally, the counter being publicly known is acceptable, though it’s<br />

always better to keep it a secret if possible. The counter can start at a particular<br />

value, such as zero, or something chosen at random, and increment by one every<br />

time. (The initial counter value is a nonce, which is subtly different from an initialization<br />

vector; see Recipe 4.9.) Alternatively, the counter can be modified every time<br />

using a deterministic pseudo-random number generator that doesn’t repeat until all<br />

possible values are generated. The only significant requirements are that the counter<br />

value never be repeated and that both sides of an encryption channel know the order<br />

in which to use counters. In practice, part of the counter is usually chosen randomly<br />

at keying time, and part is sequential. Both parts help thwart particular kinds of<br />

risks.<br />

Despite being over 20 years old, CTR mode has only recently been standardized by<br />

NIST as part of the AES standardization process.<br />

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

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.<br />

Selecting a Cipher Mode | 165

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

Saved successfully!

Ooh no, something went wrong!