Chapter-3-Block Cipher
Chapter-3-Block Cipher
Data Encryption
Standard
Dr Savitha G
Dr Girisha S
Dr Ashutosh Holla B
Stream Cipher
➢A stream cipher is one that encrypts a digital data stream one bit or one byte
at a time
➢ Keystream Generation: A pseudorandom keystream is generated based on a
secret key. This keystream should appear random and not repeat
➢ Thekeystream must be provided to both users in advance via some independent
and secure channel
➢ Thisintroduces insurmountable logistical problems if the intended data traffic is
very large
➢ Forpractical reasons, the bit-stream generator must be implemented as an
algorithmic procedure, so that the cryptographic bit stream can be produced by
both users
Bit-stream generator
• A bit-stream generator is a component or algorithm used in cryptography
(and other domains) to produce a sequence of binary digits (bits).
The bit-stream generator is a key-controlled algorithm and must produce a bit
stream that is cryptographically strong
Decryption
Reverses the process: Plaintext = Ciphertext ⊕ Keystream
Block Cipher
➢A block cipher is one in which a block of plaintext is treated as a whole and used to
produce a ciphertext block of equal length.
➢ Typically,
a block size of 64 or 128 bits is used. As with a stream cipher the two
users share a symmetric encryption key
➢ Unlike stream ciphers that encrypt data bit by bit, block ciphers process entire
blocks of data at a time, making them suitable for structured data.
➢ Common sizes are 64 bits (e.g., DES) and 128 bits (e.g., AES).
➢ The plaintext is divided into blocks, and each block is encrypted separately.
➢ If the plaintext is smaller than the block size, padding is added.
Encryption and Decryption
Operates using a secret key to transform plaintext blocks into ciphertext blocks.
The same key is used for both encryption and decryption (symmetric encryption).
Stream cipher and Block Cipher
• Two basic building blocks for any cryptographic system
➢ Confusion:
▪ Making the relationship between encryption key and the cipher text as complex as possible.
▪ Thus, even if the attacker can get some handle on the statistics of the ciphertext, the way in which the
key was used to produce that ciphertext is so complex as to make it difficult to deduce the key. This is
achieved by the use of a complex substitution algorithm.
▪ Ex: substitution
➢ Diffusion:
▪ Making each plaintext bit affect as many CT bits as
possible
▪ One bit change in PT has significant change in CT. This is
equivalent to having each ciphertext digit be affected by many
plaintext digits
▪ An example of diffusion is to encrypt a message 𝑀 =
𝑚1 , 𝑚2 , 𝑚3 , … of characters with an averaging operation:
▪ Ex: permutation or transposition
Stream cipher and Block Cipher
• Plain Text =“HELLO”
• Convert each letter to its numerical equivalent (A=0, B=1, ..., Z=25):
• H=7,E=4,L=11,L=11,O=14.
• So, the plaintext is M={7,4,11,11,14}.
• K=2, meaning each ciphertext character 𝑦𝑛 is influenced by 2
subsequent plaintext characters.
Stream cipher and Block Cipher
• For 𝒚𝟏 (first ciphertext character):
• 𝑦1 = 𝑚2 + 𝑚3 𝑚𝑜𝑑 26 = 4 + 11 𝑚𝑜𝑑 26 = 15
• The cipher text corresponding to the value 15 is ‘P’
• Rearranging terms:
• Thus, we have described the inputs to the ith iteration as a function of the
outputs, and these equations confirm the assignments shown in the right-
hand side of Figure
• Finally, the output of the last round of the decryption process is RE0 ||LE0.
• A 32-bit swap recovers the original plaintext, demonstrating the validity of
the Feistel decryption process
Feistel Cipher Structure
➢A Feistel network depends on the choice of the following parameters and
design features:
➢ Block size:
▪ Larger block sizes mean greater security but reduced encryption/decryption
speed for a given algorithm.
▪ The greater security is achieved by greater diffusion
▪ Traditionally, a block size of 64 bits has been considered a reasonable tradeoff
and was nearly universal in block cipher design
▪ However, the new AES uses a 128-bit block size.
➢ Key Size:
▪ Larger key size means greater security but may decrease encryption/
decryption speed
▪ The greater security is achieved by greater resistance to brute-force attacks
and greater confusion
▪ Key sizes of 64 bits or less are now widely considered to be inadequate, and 128
bits has become a common size.
Feistel Cipher Structure
➢ Number of rounds:
▪ Multiple rounds offer increasing security. Typical is 16 rounds as a single
round provide inadequate security.
➢ Round function F:
▪ Greater complexity generally means greater resistance to cryptanalysis.
Feistel Cipher Structure
Data Encryption Standard (DES)
➢ Symmetric block cipher
➢ Most widely used block cipher in world
➢ Adoptedin 1977 by National Bureau of Standards (NBS), now the
National Institute of Standards and Technology (NIST)
➢ Encrypts 64-bit data using 56-bit key
➢ Has widespread use
➢ The algorithm transforms 64-bit input in a series of steps into a 64-
bit output. The same steps, with the same key, are used to reverse
the encryption
Data Encryption Standard (Des)
• Follows Feistel structure
• Block size = 64 bits of plain text
• No of rounds = 16 rounds
• Key size = 56 bits
• No of subkeys = 16 subkeys (16 rounds)
• Sub key size = 48 bits
• Cipher text size = 64 bits
Data Encryption Standard (Des)
Data Encryption Standard (Des)
Data Encryption Standard (Des)
Key Generation
• DES uses a 56-bit key. Actually, The initial key consists of 64 bits.
• However, before the DES process even starts, every 8th bit of the key is discarded
to produce a 56-bit key. That is bit positions 8, 16, 24, 32, 40, 48, 56, and 64 are
discarded.
• Thus, the discarding of every 8th bit of the key produces a 56-bit key from the
original 64-bit key.
Data Encryption Standard (DES)
• DES is based on two fundamental attributes:
substitution (also called confusion) and
transposition (also called diffusion).
• DES consists of 16 steps, each of which is called a round. Each round performs
the steps of substitution and transposition.
Data Encryption Standard (DES)
DES Basic steps:
• First, the 64-bit plaintext passes through an initial permutation (IP) that rearranges
the bits to produce the permuted input
• The initial permutation is performed on plain text.
• Next, the initial permutation (IP) produces two halves of the permuted block; saying
Left Plain Text (LH) and Right Plain Text (RH).
• This is followed by a phase consisting of sixteen rounds of the same function, which
involves both permutation and substitution functions.
• The left and right halves of the output are swapped to produce the preoutput.
• Finally, the preoutput is passed through a permutation [IP-1 ] that is the inverse of
the initial permutation function, to produce the 64-bit ciphertext.
• With the exception of the initial and final permutations, DES has the exact structure
of a Feistel cipher
Data Encryption Standard (Des)
Data Encryption Standard (Des)
How DES works?
• Initial Permutation (IP)
The 64-bit plaintext is permuted according to a predefined table.
• Ciphertext Output
The final 64-bit output is the encrypted ciphertext.
Key Generation
• The initial 64-bit key, which you can choose randomly, is transformed into a 56-bit key by
discarding every 8th bit.
• This process reduces the key to 56 bits, which is then divided into two 28-bit halves.
• In DES, each of the 16 rounds uses a different 48-bit sub-key derived from the original 56-bit key.
This process adds complexity and ensures that the encryption is secure.
Round Shifts
Key Generation
1 1
2 1
3 2
• 48-bit key generation process for each round
4 2
• Splitting into Halves:
5 2
Round 1: 13 2
14 2
•Shift C0 and D0 left by 1 position.
•C1: 00100100 11010010 10110111 1000 15 2
3 28 15 6 21 10
23 19 12 4 26 8
16 7 27 20 13 2
41 52 31 37 47 55
30 40 51 45 33 48
44 49 39 56 34 53
46 42 50 36 29 32
Key Generation
• Assume the combined 56-bit key after shifting for round 1 is:
• After getting the final result from the right half, we need to perform an XOR
operation of the left and right half.
Data Encryption Standard (Des)
Expansion Permutation (E)
• The 32-bit right half (R0) is expanded to 48 bits using
the expansion table. Here, each bit is substituted with
the one given at the respected position in the table. The
32 1 2 3 4 5
expansion table duplicates certain bits to increase the
size from 32 to 48 bits 4 5 6 7 8 9
• Expansion Table: 8 9 10 11 12 13
• Apply the expansion permutation on R0: 12 13 14 15 16 17
• R0 (32 bits): 10101010 10101010 10101010 10101010 16 17 18 19 20 21
• Expanded R0 (48 bits): 01010101 01011010 10100101 20 21 22 23 24 25
01101010 01011010 10101010
24 25 26 27 28 29
28 29 30 31 32 1
Key Mixing (⊕)
• The expanded R0 is XORed with the round key (48-bit). Using the example
from the previous step, our round key for Round 1 is:
16 7 20 21 29 12 28 17 16
1 15 23 26 5 18 31 10 1
2 8 24 14 32 27 3 9 2
19 13 30 6 22 11 4 25 19