17 Modes of Operation

epgp books

 

 

 

Learning Objectives

  • To understand the Overview of Modes of Operation
  • Discuss about each mode of operation such as EBC, CBC, CFB, OFB, CTR
  • To Compare different modes and to discuss remarks over them

18.1.    INTRODUCTION

 

So far we have seen the basic working of block ciphers. In this section, we discuss about modes of operation of block ciphers. Basically the lengthy plain text is divided into number of blocks in block ciphers. Block ciphers encrypt fixed size blocks eg. DES encrypts 64-bit blocks, with 56-bit key. But in actual scenario, the file size which has to be encrypted may not be the multiple of the block size. That is in practise, we usually need to handle arbitrary amounts of data, which may be available in advance (in which case a block mode is appropriate), and may only be available a bit/byte at a time (in which case a stream mode is used). A mode of operation describes the process of encrypting each of these blocks under a single key. A mode of operation describes the process of encrypting each of these blocks under a single key. Some modes may use randomised addition input value. We can apply a particular mode of operation in this situation. Basic modes of operations such as Electronic Code Book(ECB), Cipher Block Chaining(CBC), Cipher Feed Back (CFB), Output Feed Back (OFB), Counter (CTR) modes are considered here

Terms used :

  • Initialize Vector (IV)
    • a block of bits to randomize the encryption and hence to produce distinct ciphertext
  • Nonce : Number (used) Once
    • Random of psuedorandom number to ensure that past communications can not be reused in replay attacks. Some also refer to initialize vector as nonce
  • Padding
    • Final block may require a padding to fit a block size. Add null Bytes, Add 0x80 and many 0x00, Add the n bytes with value n are the different methods to achieve padding.

18.2.    Electronic Codebook Book (ECB)

 

Message is broken into independent blocks which are encrypted

 

Each block is a value which is substituted, like a codebook, hence name

 

Each block is encoded independently of the other blocks

 

Ci = EK (Pi)

Uses: secure transmission of single values

ECB Scheme

 

 

Remarks on ECB

 

  • Strength: it’s simple.
  • Weakness:
    • Repetitive information contained in the plaintext may show in the ciphertext, if aligned with blocks.
    • If the same message is encrypted (with the same key) and sent twice, their ciphertext are the same.
  • Typical application:
    • secure transmission of short pieces of information (e.g. a temporary encryption key)

18.3.    Cipher Block Chaining (CBC)

 

To overcome the problems of repetitions and order independence in ECB, want some way of making the ciphertext dependent on all blocks before it. This is what CBC gives us, by combining the previous ciphertext block with the current message block before encrypting. To start the process, use an Initial Value (IV), which is usually well known (often all 0’s), or otherwise is sent, ECB encrypted, just before starting CBC use. CBC mode is applicable whenever large amounts of data need to be sent securely, provided that its available in advance (eg email, FTP, web etc)

 

Use Initial Vector (IV) to start process

 

Ci = EK (Pi XOR Ci-1)

 

C0 = IV

 

Uses: bulk data encryption, authentication

 

 

18.4.    Cipher Feed Back (CFB)

 

If the data is only available a bit/byte at a time (eg. terminal session, sensor value etc), then must use some other approach to encrypting it, so as not to delay the info. Idea here is to use the block cipher essentially as a pseudo-random number generator (see stream cipher lecture later) and to combine these “random” bits with the message. Note as mentioned before, XOR is an easily inverted operator (just XOR with same thing again to undo). Again start with an IV to get things going,then use the ciphertext as the next input. As originally defined, idea was to “consume” as much of the “random” output as needed for each message unit (bit/byte) before “bumping” bits out of the buffer and re-encrypting. This is wasteful though, and slows the encryption down as more encryptions are needed. An alternate way to think of it is to generate a block of “random” bits, consume them as message bits/bytes arrive, and when they’re used up, only then feed a full block of cipher text back. This is CFB-64 mode, the most efficient. This is the usual choice for quantities of stream oriented data, and for authentication use.

 

