LECTURES Information Security Notes
LECTURES Information Security Notes
Ceaser Cipher:
Step # 1: Draw a table or matrix of all alphabetic and give them index starts from 0 and end with 25.
0 1 2 3 4 5
A B C D E F
6 7 8 9 10 11
G H I J K L
12 13 14 15 16 17
M N O P Q R
18 19 20 21 22 23
S T U V W X
24 25
Y Z
Example # 1:
Step # 2: add the index of the plain text alphabetic with the key. Where Plain Text = HELLO and key is 8,
H has an index 7, so we add 8 + 7 = 15 so result is less than 26 so the Cipher index is 15 which is P.
Encryption
H = 7, Key = 8 so 7 + 8 = 15 (P)
E = 4, key = 8 so 4 + 8 = 12 (M)
L = 11, Key = 8 so 11 + 8 = 19 (T)
L = 11, Key = 8 so 11 + 8 = 19 (T)
O = 14, Key = 8 so 14 + 8 = 22 (W)
P a g e | 1 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
Decryption
Cipher = PMTTW
P = 15, Key = 8, so 15 – 8 = 7 (H)
M = 12, Key = 8, so 12 – 8 = 4 (E)
T = 19, Key = 8, so 19 - 8 = 11 (L)
T = 19, Key = 8, so 19 - 8 = 11 (L)
W = 22, key = 8, so 22 – 8 = 14 (O)
So Cipher PMTTW has a Plain Text HELLO
Plain text = HELLO
Example # 2:
Encryption
key = 7
Plain text = PAKISTAN
Cipher = WHRPZAHU
Decryption
When we want to perform decryption then subtract the “key” from cipher text.
Cipher = WHRPZAHU
P a g e | 2 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
Mono Alphabetic:
In mono alphabetic each alphabet is replace with another alphabet as in the following table.
G C K X Y Z
A B C D E F
O N P M Q R
G H I J K L
U V W S T A
M N O P Q R
B H D E F L
S T U V W X
J I
Y Z
Example:
Plain text = PAKISTAN
Cipher = SGQPBHGV
Here “P” is replaced with its equivalent letter “S” and onward.
Key-Table
Write the key letters in key-table, no letter will repeat and remain cells are filled by remaining
alphabet as under.
N E T W O
R K S C U
I/J Y A B D
F G H L M
P Q V X Z
P a g e | 3 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
5) In case of decryption, if same row or column then take previous (backword) letter.
Encryption
Plain text = PA KI ST AN
Cipher = VI RY AS IT
Pair 1= PA See the P in A column and its correspondence letter is “ V “, and see A in P column and its
correspondence letter is “ I “.
Pair 2= KI See the K in I column and its correspondence letter is “ R “, and see I in K column and its
correspondence letter is “ Y “.
Pair 3= ST Here S and T are in same column so the next letter of S is “ A “ and T is “ S “.
Pair 4= AN See A in N column and its correspondence letter is “ I “ and see N in A column and its
correspondence letter is “ T “.
Decryption
Perform reverse procedure to convert the cipher into plain text.
P a g e | 4 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
Vigener Cipher:
Encryption
Plain text = NETWORK Row
Key = SECURITY Column
See the plain text in row in the key column to make the cipher.
P a g e | 5 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
Note: if key letter is less than the letters of plain text then repeat the key. e.g
Vernam Cipher:
Vernam cipher use bits to convert plaint text into cipher, it use the exclusive-OR operation. In
this cipher we convert the plaint text and key into 0,1 form first. E.g
Cipher = 01011
Key = 11001 +
Plain text = 10010
Note: All the techniques that we read above are substitution Cipher, in which each letter is replace
with a letter.
P a g e | 6 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
Transposition Ciphers
In this cipher the plain text is write diagonally and read it horizontally to make cipher. Here no.
of rows equal to key value.
Example # 1:
P K S A
A I T N
Cipher = PKSAAITN
Decryption
On decryption side count the cipher letter and divide them by key value to find how much rows
are there. Here write horizontally and read it diagonally to make plain text from cipher.
Cipher = PKSAAITN
Total letters = 8/2 = 4 (which shows the no. of letters in each rows)
P K S A
A I T N
Plain text = PAKISTAN
Example # 2:
Encryption
Plain text = CRYPTOGRAPHY AND NETWORK SECURITY
Key = 3 (shows the no. of rows)
C P G H N E O S U T
R T R Y D T R E R Y
Y O P A N W K C I
Decryption
P a g e | 7 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
Total letters = 29/3 ( first row=10 letter, second row= 10, third row=9 )
C P G H N E O S U T
R T R Y D T R E R Y
Y O P A N W K C I
P a g e | 8 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
2) Row Transposition:
Cipher = COHNRUPANWETTPDOCYYRATSARGYEKR
Key = 1 5 4 2 3
To convert this cipher to plain text count the cipher letters and divide with no. ok key.
Here total letters 30/5= 6 ( which shows the no. of letters in each column)
1 5 4 2 3
C R Y P T
O G R A P
H Y A N D
N E T W O
R K S E C
U R I T Y
Read row wise form above table to make plain text.
1 C O H N R U
5 R G Y E K R
4 Y R A T S I
2 P A N W E T
3 T P D O C Y
P a g e | 9 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University, Islamabad
Advanced Network Security & Cryptography
To make cipher read row wise according to no. value i.e less no. read first and onwards.
Cipher = COHNRU PANWET TPDOCY YRATSA RGYEKR
= COHNRUPANWETTPDOCYYRATSARGYEKR
Decryption
Cipher = COHNRUPANWETTPDOCYYRATSARGYEKR
Key = 1 5 4 2 3
To decrypt the cipher text count the cipher letters divided it by key no. i.e.
Here total letters 30 / 5= 6 (which shows the no. of letters in each row)
1 C O H N R U
5 R G Y E K R
4 Y R A T S I
2 P A N W E T
3 T P D O C Y
P a g e | 10 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Example:
Plain Text: Network
0 1 2 3 4 5
2 3
Key: A B C D E F
1 3 6 7 8 9 10 11
G H I J K L
Solution: 12 13 14 15 16 17
M N O P Q R
Encryption: 18 19 20 21 22 23
S T U V W X
Plain Text: NETWORK 24 25
Where N = 13, E = 4, T = 19, W = 22, O = 14, R = 17, K = 10 Y Z
NE:
2 3 13
MOD 26
1 3 4
2 x 13+3 x 4
MOD 26
1 x 13+3 x 4
26+12
MOD 26
13+12
38
MOD 26
25
12 = M & 25 = Z
M
Z
TW:
P a g e | 11 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
T = 19, W = 22
2 3 19
MOD 26
1 3 22
2 x 19+3 x 22
MOD 26
1 x 19+3 x 22
38+66
MOD 26
19+66
104
MOD 26
85
0=A&7=H
A
H
OR:
O = 14, R = 17
2 3 14
MOD 26
1 3 17
2 x 14+ 3 x 17
MOD 26
1 x 14+ 3 x 17
28+51
MOD 26
14+ 51
79
MOD 26
65
1 = B & 13 = N
B
N
P a g e | 12 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
KX:
K = 10, X = 23
2 3 10
MOD 26
1 3 23
2 x 10+3 x 23
MOD 26
1 x 10+3 x 23
20+69
MOD 26
10+69
89
MOD 26
79
11 = L & 1 = B
L
B
Thus
Plain Text = NE TW OR KX
Cipher = MZ AH BN LB
Decryption:
CIPHER = MZ AH BN LB
Formula:
C = K x P MOD 26
P = K-1 C (Order of K & C is important)
Adj of K
K-1 = = (Adj of K) x K-1
¿ A∨¿ ¿
P a g e | 13 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
2 3
K=
1 3
In Adj of K interchange a11 with a22 and change the sign of a12 & a21
3 −3
Adj of K =
−1 2
K-1 = Inverse 1
(Row x col) MOD 26
0 1 2 3 4 5 6 7 8 9 1 11 1 13 14 1 16 1 18 1 20 2 22 2 24 2
0 2 5 7 9 1 3 5
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 2 3 4 5 6 7 8 9 1 11 1 13 14 1 16 1 18 1 20 2 22 2 24 2
0 2 5 7 9 1 3 5
2 0 2 4 6 8 10 1 14 1 18 2 22 2 0 2 4 6 8 10 1 14 1 18 2 22 2
2 6 0 4 2 6 0 4
3 0 3 6 9 1 15 1 21 2 1 4 7 1 13 16 1 22 2 2 5 8 1 14 1 20 2
2 8 4 0 9 5 1 7 3
4 0 4 8 12 1 20 2 2 6 10 1 18 2 0 4 8 12 1 20 2 2 6 10 1 18 2
6 4 4 2 6 4 4 2
5 0 5 1 15 2 25 4 9 1 19 2 3 8 13 18 2 2 7 12 1 22 1 6 1 16 2
0 0 4 4 3 7 1 1
6 .
. .
. .
2 .
5
3’s inverse is 9
5’s inverse is 21
|K| = 6 – (3) = 6 – 3 = 3
Now Formula:
3 −3 -1
K-1 = 3 Mod 26
−1 2
3 −3
9 MOD 26
−1 2
3 x 9 −3 x 9
MOD 26
−1 x 9 2 x 9
P a g e | 14 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
1 25
K-1 =
17 18
CIPHER = MZ AH BN LB
MZ:
M = 12, Z = 25
P = K-1 C Mod 26
1 25 M
P= MOD 26
17 18 Z
1 25 12
P= MOD 26
17 18 25
1 x 12+25 x 25
P= MOD 26
17 x 12+18 x 25
12+ 625
P= M OD 26
204+ 450
637
P= M OD 26
654
637 MOD 26
P=
654 MOD 26
13
P=
4
N
P=
E
Thus MZ = NE
CIPHER = AH BN LB
AH:
A = 0, H = 7
P = K-1 C Mod 26
P a g e | 15 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
1 25 A
P= MOD 26
17 18 H
1 25 0
P= MOD 26
17 18 7
1 x 0+ 25 x 7
P= MOD 26
17 x 0+18 x 7
0+175
P= M OD 26
0+126
175
P= M OD 26
126
175 MOD 26
P=
126 MOD 26
19
P=
22
T
P=
W
Thus AH = TW
CIPHER = BN LB
BN:
B = 1, N = 13
P = K-1 C Mod 26
1 25 B
P= MOD 26
17 18 N
1 25 1
P= MOD 26
17 18 13
1 x 1+25 x 13
P= MOD 26
17 x 1+18 x 13
1+325
P= M OD 26
17+234
326
P= M OD 26
251
P a g e | 16 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
326 MOD 26
P=
251 MOD 26
14
P=
17
O
P=
R
Thus BN = OR
CIPHER = LB
LB:
L = 11, B = 1
P = K-1 C Mod 26
1 25 L
P= MOD 26
17 18 B
1 25 11
P= MOD 26
17 18 1
1 x 11+ 25 x 1
P= MOD 26
17 x 11+18 x 1
11+25
P= M OD 26
187+18
36
P= M OD 26
205
36 MOD 26
P=
205 MOD 26
10
P=
23
K
P=
X
Thus LB = KX
Thus
Cipher Text = MZ AH BN LB
P a g e | 17 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Plain Text = NE TW OR KX
P a g e | 18 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National
Institute of Standards and Technology (NIST).
DES STRUCTURE
The encryption process is made of two permutations (P-boxes), which we call initial and final
permutations, and sixteen Feistel rounds.
P a g e | 19 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
The 58th bit of input x will be the first bit of output IP(x), the 50th bit of x is the second bit of IP(x), etc.
P a g e | 20 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
The initial and final permutations are straight P-boxes that are inverses of each other. They have no
cryptography significance in DES
Example 1
Find the output of the initial permutation box when the input is given in hexadecimal as:
Solution
Only bit 25 and bit 64 are 1s; the other bits are 0s. In the final permutation, bit 25 becomes bit 64 and
bit 63 becomes bit 15. The result is
Rounds
A round in DES
(encryption site)
Expansion P-box
Since RI−1 is a 32-bit input and KI is a 48-bit key, we first need to expand RI−1 to 48 bits.
Expansion
permutation
P a g e | 21 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Although the relationship between the input and output can be defined mathematically,
P a g e | 22 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Example:
Step # 1:
Convert the plain text in hexadecimal form, and index it from 1 to 64.
The divide the bits into two half of 32 bit each. (Left & Right Half)
First 32 bits are left part (1-32 index) and last 32 bits are right part (33-64 index)
Step # 2:
Now we perform operations (Initial Permutation) on the Right Half (Part) and then XOR with the
Left Half (Part).
P a g e | 23 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6
3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
1 0 1 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1
1 0 0 0 1 26 0 18 0 1
58 50 42 34 10 02
1 0 0 0 1 28 0 20 1 1
60 52 44 36 12 04
0 0 0 0 0 30 0 0 0
62 54 46 38 22 14 06
1 64 1 56 1 1 40 1 32 1 1 0
48 24 16 08
0 57 0 49 0 1 0 25 0 0 1
41 33 17 09 01
0 59 1 51 0 43 1 35 0 27 0 1 1
19 11 03
1 61 0 53 0 45 1 37 1 29 0 1 1
21 13 05
0 63 1 55 0 47 1 39 1 31 0 0 1
23 15 07
1 0 0 0 1 0 0 1
1 0 0 0 1 0 1 1
0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 0
0 0 0 1 0 0 0 1
0 1 0 1 0 0 1 1
1 0 0 1 1 0 1 1
0 1 0 1 1 0 0 1
Left Half
1 0 0 0 1 0 0 1
1 0 0 0 1 0 1 1
0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 0
Right Half
0 0 0 1 0 0 0 1
0 1 0 1 0 0 1 1
1 0 0 1 1 0 1 1
0 1 0 1 1 0 0 1
P a g e | 24 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Step # 3:
Right Half
0 0 0 1 0 0 0 1
0 1 0 1 0 0 1 1
1 0 0 1 1 0 1 1
0 1 0 1 1 0 0 1
According to Expansion Table Bit #: 32, 01, 02,03,04,05 and values are 100010
P a g e | 25 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
DES: S-boxes
S1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
1 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
2 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
3 15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
100010:
S2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10
1 3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5
2 0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15
3 13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9
100010:
P a g e | 26 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
S3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8
1 13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1
2 13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7
3 1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12
101010:
15 in hexadecimal = 1111
S4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 7 13 14 3 0 6 9 10 1 2 8 5 11 12 4 15
1 13 8 11 5 6 15 0 3 4 7 2 12 1 10 14 9
2 10 6 9 0 12 11 7 13 15 1 3 14 5 2 8 4
3 3 15 0 6 10 1 13 8 9 4 5 11 12 7 2 14
100111:
S5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 2 12 4 1 7 10 11 6 8 5 3 15 13 0 14 9
1 14 11 2 12 4 7 13 1 5 0 15 10 3 9 8 6
2 4 2 1 11 10 13 7 8 15 9 12 5 6 3 0 14
P a g e | 27 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
3 11 8 12 7 1 14 2 13 6 15 0 9 10 4 5 3
110011:
S6 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 12 1 10 15 9 2 6 8 0 13 3 4 14 7 5 11
1 10 15 4 2 7 12 9 5 6 1 13 14 0 11 3 8
2 9 14 15 5 2 8 12 3 7 0 4 10 1 13 11 6
3 4 3 2 12 9 5 15 10 11 14 1 7 6 0 8 13
110110:
S7 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 4 11 2 14 15 0 8 13 3 12 9 7 5 10 6 1
1 13 0 11 7 4 9 1 10 14 3 5 12 2 15 8 6
2 1 4 11 13 12 3 7 14 10 15 6 8 0 5 9 2
3 6 11 13 8 1 4 10 7 9 5 0 15 14 2 3 12
101011:
P a g e | 28 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
S8 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 13 2 8 4 6 15 11 1 10 9 3 14 5 0 12 7
1 1 15 13 8 10 3 7 4 12 5 6 11 0 14 9 2
2 7 11 4 1 9 12 14 2 0 6 10 13 15 3 5 8
3 2 1 14 7 4 10 8 13 15 12 9 0 3 5 6 11
110010:
6 in hexadecimal: 0110
0001 1110
1111 0110
1111 1010
0100 0110
Step # 4:
Straight permutation
table
P a g e | 29 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
0 1 1 1 0 29 0 12 0 1
16 07 20 21 28 17
0 1 1 1 1 05 1 18 1 1
01 15 23 26 31 10
0 0 0 1 0 32 1 0 1
02 08 24 14 27 03 09
1 19 0 13 1 1 06 0 22 1 1 0
30 11 04 25
01110001 (Right)
XOR 10001001 (Left)
------------------------------------------
11111000
01111111 (Right)
XOR 10001011 (Left)
---------------------------------------
11110100
00010101 (Right)
XOR 00000000 (Left)
-------------------------------------
00010101
10110110 (Right)
XOR 11111110 (Left)
--------------------------------
01001000
P a g e | 30 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
P a g e | 31 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
01111000 11111000
10110101 11110100
00010001 00010101
01000100 01001000
+
Next Left Part:
P a g e | 32 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Key Generation:
0X AB012345FE678DC9
1 1 0 1 0 25 0 17 0 1
57 49 41 33 09 01
1 0 1 1 1 26 0 18 0 0
58 50 42 34 10 02
0 0 1 1 0 27 1 0 1
59 51 43 35 19 11 03
0 60 0 0 1 36 0 63 0 1 1
52 44 55 47 39
0 31 1 0 1 0 62 1 1 1
23 15 07 54 46 38
1 30 0 0 0 06 1 61 1 0 1
22 14 53 45 37
0 29 0 0 1 05 0 28 0 0 0
21 13 20 12 04
Compression Table:
0 0 1 0 1 01 0 05 1 1
14 17 11 24 03 28
0 0 1 1 1 23 1 19 1 0
15 06 21 10 12 04
0 1 0 1 1 27 0 0 0
26 08 16 07 20 13 02
0 41 0 1 1 1 47 0 1 1
52 31 37 55 30 40
1 51 1 1 0 1 44 0 1 0
45 33 48 49 39 56
0 34 0 0 0 0 50 0 0 0
53 46 42 36 29 32
P a g e | 33 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Key:
0010 1011
0011 1110
0101 1000
0011 1011
1110 1010
0000 0000
P a g e | 34 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Example:
Plain Text: 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
Key: FF EE DD CC BB AA 99 88 77 66 55 44 33 22 11 00
W0 W1 W2 W3
Step # 1: Convert the plain text in states, convert plain text Column Wise & Key Row Wise
00 = 0000 0000
--------------------------------------
FF = 1111 1111
--------------------------------------
44 = 0100 0100
---------------------------------------
P a g e | 35 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
After XOR (both plain text & Key) table show below:
Step # 4:
P a g e | 36 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
After Substitution
16 AC FC 63
FC AC 16 63
16 AC FC 63
FC AC 16 63
W4 = w0 XOR T4
W5 = w1 XOR w4
W6 = w2 XOR w5
W7 = w3 XOR w6
T4 =?
W3 = 33 22 11 00
-------------------------------------------------------------
63 C3 93 83
T4 = 63 C3 93 83
Thus
P a g e | 37 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
W4 = W0 XOR T4
W0 = FF EE DD CC
T4 = 63 C3 93 83 (XOR)
-----------------------------------------------------------------------
9C 2D 4E 4F
W4 = 9C 2D 4E 4F
W5 = ?
W5 = W1 XOR W4
W1 = BB AA 99 88
W4 = 9C 2D 4E 4F
27 87 D7 C7
W5 = 27 87 D7 C7
W6 = ?
W6 = W2 XOR W5
W2 = 77 66 55 44
W5 = 27 87 D7 C7
P a g e | 38 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
50 E1 82 83
W6 = 50 E1 82 83
W7 = ?
W7 = W3 XOR W6
W3 = 33 22 11 00
W6 = 50 E1 82 83
63 C3 93 83
W7 = 63 C3 93 83
Note:
Pre Round: -
Then Round # 1:
1. Sub Byte
2. Shift Rows
3. Mix Column
4. Add round Key (W4-W7)
Note: First is substitute row, then perform shift rows. In animation shift is column wise but we perform
only row wise.
P a g e | 39 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Note: Step # 1 to Step # 4 for public key. And step # 5 is for private key.
Example:
P = 3, q = 5
n = p x q = 3 x 5 = 15
= (3-1) (5-1) = 2 x 4 = 8
Assume e = 11
11 x 1 mod 8 = 3
11 x 2 mod 8 = 6
11 x 3 mod 8 = 1 (Inverse)
So e = 11 and d = 3
P a g e | 40 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
Encryption:
Assume p = 2
C = pe mod n
= 211 mod 15
= 2048 mod 15
C=8
Decryption:
P = Cd mod n
= 83 mod 15
= 512 mod 15
P=2
Example # 2:
P = 5, q = 7, e = 5
n = p x q = 5 x 7 = 35
= (5-1) (7-1) = 4 x 6 = 24
e = 5, d =?
e x d mod ɸ (n)
5 x 1 mod 24 = 5
5 x 2 mod 24 = 10
5 x 3 mod 24 = 15
5 x 4 mod 24 = 20
P a g e | 41 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad
Advanced Network Security & Cryptography
5 x 5 mod 24 = 1 (Inverse)
d=5
Encryption:
C = pe mod n
= 25 mod 35
= 32 mod 35 = 32
C = 32
Decryption:
P = Cd mod n
= 325 mod 35
= 33554432 mod 35
P=2
P a g e | 42 Prepared By: Rana Javed Rashid (PhD Scholar), Islamic International University,
Islamabad