Introduction to Block Cipher modes
There are two types of an algorithm, one is stream cipher and another one is block Cipher. In this article, we are going to see the block cipher Modes of Operation. Before that lets discussed the block cipher. Block cipher is an encryption technique, where encryption and decryption take place block by block. It encrypts one block of text at a time and decrypts one block of encrypted text at a time. Blocks used in this process are of 64 bits or more.
Block cipher modes of operation
There are 5 modes of operation in the block cipher.
1. ECB mode
- ECB mode stands for Electronic Code Block Mode. It is one of the simplest modes of operation. In this mode, the plain text is divided into a block where each block is of 64 bits. Then each block is encrypted separately. The same key is used for the encryption of all blocks. Each block is encrypted using the key and makes the block of ciphertext.
- At the receiver side, the data is divided into a block, each of 64 bits. The same key which is used for encryption is used for decryption. It takes the 64-bit ciphertext and by using the key convert the ciphertext into the plain text.
- As the same key is used for the encryption of all blocks, if the block of plain text is repeated in the original message, then the corresponding block of ciphertext will also repeat. As the same key used for tor all block, to avoid the repetition of block ECB mode is used for an only small message where the repetition of the plain text block is less.
2. CBC Mode
- CBC Mode stands for Cipher block Mode at the sender side, the plain text is divided into blocks. In this mode IV(Initialization Vector) is used which can be a random block of text. IV is used to make the ciphertext of each block unique.
- The first block of plain text and IV is combined using the XOR operation and then encrypted the resultant message using the key and form the first block of ciphertext. the first block of ciphertext is used as IV for the second block of plain text. the same procedure will be followed for all blocks of plain text.
- At the receiver side, the ciphertext is divided into blocks. The first block ciphertext is decrypted using the same key which is used for encryption. The decrypted result will be XOR with the IV and form the first block of plain text. The second block of ciphertext is also decrypted using the same key and the result of the decryption will be XOR with the first block of ciphertext and form the second block of plain text. The same procedure is used for all the blocks.
- CBC Mode ensures that if the block of plain text is repeated in the original message, it will produce the different ciphertext for corresponding blocks.
Note that the key which is used in CBC mode is the same, only the IV is different which is initialized at a starting point.
3. CFB Mode
- CFB mode stands for Cipher Feedback Mode. In this mode, the data is encrypted in the form of units where each unit is of 8 bits.
- Like cipher block chaining mode, IV is initialized. the IV is kept in the shift register. It is encrypted using the key and form the ciphertext.
- Now the leftmost j bits of the encrypted IV are XOR with the first j bits of the plain text. this process will form the first part of the ciphertext and this ciphertext will be transmitted to the receiver.
- Now the bits of IV are shifted left by j bit. therefor the rightmost j position of the shift register now has unpredictable data. these rightmost j positions are now filed with the ciphertext. the process will be repeated for all plain text units.
4. OFB mode
- OFB Mode stands for output feedback Mode. OFB mode is similar to CDB mode, the only difference is in CFB the ciphertext is used for the next stage of the encryption process whereas in OFB the output of the IV encryption is used for the next stage of the encryption process.
- The IV is encrypted using the key and form encrypted IV. Plain text and leftmost 8 bits of encrypted IV are combined using XOR and produce the ciphertext.
- For the next stage, the ciphertext which is form in the previous stage is used as an IV for the next iteration. the same procedure is followed for all blocks.
5. CTR Mode
- CTR Mode stands for counter mode. As the name is counter, it uses the sequence of numbers as an input for the algorithm. when the block is encrypted, to fill the next register next counter value is used.
Note: the counter value will be incremented by 1.
- For encryption, the first counter is encrypted using a key and then the plain text is XOR with the encrypted result to form the ciphertext.
- The counter will be incremented by 1 for the next stage and the same procedure will be followed for all blocks. For decryption, the same sequence will be used. Here to convert ciphertext into plain text each ciphertext is XOR with the encrypted counter. For the next stage, the counter will be incremented by the same will be repeated for all blocks of Ciphertext.
This has been a guide to the block Cipher modes of Operation. Here we have seen modes of operation of Block Cipher with their encryption and decryption process in detail. You may also have a look at the following articles to learn more–