7. DES Algorithm(9)
7. DES Algorithm(9)
1
Modern Symmetric-key Ciphers:
Plaintext : 10011011110100001
Keystream : 10101010101010101
Ciphertext : 00110001011110100 (by XORing each plaintext bit with corresponding keystream bit)
3
Block Ciphers:
Example
Plaintext : The only thing we have to fear is fear itself
Modified plaintext : Theonlythingwehavetofearisfearitself
Plaintext blocks : Theonlyt hingweha vetofear isfearit selfXend (break the plaintext into 8-character block)
Ciphertext blocks : tylnoehT ahewgnih raefotev tiraefsi dneXfles (just reverse each plaintext block)
Ciphertext : tylnoehTahewgnihraefotevtiraefsidneXfles
4
Components of a Modern Block Ciphers:
5
Components of a Modern Block Ciphers (continued…):
P-Boxes:
A P-box (permutation box) is a component in a modern block cipher
that transposes bits.
Types of P-Boxes:
Three types of P-boxes are used in modern block ciphers:
(1) Straight P-Boxes
6
Components of a Modern Block Ciphers (continued…):
Straight P-Boxes:
A straight P-Box is a permutation which has n inputs and n outputs.
There are n! possible mappings.
Figure below shows a 5 x 5 straight P-box.
Compression P-Boxes:
A compression P-box is a P-box with n inputs and m outputs where m<n.
Some of the inputs are blocked and do not reach the output.
Figure below shows a 5 x 3 compression P-box.
Expansion P-Boxes:
A expansion P-box is a P-box with n inputs and m outputs where m>n.
Some of the inputs are connected to more than one output.
Figure below shows a 3 x 5 expansion P-box.
The expansion P-boxes used in modem block ciphers normally are keyless,
where a permutation table shows the rules for transposing bits.
Expansion P-boxes are used when we need to permute bits and the same
time increase the number of bits for the next stage of
encryption/decryption.
9
Components of a Modern Block Ciphers (continued…):
S-Boxes:
An S-box (substitution box) can be thought of as a miniature
substitution cipher.
However, an S-box can have a different number of inputs and outputs.
In other words, the input to an S-box could be an n-bit word, but the
output can be an m-bit word, where m and n are not necessarily the
same.
Although an S-box can be keyed or keyless, modern block ciphers
normally use keyless S-boxes, where the mapping from the inputs to
the outputs is predetermined.
10
Components of a Modern Block Ciphers (continued…):
Input-Output Relationship for a 3x2 S-Box by Table:
The following table defines the input/output relationship for an S-box of
size 3 × 2.
The leftmost bit of the input defines the row; the two rightmost bits of the
input define the column.
The two output bits are values on the cross section of the selected row and
column.
Based on the above S-box table, an input of 010 yields the output 01. An
input of 101 yields the output of 00.
11
Components of a Modern Block Ciphers (continued…):
Kinds of Product Ciphers:
Modern block ciphers are all product ciphers, but they are divided into two
classes:
❑ Feistel ciphers
❑ Non-Feistel ciphers
❑ Feistel ciphers:
❖ In 1973, Feistel designed a very intelligent and interesting cipher that
has been used for decades. Several block ciphers are based on the
Feistel structure.
❖ This type of ciphers use both invertible and noninvertible components.
❖ A Feistel cipher can have three types of components: self-invertible,
invertible, and noninvertible.
❖ A Feistel cipher combines all noninvertible elements in a unit (called
mixer) and uses the same unit in the encryption and decryption
algorithms.
❖ The block cipher DES, IDEA, RC5 (Rivest’s Cipher) are good examples
of a Feistel cipher. But Feistel design is not used in AES.
12
Components of a Modern Block Ciphers (continued…):
❑ Non-Feistel ciphers:
This type of ciphers use only invertible components.
A component in the encryption cipher has the corresponding
component in the decryption cipher.
For example, S-boxes need to have an equal number of inputs and
outputs to be compatible. No compression or expansion P-boxes are
allowed, because they are not invertible.
❖ In a non-Feistel cipher, there is no need to divide the plaintext into two
halves as we saw in the Feistel ciphers.
❖ The block cipher AES is a good example of a non-Feistel cipher.
13
Confusion and Diffusion:
The terms diffusion and confusion were introduced by Claude Shannon to
capture the two basic building blocks for product cipher.
Every block cipher involves a transformation of a block of plaintext into a block
of ciphertext, where the transformation depends on the key.
Hence, the block cipher needs to completely obscure statistical properties of
original message.
Shannon suggested combining S & P elements to obtain diffusion and
confusion.
❑ Diffusion (Substitution):
❖ The idea of diffusion is to hide the relationship between the ciphertext and
the plaintext. That is, the statistical relationship between the plaintext and
ciphertext is made as complex as possible in order to thwart attempts to
deduce the key. This will frustrate the adversary who uses ciphertext
statistics to find the plaintext.
❖ Diffusion implies that each symbol (bit) in the ciphertext is dependent on
some or all symbols in the plaintext. In other words, if a single symbol in
the plaintext is changed, several or all symbols in the ciphertext will also
be changed.
❑ Confusion(Transposition):
❖ The idea of confusion is to hide the relationship between the ciphertext
and the key. That is, the relationship between the ciphertext and the key
is made as complex as possible in order to thwart attempts to discover the
key. This will frustrate the adversary who tries to use the ciphertext to
find the key.
❖ In other words, if a single bit in the key is changed, most or all bits in the 14
ciphertext will also be changed.
Brief History of Data Encryption Standard (DES)
The Data Encryption Standard (DES) is a symmetric-key block cipher published
by the National Institute of Standards and Technology (NIST).
❑ In 1973, NIST published a request for proposals for a national symmetric-key
cryptosystem.
❑ A proposal from IBM, a modification of a research project called Lucifer, was accepted as
DES.
❑ DES was published in the Federal Register in March 1975 as a draft of the Federal
Information Processing Standard (FIPS).
❑ After the publication, IBM sought technical advice from the National Security Agency
(NSA) for the modification of Lucifer.
The modified version of LUCIFER was put forward as a proposal for the new
national encryption standard requested by the National Bureau of Standards
(NBS, now known as the National Institute of Standards and Technology,
NIST). It was finally adopted in 1977 as the Data Encryption Standard -DES
(FIPS PUB 46).
Some of the changes made to LUCIFER have been the subject of much
controversy even to the present day for two reasons:
❑ First, the critics questioned the small key length (only 56 bits) which could make
the cipher vulnerable to brute-force attack. Even though DES actually accepts a 64
bit key as input, the remaining eight bits are used for parity checking and have no
effect on DES’s security.
❑ Second, critics were concerned about some hidden design behind the internal
structure of DES. They were suspicious that some part of the structure (e.g. the
S-boxes) may have some hidden trapdoor that would allow the NSA to decrypt the
message without the need for the key.
15
Overview of DES
16
• DES uses a 56-bit key.
• Actually, the initial key consists of 64 bits.
• However, before the DES process even starts, every 8th bit
DES Structure 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.
17
DES Structure
• DES is based on the two fundamental attributes of cryptography: 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.
• In the first step, the 64-bit plain text block is handed over to an initial Permutation (IP) function.
• Next, the initial permutation (IP) produces two halves of the permuted block; saying Left Plain Text (L 0) and Right Plain Text
(R0).
• In the end, L0 and R0 are rejoined and a Final Permutation (FP) is performed on the combined block
18
Initial Permutation(IP)
• The initial permutation (IP) happens only once
and it happens before the first round.
• It suggests how the transposition in IP should
proceed, as shown in the figure.
• For example, it says that the IP replaces the
first bit of the original plain text block with the
58th bit of the original plain text, the second bit
with the 50th bit of the original plain text
block, and so on.
• This is nothing but jugglery of bit positions of
the original plain text block. the same rule
applies to all the other bit positions shown in
the figure.
19
• After IP is done, the resulting 64-bit
permuted text block is divided into two half
blocks.
• Each half-block consists of 32 bits, and
each of the 16 rounds, in turn, consists of
the broad-level steps outlined in the figure.
•
20
Key Transformation
• Initial 64-bit key is transformed into a 56-bit key by
discarding every 8th bit of the initial key.
• Thus, for each a 56-bit key is available.
• From this 56-bit key, a different 48-bit Sub Key is
generated during each round using a process called
key transformation.
• For this, the 56-bit key is divided into two halves,
each of 28 bits.
• These halves are circularly shifted left by one or two
positions, depending on the round.
• For example: if the round numbers 1, 2, 9, or 16 the
shift is done by only one position for other rounds,
the circular shift is done by two positions.
21
Key Transformation(Cont..)
• After an appropriate shift, 48 of the 56 bits are
selected.
• For selecting 48 of the 56 bits the table is shown in
the figure .
• For instance, after the shift, bit number 14 moves to
the first position, bit number 17 moves to the second
position, and so on.
• If we observe the table , we will realize that it
contains only 48-bit positions.
• Bit number 18 is discarded (we will not find it in the
table), like 7 others, to reduce a 56-bit key to a 48-bit
key.
• Since the key transformation process involves
permutation as well as a selection of a 48-bit subset
of the original 56-bit key it is called Compression
Permutation.
22
Expansion P-Box Permutation
• Recall that after the initial permutation, we had
two 32-bit plain text areas called Left Plain
Text(L0) and Right Plain Text(R0).
• During the expansion permutation, the R0 is
expanded from 32 bits to 48 bits.
• Bits are permuted as well hence called
expansion permutation.
• This happens as the 32-bit R0 is divided into 8
blocks, with each block consisting of 4 bits.
• Then, each 4-bit block of the previous step is
then expanded to a corresponding 6-bit block,
i.e., per 4-bit block, 2 more bits are added.
23
Expansion P-Box
Permutation
24
Overall Process discussed so far
• The key transformation process compresses the 56-bit key to 48 bits.
• Then the expansion permutation process expands the 32-bit
R0 to 48-bits.
• Now the 48-bit key is XOR with 48-bit R0 and the resulting output is
given to the next step, which is the S-Box substitution.
25
DES Rounds:
In DES, substitution and permutation are used a number of times in
iterations called rounds. Generally, the more rounds there are, the
more secure the algorithm is.
DES uses 16 rounds. Each round of DES is a Feistel cipher.
27
Figure: DES function
DES Round Function f(Ri-1,Ki):
Whitener (Exclusive-or):
After the expansion permutation, DES uses the XOR operation on the
expanded right section and the round key.
❑ Note that both the right section and the key are 48-bits in length. Also
note that the round key is used only in this operation.
Figure: Whitener
28
The S-boxes (substitute 48 bits to
32 bits):
In DES, a non-linearity is introduced into the encryption so that decryption will be
computationally infeasible without the secret key.
This is achieved with the use of S-boxes . which are basically non-linear substitution tables
where either the output is smaller than the input or vice versa.
❖ The S-boxes are the only non-linear operation in DES that do the real
mixing (confusion).
DES uses 8 S-boxes, each with a 6-bit input and a 4-bit output, that is it
accepts a 48-bit input and produces 32-bit number as output (defined in
tables).
❖ The resulting 48 bits from XOR operation are divided into eight 6-bit
chunks, each of which is fed into an S-Box that mixes the bits and
produces a 4-bit output (The 8 S-boxes are shown in table).
❖ Those 4-bit outputs are combined into a 32-bit value.
❖ The first and last bits of the 6-bit input of each S-box determine which
column permutation is used. It provides non-linearity (confusion).
29
30
31
32
DES Round Function f(Ri-1,Ki):
4. Straight Permutation (P-box):
The combined 32 bits from the previous step are permuted once
again to produce the 32 bits output of the f-function using expansion
P-box table (Shown in Table-4).
34
DES Algorithm/DES Structure/ Encryption of the DES (continued…) :
❑ The output found using key ki after ith round is represented by Li and Ri
respectively where i=1, 2, 3, …..,16.
❑ Round i has input Li-1||Ri-1 and output Li||Ri where
❖ Li=Ri-1
❖ Ri=Li-1 ⌖ f(Ri-1,ki)
❑ In the final round, the left (L) and right (R) halves are swapped,
so that the decryption algorithm has the same structure as the
encryption algorithm.
❑ After the final round (16th round), the right and left halves are joined or
concatenated.
❑ Then, a final permutation IP-1 (which is the inverse of the initial
permutation ), is applied to the 64-bit joining block.
❑ The output of this final permutation is the 64 bit encrypted output
(ciphertext).
35
DES Algorithm/DES Structure/ Encryption of the DES (continued…) :
38