Chapter 2
Symmetric Encryption
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 1
What is a Block Cipher?
A block cipher is a type of encryption algorithm that processes data
in fixed-size chunks called blocks. It transforms a plaintext block of a
specific size into a ciphertext block of the same size using a secret key.
Block ciphers are widely used in cryptography for securing data in
various applications, such as data transmission, file encryption, and
securing communication protocols.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 3
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 4
What is a Stream Cipher?
This method of encryption works bit-by-bit, utilizing keystreams to generate ciphertext for arbitrary lengths of plain text
messages. The cipher combines a key (128/256 bits) and a nonce digit (64-128 bits) in order to generate the keystream
- a pseudorandom number XORed with the plaintext to generate the ciphertext.
The keystream must be different for each encryption iteration even though the key and nonce can be reused to
maintain security. In order to build the keystream, stream encryption ciphers generate a unique nonce (a number used
only once utilizing feedback shift registers.
Since a mistake in the translation of one bit often does not affect the entire plaintext block, stream cipher encryption
algorithms are less likely to cause system-wide errors to spread. Additionally, stream encryption is linear and
continuous, making it easier and quicker to deploy.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 5
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 6
Key Features of Block Ciphers:
v Fixed Block Size:
Operates on fixed-size blocks, e.g., 64-bit, 128-bit, or 256-bit. If the input data is larger or
smaller than the block size, it may need padding or splitting.
v Key Dependency:
The encryption and decryption processes depend on a secret key, making the ciphertext
secure as long as the key remains secret.
v Reversible Process:
Decryption reverses the encryption process to retrieve the original plaintext using the
same key.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 7
Examples of Block Ciphers
•AES (Advanced Encryption Standard): Widely used, with block sizes of 128 bits.
•DES (Data Encryption Standard): An older standard with 64-bit block size, now
considered insecure.
•3DES (Triple DES): A more secure version of DES.
•Blowfish, Twofish, and RC5: Other examples of block ciphers.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 8
Modes of Operation:
To encrypt larger messages, block ciphers use modes of operation, such as:
•ECB (Electronic Codebook): Encrypts each block independently (vulnerable to pattern
detection).
•CBC (Cipher Block Chaining): Each plaintext block is XORed with the previous
ciphertext block, making it more secure.
•CFB (Cipher Feedback) and OFB (Output Feedback): Turn block ciphers into stream
ciphers.
•CTR (Counter Mode): Uses a counter for encryption, providing parallelizability and
improved performance.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 9
1. ECB (Electronic Codebook)
ECB (Electronic Codebook) is the simplest mode of operation for block ciphers. It divides
plaintext into fixed-size blocks and encrypts each block independently using the same key. While
easy to implement, ECB is rarely used in practice due to its significant security weaknesses.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 10
How ECB
Works?
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 11
How ECB
Works?
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 12
How
ECB
Works?
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 13
How
ECB
Works?
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 14
How
ECB
Works?
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 15
2. Cipher Block Chaining (CBC)
Cipher Block Chaining (CBC) is a mode of operation for block ciphers that improves
security by introducing dependency between blocks. Unlike the simpler ECB mode, CBC ensures
that the encryption of one block depends on the encryption of the previous block, making it
resistant to pattern detection.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 16
How CBC
Works
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 17
How CBC
Works
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 18
How CBC
Works
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 19
Advantages
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 20
Disadvantag
es
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 21
3. Cipher Feedback (CFB)
Cipher Feedback (CFB) is a mode of operation for block ciphers that turns them into stream
ciphers. It processes plaintext in smaller chunks than the block size (often bits or bytes) and
incorporates feedback from the ciphertext into the encryption process. This feedback introduces
dependency between blocks, improving security.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 22
How CFB
Works?
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 23
How CFB
Works?
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 24
Advantages
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 25
Disadvantag
es
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 26
4. Output Feedback (OFB)
Output Feedback (OFB) is a mode of operation for block ciphers that transforms a block
cipher into a stream cipher, similar to CFB. However, unlike CFB, the feedback in OFB comes
from the cipher's output rather than the ciphertext. This eliminates error propagation and
makes it suitable for applications requiring high error tolerance.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 27
How it
Works?
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 28
How it
Works?
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 29
Advantages
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 30
Disadvantag
es
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 31
5. Counter Mode
Counter Mode (CTR) is a mode of operation for block ciphers that
transforms them into a stream cipher. It is widely used because of its
efficiency, parallelizability, and ability to handle plaintext of any length. In
CTR mode, encryption and decryption are based on a counter value that
is incremented for each block of plaintext or ciphertext.
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 32
Counter
Mode
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 33
How Counter
Mode Works?
CTR mode works by generating a
keystream from the block cipher
and a counter, then XORing the
keystream with the plaintext to
produce ciphertext (or with
ciphertext to recover plaintext).
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 34
Counter
Mode
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 35
Counter
Mode
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 36
Feistel Cipher
Structure
3/9/25 PROF. SRIDHAR IYER, DJSCE, MUMBAI 37
Feistel Cipher
PROF. SRIDHAR IYER, DJSCE, MUMBAI 3/9/25 38
The Feistel Cipher
The modern block cipher was invented by Horst Feistel, around 1973. At the time, he
was working for IBM.
◦ Based on the concept of a product cipher, which uses two or more basic ciphers in sequence in
such a way that the combined result is cryptographically stronger than any of the component
ciphers.
◦ In particular, Feistel proposed a cipher that alternates substitutions and permutations. This
is a practical implementation of Shannon's confusion and diffusion principles.
◦ So successful are diffusion and confusion, that they have become the cornerstone of modern
block cipher design.
39
The Feistel Network
A plaintext block of
The inputs to a Feistel length n bits (n is even)
Network are: A key K of m bits
The two halves pass
through n rounds of
The plaintext is divided processing, and finally
into 2 parts, L and R combine to produce the
ciphertext.
The key, K, is used to
The subkeys are distinct
generate n subkeys, Ki, from each other and
each of which is used in a from the original key, K.
round
40
The Feistel Network
A Feistel Network is an iterated block cipher, where the output of the ith round is
determined from the output of the (i-1)th round:
%" = $" !6
$" = %" !6 " ! 5 $" !6 / # " 4
(((((((301)1(# " (&.(%01(.",21-(".1*(&#(%01("%0()'"#*/(
+#*
(((((( ! (&.(+#(+),&%)+)-()'"#*(!"#$%&'#
Because XOR is used to combine the left half with the output of the round function, the
operation is reversible:
"! !! " % $ $! !! # #! " " % $ $! !! # #! " = "! !!
41
Example
The Feistel Network
Implementations of a Feistel Network depend on a number of parameters:
◦ Block size
◦ Larger block sizes provide greater security, but reduced performance.
◦ Block sizes of 64 bits or, more recently, 128 bits are reasonable
The Feistel
◦ Key size
◦ Larger key sizes provide greater security, but may reduce performance
Network
◦ Key sizes of 64 bits are now considered to be inadequate;
128 bits is now more common; 256 bits is better.
◦ Number of rounds
◦ The more rounds, the more security
◦ 16 rounds is typical
◦ Subkey generation
◦ More complexity in how subkeys are generated from the input key provides
greater security
◦ Round function
◦ Greater complexity yields greater resistance to cryptanalysis
43