Lecture 5 Modes of Operation
Lecture 5 Modes of Operation
Alshaimaa Abo-alian
Block Cipher [email protected]
Modes of Operation
Lecture Outline
➢Modes of operation
– Electronic Codebook (ECB)
– Cipher Block Chaining (CBC)
– Cipher Feedback (CFB)
– Output Feedback (OFB)
– Counter (CTR)
2
Modes of Operation
▪ A block cipher takes a fixed-length block of text of length n
bits and a key as input and produces a n-bit block of
ciphertext.
What about encrypting plaintext longer than n bits?
▪ Breaking the plaintext up into n-bit blocks and applying
cipher on each block
▪ When multiple blocks of plaintext are encrypted using the
same key, a number of security issues arise.
▪ A mode of operation is a technique for enhancing the effect
of a cryptographic algorithm
▪ As defined by NIST, there are 5 modes of operation for use
with any symmetric block cipher. 3
Modes of Operation
Mode Description Typical Application
5
Electronic Codebook (ECB) Mode
▪ We can define ECB mode as follows.
7
Cipher Block Chaining (CBC)
Mode
▪ We can define CBC mode as follows.
Cj = E(K, (Cj-1 ⊕ Pj ))
Pj = Cj-1 ⊕ D(K, Cj )
▪ To produce the first block of ciphertext, an initialization
vector (IV) is XORed with the first block of plaintext.
C1= E(K, (IV ⊕ P1 ))
P1 = IV ⊕ D(K, C1)
▪ The IV must be known to both the sender and receiver but be
unpredictable by a third party.
8
Properties of the CBC Mode
▪ Randomized encryption: Identical plaintext blocks results in
different ciphertext.
9
ECB vs. CBC
Encrypted image
Using ECB mode
Encrypted image
Using CBC mode
Original image
10
Cipher Feedback (CFB) Mode
▪ It is possible to convert a block cipher into a stream cipher,
using one of the following three modes:
1. Cipher feedback (CFB) mode
2. Output feedback (OFB) mode
3. Counter (CTR) mode.
▪ A stream cipher eliminates the need to pad a message to be
an integral number of blocks.
▪ If a character stream is being transmitted, each character
can be encrypted and transmitted immediately
11
C F B Mode Ij = LSBb-s (Ij-1 ) || Cj-1
Cj = Pj ⊕ MSBs (Oj )
I1 = IV
Oj = E (K, Ij)
12
C F B Mode
13
C F B Mode
▪ 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.
▪ We can define CFB mode as follows.
14
C F B Mode
– The input to the encryption function is a n-bit shift register that is
initially set to some initialization vector (IV).
▪ Chaining?
▪ Error Propagation?
16
O F B Mode
18
O F B Mode
▪ Similar in structure to that of CFB.
19
O F B Mode
▪ We can define OFB mode as follows.
20
Properties Of OFB Mode
▪ Chaining dependencies?
▪ Error propagation?
21
Counter (CTR) Mode
22
CTR Mode
23
Advantages of C T R
1. Efficiency
2. Preprocessing
3. Random access
4. Simplicity
24
Example
Consider a 4-bit block cipher, called ABC, that uses 2-bit keys.
Key Key
Plaintext 00 01 10 11 Plaintext 00 01 10 11
0000 0001 0101 1101 0111 1000 1000 1011 0101 1001
0001 1101 0111 1000 0101 1001 1100 0000 0010 0110
0011 0000 0110 0111 1010 1010 1010 0010 0000 0100
0010 0101 1101 1111 0011 1011 1011 0100 1001 1000
0100 0111 1000 1100 1101 1100 0110 0011 1010 1100
0101 1001 1111 1011 0001 1101 1111 1110 0100 0000
0110 0011 1001 0001 1110 1110 0100 1100 0011 0010
0111 1110 0001 0110 1111 1111 0010 1010 1110 1011
For a plaintext message of 0111 1001 0111 and key = 11, what is the ciphertext if the
following modes of operation are used, with IV= 1010:
a) ECB b) CBC c) CFB (s=2) d) OFB d) Counter
25
Final Answer
Mode Ciphertext
ECB 1111 0110 1111
CBC 0000 0110 0101
CFB 0001 1110 0110
OFB 0011 0100 0111
CTR 0000 1100 1101
Note:
In CTR, it is assumed that the initial counter is 0000 and incremented
by 1 for each subsequent block
26
Choose The Correct Answer
1. The simplest form of multiple encryption has __________
encryption stages and __________ keys.
A. four, two B. two, three
C. two, two D. three, two
2. Which of the following modes of operations can be
followed for both stream ciphers as well as block ciphers?
A. CBC (Cipher Block Chaining)
B. ECB (Electronic CodeBook)
C. CFB (Ciphertext FeedBack)
D. All of the above
27
Choose The Correct Answer
3. Which of the following is the major drawback of ECB?
A. Padding is required to make the plaintext divisible into blocks
of fixed size
B. It is prone to cryptanalysis since there is a direct relationship
between plaintext and ciphertext.
C. It requires large block size
D. None of the above
4. Which of the following modes implement chaining?
A. CBC B. OFB
C. ECB D. CTR
28
Try By Yourself
29
Thank you
30