Table of Contents### Modes

#### Electronic Codebook Mode

Entire Site

When the message to be encrypted is longer than the block length of the cipher, it is necessary to execute the algorithm several times and to combine the results in some way. The method of combination is called the mode of operation.

In electronic codebook (ECB) mode, shown in Figure 13-3, the encryption algorithm is applied independently to each block of the message. This approach is obvious, straightforward, and almost always a bad idea. The main problems with this mode are that the same input block is always encrypted as the same ciphertext and that an attacker can substitute blocks to alter part of a message. Suppose, for example, that messages are being used to make payments. If the payment amount appears in a fixed place in the message, an attacker can change the payment amount by substituting ciphertext blocks from previous messages that use the same key. ECB mode can be appropriate for some uses, however, such as the encoding of random data (such as cryptographic keys) and the encryption of plaintext that is no larger than a single block.