Plaintext is treated as a stream of bits .Any number of bit (1, 8 or 64 or whatever) to be feed back (denoted CFB-1, CFB-8, CFB-64).

 

Relation between plaintext and ciphertext

 

Ci = Pi XOR SelectLeft(EK (ShiftLeft(Ci-1)))

 

C0 = IV

 

Uses: stream data encryption, authentication

CFB Scheme

When the block cipher is used as a stream cipher.

 

In CFB mode, encipherment and decipherment use the encryption function of the underlying block cipher.

 

Enable to encrypt any number of bits e.g. single bits or single characters (bytes)

S=1 : bit stream cipher

S=8 : character stream cipher

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.

 

18.5.    Output Feed Back (OFB)

 

The alternative to CFB is OFB. Here the generation of the “random” bits is independent of the message being encrypted. The advantage is that firstly, they can be computed in advance, good for bursty traffic, and secondly, any bit error only affects a single bit. Thus this is good for noisy links (eg satellite TV transmissions etc). It works verysimilar to CFB .But output of the encryption function output of cipher is fed back (hence name), instead of ciphertext .Feedback is independent of message.

 

Relation between plaintext and ciphertext

 

Ci = Pi XOR Oi

 

Oi = EK (Oi-1)

 

O0 = IV

 

Uses: stream encryption over noisy channels

 

18.6.    CFB V.S. OFB

18.7.    OFB Scheme

 

In OFB mode, encipherment and decipherment use the encryption function of the underlying block cipher.

 

OFB as a Stream Cipher

Because the “random” bits are independent of the message, they must never ever be used more than once (otherwise the 2 ciphertexts can be combined, cancelling these bits, and leaving a “book” cipher to solve). Also, as noted, should only ever use a full block feedback ie OFB-64 mode.

 

Each bit in the ciphertext is independent of the previous bit or bits. This avoids error propagation

 

Pre-compute of forward cipher is possible. Regarding security issue , when jth plaintext is known, the jth output of the forward cipher function will be known . Easily cover jth plaintext block of other message with the same IV . This scheme requires the IV is a nonce.

 

18.8.    Counter (CTR)

 

Here, we encrypts counter value with the key rather than any feedback value (no feedback).

Counter for each plaintext will be different .It can be any function which produces a sequence which is guaranteed not to repeat for a long time.

 

Ci = Pi XOR Oi

Oi = EK (i)

 

Uses: high-speed network encryptions

 

 

Remark on CTR

  • Strengths:
    • Needs only the encryption algorithm
    • Random access to encrypted data blocks
    • Simple; fast encryption/decryption
  • Counter must be
    • Must be unknown and unpredictable
    • pseudo-randomness in the key stream is a goal

Remarks on each mode

 

Basically two types of ciphers are there:

  • Block cipher
  • Stream cipher

CBC is an excellent block cipher.CFB, OFB, and CTR are stream ciphers.CTR is faster because simpler and it allows parallel processing.

 

Modes and IV

 

  • An IV has different security requirements than a key. Generally, an IV will not be reused under the same key .
  • CBC and CFB
    • Reusing an IV leaks some information about the first block of plaintext, and about any common prefix shared by the two messages
  • OFB and CTR
    • Reusing an IV completely destroys security

18.9.    CBC and CTR comparison

 

Comparison of Different Modes

Comparison of Modes

ECB, CBC, OFB, CFB, CTR, and XTS modes only provide confidentiality. To ensure an encrypted message is not accidentally modified or maliciously tampered requires a separate Message Authentication Code (MAC).

Several MAC schemes such as HMAC, CMAC and GMAC are available. But compositing a confidentiality mode with an authenticity mode could be difficult and error prone. The modes that so far discussed were mainly devised for DES. New modes combined confidentiality and data integrity into a single cryptographic primitive such as CCM, GCM, CWC, EAX, IAPM and OCB are proposed for AES.

 

SUMMARY

  • Discussed about different modes of ciphers
  • Discussed encryption and decryption in each mode.
  • Comparative study is carried out in different modes.
you can view video on Modes of Operation