Module 2 DES
Module 2 DES
Schemes: DES
Dr. Renu Mary Daniel
Assistant Professor
Department of CSE-Cyber Security
IIIT, Kottayam
Symmetric key cryptography
XY9
Eve 8@!
#%
Will
Will
meet at
Alice Bob meet at
DXC
DXC XY9
8@!
#%
2
Cryptanalysis
• Brute force: Try every key
• Ciphertext-only attack:
• Attacker knows the ciphertext of several messages encrypted with the same
key.
• Possible to recover plaintext (also possible to deduce the key) by looking at
the frequency of letters.
• Ciphertext Only attack on Caesar Cipher:
• Ciphertext: ZHOFRPH WR WKH FLSKHU FODVV
• Most common trigram in English: THE
• Digrams: TO, IS, IN, HE
• Attacker gets the key!!!
Cryptanalysis Example
• Known-plaintext attack:
• Attacker observes pairs of plaintext/ciphertext encrypted with the same key.
• Possible to deduce the key and/or devise algorithm to decrypt the ciphertext.
1 1 1 0 0
Claude Shannon
• Proposed the idea of confusion and
diffusion.
• Year: 1945
• Complexity is implemented through
a well-defined and repeatable series
of substitutions and permutations.
Plain Text Encoding
• Each character in the plaintext "Hello Mike" is represented by a single byte in the ASCII encoding,
where 1 byte equals 8 bits.
Padding of Plain text
• Block Size: DES operates on blocks of 64 bits (which is 8 bytes).
• This means that the input plaintext must be in multiples of 8 bytes.
• Example:
• Plaintext: "Hello Mike" (10 characters)
• Length: 10 bytes (since each character is 1 byte).
• Padding Required: 16 bytes (next multiple of 8) - 10 bytes (original
length) = 6 bytes of padding.
• Padding Value: In PKCS#7 padding, if 6 bytes are added, each byte will be 0x06
in hexadecimal.
• Original Plaintext: "Hello Mike" (10 bytes)
• Padded Plaintext: "Hello Mike\x06\x06\x06\x06\x06\x06" (16 bytes)
Block Cipher Modes of Operation
• A block cipher operates on fixed-size blocks (e.g., 64 bits in DES, 128 bits in
AES).
• But most real-world data is longer or shorter than a single block.
• Modes of operation allow block ciphers to handle data of any length by
processing multiple blocks or padding the last block if necessary.
• Types:
• Electronic Code Book
• Cipher Feedback
• Cipher Block Chaining
• Output Feedback
• Counter
Electronic Code Book (ECB)
• Plaintext is handled one block at a
time and each block of plaintext is
encrypted using the same key.
• The most significant characteristic
of ECB is that if the same b-bit
block of plaintext appears more
than once in the message, it
always produces the same
ciphertext.
• For lengthy messages, the ECB
mode may not be secure.
ECB-Penguin
• Identical plaintext blocks produce identical ciphertext blocks, which can leak patterns and make it less secure for
many applications.
Cipher Block Chaining
P1 IV
(P1 IV)
(P1 IV IV)
(b) Decryption
Feistel Structure (1970)
R L
K2
F
N such rounds
K1
F
L R
Data Encryption Standard
• Symmetric Block Cipher.
• Implementation of Feistel Structure.
• Plaintext block size = 64 bits.
• Ciphertext block size = 64 bits.
• Main key = 64 bits
• Sub key = 56 bits
• Size of the round key = 48 bits
• No: of rounds = 16 rounds.
• DES is replaced by the Advanced Encryption Standard in 2001.
Putting it all together
• Step 1 (Block Division):
• First, divide the plaintext into 64-bit blocks (the block size of DES).
• Step 2 (Padding):
• If necessary, pad the final block to make it 64 bits.
• Step 3 (Encryption Using DES):
• Apply DES (which uses the Feistel structure) to each block individually.
• DES will use its Feistel network to process each 64-bit block.
• Step 4: CBC Mode Application:
• In CBC mode, the encryption of each block is dependent on the previous ciphertext block.
• The first block is XORed with an initialization vector (IV).
• The subsequent blocks are XORed with the previous ciphertext block before being
encrypted by DES.
General Structure of DES
64 bit
• Major characteristics:
• Round function 64 bit
• Key schedule
• Initial and final permutation
64 bit
Initial and Final Permutation
• Permutation (or
Transposition):
• This operation changes
the order of bits
according to a
predefined pattern.
• No bits are changed in
value; only their
positions are shuffled.
• The initial and final
permutations are
straight Permutation
boxes (P-boxes) that are
inverses of each other.
Round Function
• The heart of this cipher is
the DES function, f.
• The DES function applies a
48-bit key to the rightmost
32 bits to produce a 32-bit
output.
L (32 bits) R (32 bits)
Round Function F
K1 (48 bits)
• Expansion Permutation
Box −
• Since right input is 32-bit
and round key is a 48-bit,
we first need to expand
right input to 48 bits.
• Permutation logic is
graphically depicted in the
following illustration:
Round Function (cont..)
• XOR −
• After the expansion permutation, DES does XOR operation on the expanded
right section and the round key.
• The round key is used only in this operation.
• Substitution Boxes. −
• The S-boxes carry out the real mixing (confusion).
• DES uses 8 S-boxes, each with a 6-bit input and a 4-bit output.
• Refer the following illustration −
S-Boxes in Round Function
• The key is first subjected to a permutation governed by a table labeled Permuted Choice One
Shift left Operation
• In this shift operation each bit in the register is shifted to the left
one by one.
• After shifting, the LSB becomes empty, so the value of the MSB
is filled in there.
Key Generation
• The resulting 56-bit key is then treated
as two 28-bit quantities and labeled .
• At each round, and are separately
subjected to a circular left shift or
(rotation) of 1 or 2 bits (as per table d).
• These shifted values serve as input to
the next round.
• They also serve as input to the part
labeled Permuted Choice Two (Table
c), which produces a 48-bit output.
Key Expansion in AES
• Key in Text – ‘command’