Block Cipher Modes
Block Cipher Modes
Block Cipher Modes
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
1
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
For a message longer than b bits, the procedure is simply to break the
message into b-bit blocks, padding the last block if necessary. Decryption is
performed one block at a time, always using the same key. In Figure 6.3, the
plaintext (padded as necessary) consists of a sequence of b-bit blocks, P1,
P2,..., PN; the corresponding sequence of ciphertext blocks is C1, C2,..., CN.
2
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
The ECB method is ideal for a short amount of data, such as an encryption
key. Thus, if you want to transmit a DES key securely, ECB is the appropriate
mode to use.
The most significant characteristic of ECB is that the same b-bit block of
plaintext, if it appears more than once in the message, always produces the
same ciphertext.
For lengthy messages, the ECB mode may not be secure. If the message is
highly structured, it may be possible for a cryptanalyst to exploit these
regularities. For example, if it is known that the message always starts out
with certain predefined fields, then the cryptanalyst may have a number of
known plaintext-ciphertext pairs to work with. If the message has repetitive
elements, with a period of repetition a multiple of b bits, then these elements
can be identified by the analyst. This may help in the analysis or may provide
an opportunity for substituting or rearranging blocks.
3
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
For decryption, each cipher block is passed through the decryption algorithm.
The result is XORed with the preceding ciphertext block to produce the
plaintext block. To see that this works, we can write
Then
4
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
The IV must be known to both the sender and receiver but be unpredictable
by a third party. For maximum security, the IV should be protected against
unauthorized changes. This could be done by sending the IV using ECB
encryption. One reason for protecting the IV is as follows: If an opponent is
able to fool the receiver into using a different value for IV, then the opponent
is able to invert selected bits in the first block of plaintext. To see this, consider
the following:
P1 = IV ⊕D(K, C1)
Now use the notation that X[i] denotes the ith bit of the b-bit quantity X. Then
where the prime notation denotes bit complementation. This means that if an
opponent can predictably change bits in IV, the corresponding bits of the
received value of P1 can be changed.
In addition to its use to achieve confidentiality, the CBC mode can be used for
authentication.
5
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
also can operate in real time. Thus, if a character stream is being transmitted,
each character can be encrypted and transmitted immediately using a
character-oriented stream cipher.
One desirable property of a stream cipher is that the ciphertext be of the same
length as the plaintext. Thus, if 8-bit characters are being transmitted, each
character should be encrypted to produce a cipher text output of 8 bits. If
more than 8 bits are produced, transmission capacity is wasted.
Figure (6-3) depicts the CFB scheme. In the figure, it is assumed that the unit
of transmission is s bits; a common value is s = 8. As with CBC, the units of
plaintext are chained together, so that the ciphertext of any plaintext unit is a
function of all the preceding plaintext. In this case, rather than units of b bits,
the plaintext is divided into segments of s bits.
6
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
First, consider encryption. The input to the encryption function is a b-bit shift
register that is initially set to some initialization vector (IV). The leftmost (most
significant) s bits of the output of the encryption function are XORed with the
first segment of plaintext P1 to produce the first unit of ciphertext C1, which is
then transmitted. In addition, the contents of the shift register are shifted left
by s bits and C1 is placed in the rightmost (least significant) s bits of the shift
register. This process continues until all plaintext units have been encrypted.
For decryption, the same scheme is used, except that the received ciphertext
unit is XORed with the output of the encryption function to produce the
plaintext unit. Note that it is the encryption function that is used, not the
decryption function. This is easily explained. Let Ss(X) be defined as the most
significant s bits of X. Then
C1 = P1 ⊕ Ss[E(K, IV)]
Therefore,
P1 = C1 ⊕ Ss[E(K, IV)]
7
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
One advantage of the OFB method is that bit errors in transmission do not
propagate. For example, if a bit error occurs in C1 only the recovered value of
is P1 affected; subsequent plaintext units are not corrupted. With CFB, C1 also
serves as input to the shift register and therefore causes additional corruption
downstream.
8
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
checksum portion of the message as well as to the data portion, to alter the
ciphertext in such a way that it is not detected by an error-correcting code.
Figure (6-5) depicts the CTR mode. A counter, equal to the plaintext block
size is used. The only requirement is that the counter value must be different
for each plaintext block that is encrypted. Typically, the counter is initialized
to some value and then incremented by 1 for each subsequent block (modulo
2b where b is the block size). For encryption, the counter is encrypted and
then XORed with the plaintext block to produce the ciphertext block; there is
no chaining. For decryption, the same sequence of counter values is used,
with each encrypted counter XORed with a ciphertext block to recover the
c o r r e s p o n d i n g p l a i n t e x t b l o c k .
9
Chapter Six Prepared By :
Block Ciphers Modes Of Operation Asst. Prof. Dr. Muhanad Tahrir Younis
10