Module 2
Cipher Block Modes of
Operations
How to use a block cipher?
• Block ciphers encrypt fixed-size blocks
• e.g. DES encrypts 64-bit blocks
• We need some way to encrypt a message of
arbitrary length
• e.g. a message of 1000 bytes
• NIST defines several ways to do it
• called modes of operation
3
Five Modes of Operation
• Electronic codebook mode (ECB)
• Cipher block chaining mode (CBC) – most popular
• Output feedback mode (OFB)
• Cipher feedback mode (CFB)
• Counter mode (CTR)
4
Electronic Code Book (ECB)
• The plaintext is broken into blocks, P1, P2, P3, ...
• Each block is encrypted independently:
Ci = EK(Pi)
• For a given key, this mode behaves like we have a gigantic codebook,
in which each plaintext block has an entry, hence the name Electronic
Code Book
5
P.Jeevana Jyothi 6
Remarks on ECB
• Strength: it’s simple.
• Weakness:
• Repetitive information contained in the plaintext
may show in the cipher text, if aligned with blocks.
• If the same message is encrypted (with the same
key) and sent twice, their cipher texts are the
same.
• Typical application: secure transmission of
short pieces of information (e.g. a temporary
encryption key)
7
Cipher Block Chaining (CBC)
The plaintext is broken into blocks: P1 , P2 , P3 , ...
Each plaintext block is XORed chained with the previous
ciphertext block before encryption (hence the name):
Ci E K Ci 1 Pi
C0 IV
Use an Initial Vector IV to start the process.
Decryption : Pi Ci 1 D K (Ci )
Application : general block-oriented transmission.
8
Cipher Block Chaining (CBC)
9
Remarks on CBC
• The encryption of a block depends on the current and all blocks
before it.
• So, repeated plaintext blocks are encrypted differently.
• Initialization Vector (IV)
• Must be known to both the sender & receiver
• Typically, IV is either a fixed value or is sent encrypted in ECB mode
before the rest of ciphertext.
10
Cipher Feedback (CFB) Mode
11
Remark on CFB
• The block cipher is used as a stream cipher.
• Appropriate when data arrives in bits/bytes.
• s can be any value; a common value is s = 8.
• A ciphertext segment depends on the current and
all preceding plaintext segments.
• A corrupted ciphertext segment during
transmission will affect the current and next
several plaintext segments.
• How many plaintext segments will be affected?
12
Output Feedback (OFB) Mode
P.Jeevana Jyothi 13
Remark on OFB
• The block cipher is used as a stream cipher.
• Appropriate when data arrives in bits/bytes.
• Advantage:
• more resistant to transmission errors; a bit error in a ciphertext
segment affects only the decryption of that segment.
• Disadvantage:
• Cannot recover from lost ciphertext segments; if a ciphertext
segment is lost, all following segments will be decrypted
incorrectly (if the receiver is not aware of the segment loss).
• IV should be generated randomly each time and sent with
the ciphertext.
14
Counter Mode (CTR)
• Plaintext blocks: p1, p2, p3, …
• Key: k
• Encryption:
15
Remark on CTR
• Strengthes:
• Needs only the encryption algorithm
• Fast encryption/decryption; blocks can be processed
(encrypted or decrypted) in parallel; good for high
speed links
• Random access to encrypted data blocks
• IV should not be reused.
16