Algorithm Modes

Even though a basic algorithm is designed to be efficient, different cipher modes are implemented in order to make the algorithm efficient in concealing the patterns. The different types of cipher modes are as follows:

Electronic Code Book

Electronic Code Book is a straightforward method of converting a block of plaintext into cipher text. The advantage of this mode is asynchronous enciphering of the data. However, this mode is vulnerable to attacks since the same plain text is always converted to the same cipher text.
ecb
Block Cipher Encryption in Electronic Code Book (ECB) Mode

Cipher Block Chaining

In Cipher Block Chaining mode, the plain text is XORed with the previous cipher text block before encryption. Thus, the encryption of each block depends on all the previous blocks.

cbc
Block Cipher Encryption in Cipher Block Chaining (CBC) Mode

The above Figure presents the block diagram for the Cipher Block Chaining (CBC) mode. This mode removes the patterns when compared to the ECB mode. If a bit error occurs during encryption, it will affect all the subsequent blocks. However, during decryption, the effect is reversed and the recovered plain text will only have a single error.

Cipher Feedback Mode

Cipher Feedback Mode is used when data must be transmitted in blocks smaller than as a full block. The incoming byte, or a group of bytes, of plaintext is XORed with the LSB of the self-synchronizing stream cipher. A self-synchronizing stream cipher has a key stream in which every bit is a function of a fixed number of previous cipher texts.
cfb
Stream Cipher Encryption in Cipher Feedback (CFB) Mode

Output Feedback Mode

The Output Feedback Mode (OFB) also uses a synchronous stream cipher but the feedback mechanism is independent of the plain text and the cipher text stream. Instead of inserting the cipher text bits as feedback, the n bits of the output block are moved to the right side of the shift register. Therefore, this mode provides ease of processing even before the plain text arrives. When the plain text arrives, it is simply XORed with the output bits of the algorithm in order to form the cipher text.

ofb
Stream Cipher Encryption in Output Feedback (OFB) Mode

Counter Mode

All the above modes were used in a pre-AES time. Except for the ECB mode, they all involve feedback, which is comparatively insecure and performance delay are observed. Therefore, a new type of mode was proposed, which is termed the counter mode. In this mode, a counter is encrypted to generate a key stream, which is simply XORed with the plain text in order to generate the cipher text. The advantage of counter mode is that there is no feedback or chaining. The following Figure presents the block diagram for the Counter (CTR) mode.

ctr
Stream Cipher Encryption in Counter (CTR) Mode

--NEXT--> Selection of Algorithm