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.

Electronic Code Book (ECB) mode<br />

This mode simply breaks up a message into blocks and directly encrypts each block<br />

with the raw encryption operation. It does not have any desirable security properties<br />

and should not be used under any circumstances. We cover raw encryption as a<br />

building block for building other modes, but we don’t cover ECB itself because of its<br />

poor security properties.<br />

ECB has been standardized by NIST (the U.S. National Institute for Standards and<br />

Technology).<br />

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

• Encrypting a block of a fixed value always yields the same result, making ECB<br />

mode particularly susceptible to dictionary attacks.<br />

• When encrypting more than one block and sending the results over an untrusted<br />

medium, it is particularly easy to add or remove blocks without detection (that<br />

is, ECB is susceptible to tampering, capture replay, and other problems). All<br />

other cipher modes that lack integrity checking have similar problems, but ECB<br />

is particularly bad.<br />

• The inputs to the block cipher are never randomized because they are always<br />

exactly equal to the corresponding block of plaintext.<br />

• Offline precomputation is feasible.<br />

The mode does have certain advantages, but do note that other modes share these<br />

advantages:<br />

• Multiblock messages can be broken up, and the pieces encrypted in parallel.<br />

• Random access of messages is possible; the 1,024th block can be decrypted<br />

without decrypting other data blocks.<br />

However, the advantages of ECB do not warrant its use.<br />

We do discuss how to use ECB to encrypt a block at a time in Recipe 5.5, when it is<br />

necessary in implementing other cryptographic primitives.<br />

Cipher Block Chaining (CBC) mode<br />

CBC mode is a simple extension to ECB mode that adds a significant amount of<br />

security. CBC works by breaking the message up into blocks, then using XOR to<br />

combine the ciphertext of the previous block with the plaintext of the current block.<br />

The result is then encrypted in ECB mode. The very first block of plaintext is XOR’d<br />

with an initialization vector (IV). The IV can be publicly known, and it must be randomly<br />

selected for maximum security. Many people use sequential IVs or even fixed<br />

IVs, but that is not at all recommended. For example, SSLhas had security problems<br />

in the past when using CBC without random IVs. Also note that if there are common<br />

initial strings, CBC mode can remain susceptible to dictionary attacks if no IV<br />

164 | 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!