Upload
khurram-hashmi
View
216
Download
0
Embed Size (px)
Citation preview
8/3/2019 DESpseodo Code Intro.
1/17
DATA ENCRYPTION
STANDARD(DES)
by Engr. Khurram Hashmi
8/3/2019 DESpseodo Code Intro.
2/17
Sequence
Cryptography
Block Ciphers
DES
Encryption Algorithm
Feistel Function
Pseudo Code
8/3/2019 DESpseodo Code Intro.
3/17
Cryptography
8/3/2019 DESpseodo Code Intro.
4/17
Block Ciphers
Block ofplain Text
Size: (M)
CipherEncryption
Algorithm
Block ofcipher Text
Size : (M)
Secret key
8/3/2019 DESpseodo Code Intro.
5/17
Data Encryption Standard
It is a block Cipher
Data is encrypted block by block i.e. 64 bits each
time
plain Text64 bit blocks
CipherEncryptionAlgorithm
16 cycles
Cipher Text64 bit blocks
Secret key64 bits
N Blocks N Blocks
56 bits used
8/3/2019 DESpseodo Code Intro.
6/17
Block Division
Divides the Data into N blocks of 64 bit length
Block _size = 64 bit
Assuming that each location in an array stores 1 bit
Input>> input_data [any length ]
Loop: (count bits: 0 to data end)
Initialize: N=0, until all data stored
{
Loop: (count bits: 0 to 63),
initialize: i=0, until : i=63
{
Input_data_block N [ i]= Input_ data[ i]
Increment : i
}
Increment: N a number of blocks
}
128 bit
64 bit 64 bit
8/3/2019 DESpseodo Code Intro.
7/17
Encryption Algorithm
Data is processed as 32 bithalf-blocks
Takes 16 rounds to complete
In each round, a new sub-key from the key schedulerisutilized
Data is swapped after each
round except the last Initial and final permutations
are Inverses of each other
48 bitSub-key
48 bitSub-key
32bit32bit
32bit32bit
XOR
8/3/2019 DESpseodo Code Intro.
8/17
Encryption Algorithm-Splitting Half
Input _data_block[64 bits]
8/3/2019 DESpseodo Code Intro.
9/17
Initial Permutation
Loop:( counts :16 rounds)
{
Fiestel Function executed with Inputs:
Half_block_1 [32 bits]
Subkey_N [48 bits]
Cipher_text[32 bit] = Fiestel_output [32 bit] Half_block_2 [32bits]
Such that output is swapped each time before next round except the last round
}
Final Permutation
Output >> Cipher_text [64 bits]
Initial and Final permutations are inverses of each other
Encryption Algorithm
8/3/2019 DESpseodo Code Intro.
10/17
Feistel function
XOR 6-bit input
4-bit output
Enables Swap
Expansion
The S-BoxesNon LinearTransformation
32 bit Data Output
48 bit data
8/3/2019 DESpseodo Code Intro.
11/17
Feistel function
Expansion:
Loop(until data expansion is complete)
{
halfblock_expnaded[48 bits]
8/3/2019 DESpseodo Code Intro.
12/17
Feistel function
Input to S-boxes:
the input for each s-box can be stored in a separate array of 6 locations
Loop: (counts 8 cycles) % thereby accounting for the 48 bits: 6*8=48
{
Loop : (counts 6 bits: 0 to 5)
Initialize: i=0, until i=5
{
S-box_input_N [i] = array [i]
increment: i
}
}
Array [48 bit]
S input S input2 S input 8
8/3/2019 DESpseodo Code Intro.
13/17
Feistel function
Substitution (S-Boxes):
Feistal_output [32 bit array] %will store the output of the s-boxes
Loop: (counts : 8 cycles) %the eight boxes
{
Loop:(counts 4 bits) %Each box gives output of 4 bits
{
Look_up_table : non linear transformation executed
S-box_input_N [i] > transformed> SN- box output [4 bit]
Feistal_output [ i ]
8/3/2019 DESpseodo Code Intro.
14/17
Look up table
S5
Middle 4 bits of input
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Outer
bits
00 0010 1100 0100 0001 0111 1010 1011 0110 1000 0101 0011 1111 1101 0000 1110 1001
01 1110 1011 0010 1100 0100 0111 1101 0001 0101 0000 1111 1010 0011 1001 1000 0110
10 0100 0010 0001 1011 1010 1101 0111 1000 1111 1001 1100 0101 0110 0011 0000 1110
11 1011 1000 1100 0111 0001 1110 0010 1101 0110 1111 0000 1001 1010 0100 0101 0011
Input: 011011 Output: 1001
Non Linear Transformation
8/3/2019 DESpseodo Code Intro.
15/17
Feistel function
Output Permutation:
Such that in the next round a Swap occurs
Loop: ( )
{
Outputfixed Permutation on
Feistel_output [32 bit]
}
Output >> Feistel_output [32 bit array]
8/3/2019 DESpseodo Code Intro.
16/17
Encryption
And Decryption is Similar. . .
plain Text64 bit blocks
CipherEncryptionAlgorithm
16 cycles
Cipher Text64 bit blocks
Secret key64 bits
N Blocks N Blocks
56 bits used
8/3/2019 DESpseodo Code Intro.
17/17
Questions
Thank You