Block Cipher Modes
Block Cipher Modes
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
length.
• E: {0,1}n × {0,1}k → {0,1}n
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• In real life there are two important issues:
• Plaintext much larger than a typical block length of 128 bits
• Plaintext not a multiple of block length
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Output feedback mode (OFB)
• Cipher feedback mode (CFB)
• Counter mode (CTR)
4
Electronic Code Book (ECB)
• Message is broken into independent blocks
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Each plaintext block gets encrypted by the key to a different
cipher-text
• Ci = EK(Pi)
5
Schematic Diagram
PDPU
Properties
• Chaining dependencies:
• Blocks are encrypted independently of other blocks.
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Reordering cipher-text blocks results in correspondingly re-
ordered plaintext blocks.
• Error propagation:
• One or more bit errors in a single cipher-text block affect
decipherment of that block only.
• Other blocks are not affected
7
Security Issues
• Identical blocks of plaintext will be encrypted as identical
blocks of cipher text
• Consider if the plaintext has only two possibilities : all 64 bits
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
(block length) 0 or all 64 bits 1
• ECB leaks all secret
• if aligned with plain text block
• particularly with data such as graphics
• or with messages that change very little, which become a
code-book analysis problem
• Weakness is due to the encrypted message blocks being
independent
• If attacker re-orders blocks it will not be detected by 8
receiver
Limitations of ECB
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
Original Encrypted with ECB Encrypted with other
than ECB
9
From wiki
Cipher Block Chaining (CBC)
• Used to solve the problem of identical plain text blocks
being encrypted to identical cipher-text blocks
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Idea is to use chaining
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Note that : C1 : EK(IV XOR P1)
• Thus, P1 = DK(C1) XOR IV
• If attacker flips certain bits of IV, the corresponding bits of
the recovered plain text also changes
• Can lead to problems in some applications (in which
integrity is required)
12
• if IV is sent in clear, attacker can change bits of first block,
and change IV to Compensate
Properties
• Chaining dependencies
• chaining causes cipher-text cj to depend on all preceding
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
plaintext
13
Properties
• Error propagation
• a single bit error in cj affects decipherment of blocks cj and
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
cj+1
• reordering the cipher-text blocks affects decryption
• Error recovery
• self-synchronizing: if an error occurs in cj (but not cj+1, cj+2),
then cj+2 is correctly decrypted to xj+2.
• can be used as a MAC: x1, x2, . . . , xn, cn (for Authentication)
14
Example – Error Propagation in CBC
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Last block of message is not as large as the block size of
cipher
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Can encryption begin until a complete block of data received?
17
Cipher Feedback Mode (CFB)
• The plaintext message
• is treated as a stream of bits
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• is added to the output of the block cipher
• the result is then feed back for next stage (hence the name)
• standard allows any number of bit (1,8, 64 or 128 etc) to be
feed back
• denoted CFB-1, CFB-8, CFB-64, CFB-128 etc
• most efficient to use all bits in block (64 or 128)
• Ci = Pi XOR DESK1(Ci-1)
• C-1 = IV
18
• uses: stream data encryption, authentication
Cipher Feedback Mode (CFB)
• Input
• k-bit key K;
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• n-bit IV;
• s-bit plaintext blocks x1…, xu (1≤ s≤n)
• Output
• produce s-bit cipher-text blocks c1,…,cu
19
Cipher Feedback Mode (CFB)
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• Most common stream mode
22
Advantages and Limitations of CFB
• A cipher-text segment depends on the current and all
preceding plaintext segments.
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• A corrupted cipher-text segment during transmission will
affect the current and next several plaintext segments.
• How many plaintext segments will be affected?
23
Advantages and Limitations of CFB
• Bit errors in the incoming cipher block (bytes in this
context) will cause bit error at the same bit positions in the
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
first plain text block.
• This cipher block will then be fed to the shift register and
cause bit errors in the plain text for as long as the erroneous
bits stay in the shift register.
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• output is then feed back (hence name OFB)
• feedback is independent of message
• can be computed in advance
• Oi = EK(Oi-1)
• Ci = Pi XOR Oi
• O-1 = IV
25
Cipher Feedback
Output Feedback
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• produce r-bit cipher-text blocks c1,…, cu
• Encryption
• I1←IV. For 1≤ j≤u, given plaintext block xj:
• Oj ← Ek(Ij). (Compute the block cipher output)
• tj ←the r leftmost bits of Oj - assume the leftmost is
identified as bit 1
• cj ←xj ⊕tj - transmit the r-bit ciphertext block cj
• Ij+1 ← Oj - update the block cipher input for the next block 28
• Ij+1 ← 2r ㆍIj + tj mod 2n” - shift output tj into right end of
shift register
Output Feedback Mode (OFB)
• Decryption
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• I1 ←IV.
• For 1≤j≤u, upon receiving cj: xj ← cj ⊕tj, where tj, Oj and
Ij are computed as above
29
Dr. Reema Patel, IS 2019, B.Tech,
30
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• more resistant to transmission errors; a bit error in a ciphertext segment
affects only the decryption of that segment.
31
• sender & receiver must remain in sync
Counter (CTR)
• similar to OFB
• but encrypts counter value rather than any feedback value
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• must have a different key & counter value for every
plaintext block (never reused)
• Oi = EK(i)
• Ci = Pi XOR Oi
32
Counter (CTR)
PDPU
Counter (CTR)
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• can pre process in advance of need
• good for high speed links
• random access to encrypted data blocks
• provable security (good as other modes)
• but must ensure never reuse key/counter values, otherwise
could break
36
Summary of Block Cipher Modes
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
• should not be used for message encryption
• good for encrypting random data such as key, IV
• CBC
• best for encrypting files
• speed is the same as the block cipher
• encryption is not parallelizable, but decryption is
• most suitable for software based systems
38
Choosing a Cipher mode
• CFB
• used for encrypting streams of information …8-bit CFB for
PDPU
Dr. Reema Patel, IS 2019, B.Tech, CE/ICT, SOT,
character encryption
• OFB
• used for high speed synchronous systems
• used if pre-processing is required.
39