Search This Blog

Thursday, 3 September 2026

Block Cipher Modes of Operation

0 comments

Block Ciphers and Modes of Operation

  • Block ciphers encrypt data in fixed-size blocks. These blocks are usually 64 or 128 bits. 
  • The encryption algorithm then processes each block of data separately using the key to transform the given data into cipher text. 
  • When our data to encrypt is bigger than the given block-size, we partition the data into several blocks, and encrypt them seperately. 
  • A mode of operation simply describes how to repeatedly apply a cipher’s single-block operation to securely transform amounts of data larger than one block. 
  • There are four different modes of operation available for Block Ciphers.  They are as follows:
    • Electronic Code Book (ECB)
    • Cipher Block Chaining (CBC)
    • Cipher Feedback Mode (CFM)
    • Output Feedback Mode (OFM)

1.  Electronic Code Book (ECB):

  • This is the simplest mode for block ciphers — the plain text is processed block by block and each block is encrypted using a single key. 
  • Since multiple blocks are encrypted using the same key, it obviously gives security problems.
  • ECB works very fast, since it allows for encrypting blocks in parallel. 
  • It is also very robust against loss or corruption of individual blocks. This is because each block of cipher text is generated independently of all the other blocks, which means that loss or corruption of one block does not get transferred to the other blocks.

2.  Cipher Book Chaining (CBC):

  • In CBC, the previous cipher text is given as input to the next encryption algorithm after it is XOR’ed with the original text block.
Cipher Block Chaining (CBC) Mode of Operation
  • This mode of operations involves two step process:
    • We have an input text we want to encrypt. In the first step, where we have no previous cipher text to XOR with our input text, we make an Initialization Vector (IV), which is XORed with our input text. This is then passed on to our encryption algorithm, which produces the cipher text.
    • We take the ciphertext from the previous step, and XOR it with the current input text block. This is then passed to the encryption algorithm, which gives us the cipher text needed in the next block. 
  • This process is simple to understand, and easy to implement. However, it is not as fast as ECB, since we cannot encrypt in parallel, when we need the cipher text from a former step.

3.  Cipher Feedback (CFB) Mode:

  • Cipher FeedBack (CFB) mode is a bit different from ECB and CBC.  
  • It does its operation as follows:
    • We start out by creating an Initialization Vector (IV), which is n-bits long.
    • The initialization vector is encrypted using the secret key.
    • The result is then XOR’ed with the message to produce the ciphertext.
    • The ciphertext is given as feedback to the next block to perform the encryption, the output of which is XOR’ed with the message to produce the ciphertext of next block
    • This process is continued until all blocks have been encrypted.
  • CFB has the same drawback as that of CBC — we cannot encrypt in parallel, when we need the cipher text from a former step.

4.  Output FeedBack (OFB) Mode:

  • Output Feedback Mode is similar to CFB.  The major difference is that it passes on the encrypted output, instead of the XOR’ed output.
  • Following are the step by step approach of OFB:
    • We start out by creating an Initialization Vector (IV), which is n-bits long.
    • The initialization vector is encrypted using the secret key.
    • The result is then used as a feedback given to the next block to be encrypted further.
    • The encrypted message is XORed with the plaintext to produce the ciphertext
  • This process is continued until all blocks have been encrypted.

5.  Counter Mode (CTR)

  • In this mode, we have a vector containing both a nonce and a counter — each have the same length. This is then passed to the encryption algorithm, which is XOR’ed with the plaintext — which gives us the cipher text.
  • Here are the various steps involved in Counter (CTR) Mode of operation:
    • We load the vector, which contains the initial counter value as well as the nonce (Number used Once). This serves the same purpose as the IV in the CFB and CBC modes.
    • We encrypt the vector containing the nonce and the counter.
    • We XOR the encrypted nonce and counter vector with the input text — which gives us the cipher text.
    • We update out counter
    • The next block is now encrypted. This is done until the last block has been encrypted.
  • Since we don’t use any chaining in Counter Mode (CTR), it is possible to perform the encryption in parallel on many blocks of plain-text or ciphertext.

References

Leave a Reply