Block cipher is a structure which considers block of plaintext as a whole and produces a ciphertext of equal length. Typically, it uses block size of 64 bit or 128 bits.
For instance, DES or AES, Triple DES, Feistel Cipher are examples of block cipher.
Moreover, to apply a block cipher to a variety of applications, it uses five modes of operations. Let’s take a look at these modes.
- Electronic Code Book (ECB)
- Cipher Block Chaining (CBC)
- Cipher Feedback (CFB)
- Output Feedback (OFB)
- Counter (CTR)
Working of Block Cipher Modes
Electronic Code Book
Firstly, in ECB Mode plaintext handles one block at a time and same key is used to encrypt each block of plaintext. In addition, the term code book means for given key, there is unique ciphertext for every b bit block of plaintext.
It is useful in secure transmission of short pieces of information. For instance, temporary encryption key.
Moreover, this mode has some weaknesses. If repetitive elements are there, analyst can easily identify them.
Cipher Block Chaining
CBC is a technique in which if plaintext block repeats itself, it produces different ciphertext blocks. In addition, in this technique, input to the encryption algorithms is XOR of current plaintext block and preceding ciphertext block.
Each block uses same key. Moreover, to produce first block of ciphertext, an Initialization Vector (IV) is XOR with first block of plaintext.
On decryption, this IV is XOR’ed with output of decryption algorithm to recover plaintext block.
It is useful in authentication and general purpose block oriented transmission. Similarly, because of chaining mechanism, it is appropriate for larger length of messages.
Cipher Feedback Mode
In CFB, the leftmost significant s bits of output of encryption function are XOR with the first segment of plaintext. It produces plaintext P1 to produce the first unit of ciphertext C1.
Moreover, the b bit shift register is initially set to some value of IV.
For decryption, resultant ciphertext unit is XOR with output of encryption function to produce plaintext unit.
Output Feedback Mode
In OFB, the output of the encryption function passes to input for encryption of the next block of plaintext. Moreover, OFB mode operates on full blocks of plaintext and ciphertext.
In OFB encryption, each bit in ciphertext is independent of the previous bits. This avoids error propagation.
Nonce : A time varying value that has at most a negligible chance of repeating. For instance, a random value, a time stamp etc.
Counter Mode
Firstly, CTR uses a counter equal to the length of plaintext block. The counter value is different for each plaintext block. Typically, counter is set to some value and then incremented by 1 for each subsequent block.
Moreover, one main advantage of using CTR is that encryption and decryption can be done in parallel. It is also fastest.
Comparision table of block cipher modes
Operation Mode | Description | Type of Result |
ECB | Each n-bit encryption independently with same key | Block Cipher |
CBC | Similar to ECB but each block XOR with previous ciphertext | Block Cipher |
CFB | Each s-bit block XOR with s-bit key that is part of previous ciphertext | Stream Cipher |
OFB | Similar to CFB but shift register is updated by previous s-bit key | Stream Cipher |
CTR | Similar to OFB but a counter is used instead of nonce | Stream Cipher |
Summary
In conclusion, we have seen all five modes of operation in block cipher. Moreover, we have learnt about its application and its comparision.