Cryptography-Vit-Module 2
Cryptography-Vit-Module 2
• Human • The art and science of concealing the messages to introduce secrecy
• Formation of groups of information is recognized as cryptography.
• Need for communication
• Pictographical methods • Cryptography is the art and science of keeping messages secure.
• Sign Language
• Natural Language
• Written Form
• Oral Form • Cryptography is the science of using mathematics to encrypt and
• Need for secret communication decrypt data.
• One such modern technique devised to help this is termed as “Cryptography”
Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore. Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 1 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore. Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 2 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
2. Authentication 3. Integrity
• The process of proving one's identity. • Assuring the receiver that the received message has not been
• Authentication, which is the process of providing proof of identity of altered in any way from the original.
the sender to the recipient, so that the recipient can be assured that • Integrity, which is the method to ensure that information is not
the person sending the information is who and what he or she claims tampered with during its transit or its storage on the network.
to be. • Any unauthorized person should not be able to tamper with the
• For example, when Bob receives a message from Alice, then he information or change the information during transit.
should be able to establish the identity of Alice and know that the • For example, when Alice sends a message to Bob, then the contents
message was indeed sent by Alice. of the message should not be altered with and should remain the
• Cryptography can help establish identity for authentication same as what Alice has sent.
purposes.
Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore. Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore.
Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore. Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 3 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore. Dr.Swetha.N.G., Assistant Professor Senior, SCOPE, VIT, Vellore.
with another.
• Symmetric encryption, also referred to as conventional encryption or Substitution Cipher Transposition Cipher
single-key encryption.
one-to-one one-to-many
Keyless Transposition
Monoalphabetic Cipher Polyalphabetic Cipher Ciphers
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 4 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Cipher Cipher
• Examples: Plain A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
• Playfair Cipher Text
• Hill Cipher Cipher D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Text
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 5 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Plain A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Plain A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Text Text
Cipher 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Cipher 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Text Text
• Example 1: • Example 2:
• Use Caesar cipher to encrypt the message “hello” • Use Caesar cipher to decrypt the message “khoor”
• Encryption: • Decryption:
• C => E(3,p) = (p+3) mod 26 • p => D(3,C) = (C-3) mod 26
Plain Numeric E(3,p) = (p+3) mod 26 Numerical Value Cipher Text (C) Cipher Numeric D(3,C) = (C-3) mod 26 Numerical Value Plain Text (p)
Text (p) al Eq of p of the process Text (C) al Eq of C of the process
h 7 E(3,7) = (7+3) mod 26 = 10 mod 26 10 k k 10 D(3,10) = (10-3) mod 26 = 7 mod 26 7 h
e 4 E(3,4) = (4+3) mod 26 = 7 mod 26 7 h h 7 D(3,7) = (7-3) mod 26 = 4 mod 26 4 e
l 11 E(3,11) = (11+3) mod 26 = 14 mod 26 14 o o 14 D(3,14) = (14-3) mod 26 = 11 mod 26 11 l
l 11 E(3,11) = (11+3) mod 26 = 14 mod 26 14 o o 14 D(3,14) = (14-3) mod 26 = 11 mod 26 11 l
o 14 E(3,14) = (14+3) mod 26 = 17 mod 26 17 r r 17 D(3,17) = (17-3) mod 26 = 14 mod 26 14 o
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 6 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Plain A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Text
Caesar Cipher / Additive Cipher Cipher
Text
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
• Caesar Cipher is a specific case of additive Cipher where shift key=3. • Example 3:
• Use Additive cipher with key = 15 to encrypt the message “hello”
• Encryption:
• C => E(k,p) = (p+k) mod 26
Plain Numeric E(15,p) = (p+15) mod 26 Numerical Value Cipher Text (C)
Text (p) al Eq of p of the process
h 7 E(15,7) = (7+15) mod 26 = 22 mod 26 22 w
e 4 E(15,4) = (4+15) mod 26 = 19 mod 26 19 t
l 11 E(15,11) = (11+15) mod 26 = 26 mod 26 0 a
l 11 E(15,11) = (11+15) mod 26 = 26 mod 26 0 a
o 14 E(15,14) = (14+15) mod 26 = 29 mod 26 3 d
Plain A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Text
Cipher 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Vigenère Cipher
Text
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 7 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
G C Y C Z F M L Y L E I M
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 8 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
• The technique encrypts pairs of letters (bigrams or digrams), instead • The Playfair cipher uses a 5 by 5 table C R Y P T
of single letters as in the simple substitution cipher. containing a key word or phrase.
O G A H B
• To generate the key table,
• The Playfair is thus significantly harder to break since the frequency • First fill in the spaces in the 5X5 table D E F I/J K
analysis used for simple substitution ciphers does not work with it. with the letters of the keyword
(dropping any duplicate letters). L M N Q S
• It was used for tactical purposes by British forces in the Second Boer • Then fill the remaining spaces with the
War and in World War I and for the same purpose by the British and U V W X Z
rest of the letters of the alphabet in
Australians during World War II. order (usually omitting "J" or "Q" to
reduce the alphabet to fit; other
versions put both "I" and "J" in the same
space).
• The Playfair cipher uses a 5 by 5 table C R Y P T • The Playfair cipher uses a 5 by 5 table B D F G H
containing a key word or phrase. containing a key word or phrase. K L M N O
O G A H B
• To generate the key table, • To generate the key table,
P Q R S T
• First fill in the spaces in the 5X5 table D E F I/J K • First fill in the spaces in the 5X5 table
with the letters of the keyword with the letters of the keyword V W X Y Z
(dropping any duplicate letters). L M N Q S (dropping any duplicate letters).
• Then fill the remaining spaces with the • Then fill the remaining spaces with the
U V W X Z
rest of the letters of the alphabet in rest of the letters of the alphabet in J U I C E
order (usually omitting "J" or "Q" to order (usually omitting "J" or "Q" to
reduce the alphabet to fit; other reduce the alphabet to fit; other A B D F G
versions put both "I" and "J" in the same versions put both "I" and "J" in the same
space). How will you build the key cipher if space). H K L M N
the key phrase is “JUICE” ? O P R S T
V W X Y Z/Q
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 9 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 10 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
I/J T Y A B
HE LX LO WO RL DX
D F G H K
L M N O P
The plain text contains 6 digram with letter “X” as a dummy.
Q V W X Z
S E C U R S E C U R S E C U R S E C U R
D F G H K D F G H K D F G H K D F G H K
L M N O P L M N O P L M N O P L M N O P
Q V W X Z Q V W X Z Q V W X Z Q V W X Z
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 11 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
S E C U R S E C U R S E C U R S E C U R
D F G H K D F G H K D F G H K D F G H K
L M N O P L M N O P L M N O P L M N O P
Q V W X Z Q V W X Z Q V W X Z Q V W X Z
S E C U R S E C U R S E C U R S E C U R
D F G H K D F G H K D F G H K D F G H K
L M N O P L M N O P L M N O P L M N O P
Q V W X Z Q V W X Z Q V W X Z Q V W X Z
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 12 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
I/J T Y A B I/J T Y A B
Now we start the decryption process !!!
D F G H K D F G H K
L M N O P L M N O P
Q V W X Z Q V W X Z
Decrypted Digram 1: HE
S E C U R S E C U R S E C U R S E C U R
D F G H K D F G H K D F G H K D F G H K
L M N O P L M N O P L M N O P L M N O P
Q V W X Z Q V W X Z Q V W X Z Q V W X Z
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 13 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
S E C U R S E C U R S E C U R S E C U R
D F G H K D F G H K D F G H K D F G H K
L M N O P L M N O P L M N O P L M N O P
Q V W X Z Q V W X Z Q V W X Z Q V W X Z
L M N O P L M N O P
We get the plain text “HELLOWORLD”
Q V W X Z Q V W X Z
Decrypted Digram 6: DX
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 14 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Hill Cipher
• In classical cryptography, the Hill cipher is a polygraphic substitution
Hill Cipher
cipher based on linear algebra.
• Each letter is represented by a number modulo 26.
• Invented by Lester S. Hill in 1929, it was the first polygraphic cipher
in which it was practical (though barely) to operate on more than
three symbols at once.
• The following discussion assumes an elementary knowledge of
matrices.
• To encrypt a message, each block of n letters (considered as an n-
component vector) is multiplied by an invertible n × n matrix, against
modulus 26.
• To decrypt the message, each block is multiplied by the inverse of
the matrix used for encryption.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 15 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
• Encrypt and Decrypt the message ‘ACT’ (n=3). The key is 6 24 1 0 0 ∗ 6 + 2 ∗ 24 + (1 ∗ 19)
‘GYBNQKURP’. 13 16 10 ∗ 2 = 0 ∗ 13 + 2 ∗ 16 + 19 ∗ 10
20 17 15 19 0 ∗ 20 + 2 ∗ 17 + 19 ∗ 15
67
𝐺 𝑌 𝐵 6 24 1 = 222 𝑚𝑜𝑑 26
Key = 𝑁 𝑄 𝐾 = 13 16 10 319
𝑈 𝑅 𝑃 20 17 15
15 Encrypted Text = POH
0 = 14
𝑃𝑙𝑎𝑖𝑛 𝑇𝑒𝑥𝑡 = 2 7
19
|A|=6(240-170)-24(195-200)+1(221-320)
= 420+120-99
= 441
|A| mod 26 = 25
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 16 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
6 24 1
A= 13 16 10
Matrix Modular Inverse (3X3) 20 17 15
Matrix Modular Inverse (3X3)
Step 2: Find the minors of the matrix. Step 3: Find the Cofactor matrix
16 10 13 10 13 16
𝐴11 = = 70 𝐴12 = = −5 𝐴13 = = −99
17 15 20 15 20 17 +(70) −(−5) +(−99) 70 5 −99
CoF(A)= −(343) +(70) −(−378) = −343 70 378
24 1 6 1 6 24 +(224) −(47) +(−216) 224 −47 −216
𝐴21 = = 343 𝐴22 = = 70 𝐴23 = = −378
17 15 20 15 20 17
24 1 6 1 6 24
𝐴31 = = 224 𝐴32 = = 47 𝐴33 = = −216
16 10 13 10 13 16
70 −343 224 8 5 10
𝐴−1 = 25 5 70 −47 𝑚𝑜𝑑 26 = 21 8 21
−99 378 −216 21 12 8
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 17 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 18 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 19 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
1.Initial and Final Permutations – Example 1 1.Initial and Final Permutations – Example 2
• Find the output of the initial permutation box when the input is given • Find the output of the final permutation box when the input is given
in hexadecimal as: in hexadecimal as:
0000 0000 0000 0010 ……. 0001
0000000000000000
0000000010000000
• Solution: 0000000000000000
0000000000000010
• Only bit 15 and bit 64 are 1s; the other bits are 0s. • Solution:
• In the final permutation, bit 15 becomes bit 63 and bit 64 becomes • Bit 25 and 63 are only 1’s.
bit 25. • From the Final permutation table,
• The result is • Bit 25 -> Bit 64
• Bit 63 -> Bit 15
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 20 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 21 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Solution: Solution:
• If we write the first and the sixth bits together, we get 11 in binary, • If we write the first and the sixth bits together, we get 00 in binary,
which is 3 in decimal. which is 0 in decimal.
• The remaining bits are 0001 in binary, which is 1 in decimal. • The remaining bits are 0000 in binary, which is 0 in decimal.
• We look for the value in row 3, column 1, in (S-box 1). • We look for the value in row 1, column 1, in (S-box 1).
• The result is 12 in decimal, which in binary is 1100. • The result is 13 in decimal, which in binary is 1101.
• So the input 100011 yields the output 1100. • So the input 000000 yields the output 1101.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 22 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 23 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Trace of Data:
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 24 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
2. Completeness effect:
• Completeness effect means that each bit of the ciphertext needs to
depend on many bits on the plaintext.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 25 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 26 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Weaknesses in Key – Semi Weak Keys Weaknesses in Key – Semi Weak Keys
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 27 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 28 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
1. Triple DES with Two Keys 2. Triple DES with Three Keys
• In triple DES with two keys, there • In triple DES with two keys, there
are only two keys: k1 and k2. are three keys: k1, k2 and k3.
• The first and the third stages use • The first and the third stages use
k1; the second stage uses k2. k1; the second stage uses k2.
• A message encrypted with single • Compatibility with single DES is
DES with key k can be decrypted provided by letting k1 = k and
with triple DES if k1= k2 = k. setting k2 and k3 to the same
• Usecase: Banking Industry arbitrary key chosen by the
receiver.
• Usecase: PGP
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 29 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
17
17
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Text ➔ 0 to 25 ➔ Hex
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 30 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Inv
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 31 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
AES – Permutation
AES – Permutation
• InvShiftRows
• Another transformation found in a round is shifting, which permutes • In the decryption, the transformation is called InvShiftRows and the
the bytes. shifting is to the right.
Shift Rows • Figure shows how a state is transformed using ShiftRows
• In the encryption, the transformation is called Shift Rows. transformation. The figure also shows that InvShiftRows
transformation creates the original state.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
GF(28)
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 32 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 33 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
RCon
• Round Constant
• 4 Byte value
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 34 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 35 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 36 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 37 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 38 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 39 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 40 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
4. Output Feedback
Mode (OFB)
Advantages of OFB
• Operation is similar to that • In the case of CFB, a single bit error in a block is propagated to all
of CFB mode. subsequent blocks.
• Nonce value is already • This problem is solved by OFB as it is free from bit errors in the
known. plaintext block.
Disadvantages of OFB
• The drawback of OFB is that, because to its operational modes, it
is more susceptible to a message stream modification attack
than CFB.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 41 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
• The fact that CTR mode requires a synchronous counter at both the
transmitter and the receiver is a severe drawback.
• The recovery of plaintext is erroneous when synchronization is lost.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 42 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 43 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
K
0
1
1
2
2
3
3
6
4
1
5
2
6
3
7
6
Initialization Initialization
i=0 j= 0+s[0]+k[0] mod 8
j= (0 + 0 + 1) mod 8 = 1 Swap(s[0],s[1]) ➔ S [1 0 2 3 4 5 6 7]
S[i] i=1 j= 1+s[1]+k[1] mod 8
Index 0 1 2 3 4 5 6 7 j= (1 + 0 + 2) mod 8 = 3 Swap(s[1],s[3]) ➔ S [1 3 2 0 4 5 6 7]
Position i=2 j= 3+s[2]+k[2] mod 8
Value 0 1 2 3 4 5 6 7 j= (3 + 2 + 3) mod 8 = 0 Swap(s[2],s[0]) ➔ S [2 3 1 0 4 5 6 7]
i=3 j= 0+s[3]+k[3] mod 8
K[i] Key= [1 2 3 6] j= (0 + 0 + 6) mod 8 = 6 Swap(s[3],s[6]) ➔ S [2 3 1 6 4 5 0 7]
Permutation i=4 j= 6+s[4]+k[4] mod 8 Permutation
Index 0 1 2 3 4 5 6 7 j= (6 + 4 + 1) mod 8 = 3 Swap(s[4],s[3]) ➔ S [2 3 1 4 6 5 0 7]
Position i=5 j= 3+s[5]+k[5] mod 8
Value 1 2 3 6 1 2 3 6 j= (3 + 5 + 2) mod 8 = 2 Swap(s[5],s[2]) ➔ S [2 3 5 4 6 1 0 7]
i=6 j= 2+s[6]+k[6] mod 8
j= (2 + 0 + 3) mod 8 = 5 Swap(s[6],s[5]) ➔ S [2 3 5 4 6 0 1 7]
i=7 j= 5+s[7]+k[7] mod 8
j= (5 + 7 + 6) mod 8 = 2 Swap(s[7],s[2]) ➔ S [2 3 7 4 6 0 1 5]
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 44 of 45
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore.
Position 0 1 2 3 4 5 6 7
S 2 3 7 4 6 0 1 5 2. Pseudo Random Decryption:
K 1 2 3 6 1 2 3 6 Generator
P [1] i=0 ; j=0
i= 1; j= (0+s[1]) = 3 PT = 0 0 0 1
Algorithm (PRGA) 1. Key Scheduling Algorithm (KSA)
Initialization
Swap (S[1], S[3]) ➔ S [2 4 7 3 6 0 1 5] K = 0101
K= S[(S[1]+S[3]) mod 8] = S[(4+3) mod 8] = S[7] = 5 XOR = 0 1 0 0 ➔ 4
P[2] i=1 ; j=3 S[i]
i= 2; j= (3+s[2]) = 10 mod 8 = 2 PT = 0 0 1 0
Index 0 1 2 3 4 5 6 7
Swap (S[2], S[2]) ➔ S [2 4 7 3 6 0 1 5] K = 0001
K= S[(S[2]+S[2]) mod 8] = S[(7+7) mod 8] = S[6] = 1 XOR = 0 0 1 1 ➔ 3 Position
P[2] i=2 ; j=2 Value 0 1 2 3 4 5 6 7
i= 3; j= (2+s[3]) = 5 PT = 0 0 1 0
Swap (S[3], S[5]) ➔ S [2 4 7 0 6 3 1 5] K = 0000 K[i] Key= [1 2 3 6]
K= S[(S[3]+S[5]) mod 8] = S[(0+3) mod 8] = S[3] = 0 XOR = 0 0 1 0 ➔ 2 Permutation
P[2]
Index 0 1 2 3 4 5 6 7
i=3 ; j=5
i= 4; j= (5+s[4]) = 3 PT = 0 0 1 0 Position
Swap (S[4], S[3]) ➔ S [2 4 7 6 0 3 1 5] K = 0001 Value 1 2 3 6 1 2 3 6
K= S[(S[4]+S[3]) mod 8] = S[(0+6) mod 8] = S[6] = 1 XOR = 0 0 1 1 ➔ 3
CT → [4 3 2 3]
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Position 0 1 2 3 4 5 6 7
Permutation 1. Key Scheduling S 2 3 7 4 6 0 1 5 2. Pseudo Random
Position 0 1 2 3 4 5 6 7
Algorithm (KSA) K 1 2 3 6 1 2 3 6 Generator
S 0 1 2 3 4 5 6 7
K
CT [4] i=0 ; j=0 Algorithm (PRGA)
1 2 3 6 1 2 3 6 Initialization i= 1; j= (0+s[1]) = 3 CT = 0 1 0 0
i=0 j= 0+s[0]+k[0] mod 8 Swap (S[1], S[3]) ➔ S [2 4 7 3 6 0 1 5] K = 0101
j= (0 + 0 + 1) mod 8 = 1 Swap(s[0],s[1]) ➔ S [1 0 2 3 4 5 6 7] K= S[(S[1]+S[3]) mod 8] = S[(4+3) mod 8] = S[7] = 5 XOR = 0 0 0 1 ➔ 1
CT [3] i=1 ; j=3
i=1 j= 1+s[1]+k[1] mod 8
j= (1 + 0 + 2) mod 8 = 3 Swap(s[1],s[3]) ➔ S [1 3 2 0 4 5 6 7] i= 2; j= (3+s[2]) = 10 mod 8 = 2 CT = 0 0 1 1
Swap (S[2], S[2]) ➔ S [2 4 7 3 6 0 1 5] K = 0001
i=2 j= 3+s[2]+k[2] mod 8 K= S[(S[2]+S[2]) mod 8] = S[(7+7) mod 8] = S[6] = 1 XOR = 0 0 1 0 ➔ 2
j= (3 + 2 + 3) mod 8 = 0 Swap(s[2],s[0]) ➔ S [2 3 1 0 4 5 6 7]
CT [2] i=2 ; j=2
i=3 j= 0+s[3]+k[3] mod 8 i= 3; j= (2+s[3]) = 5 CT = 0 0 1 0
j= (0 + 0 + 6) mod 8 = 6 Swap(s[3],s[6]) ➔ S [2 3 1 6 4 5 0 7] Swap (S[3], S[5]) ➔ S [2 4 7 0 6 3 1 5] K = 0000
i=4 j= 6+s[4]+k[4] mod 8 Permutation K= S[(S[3]+S[5]) mod 8] = S[(0+3) mod 8] = S[3] = 0 XOR = 0 0 1 0 ➔ 2
j= (6 + 4 + 1) mod 8 = 3 Swap(s[4],s[3]) ➔ S [2 3 1 4 6 5 0 7] CT [3] i=3 ; j=5
i=5 j= 3+s[5]+k[5] mod 8 i= 4; j= (5+s[4]) = 3 PT = 0 0 1 1 C
j= (3 + 5 + 2) mod 8 = 2 Swap(s[5],s[2]) ➔ S [2 3 5 4 6 1 0 7] Swap (S[4], S[3]) ➔ S [2 4 7 6 0 3 1 5] K = 0001
K= S[(S[4]+S[3]) mod 8] = S[(0+6) mod 8] = S[6] = 1 XOR = 0 0 1 0 ➔ 2 P C
i=6 j= 2+s[6]+k[6] mod 8 P
j= (2 + 0 + 3) mod 8 = 5 Swap(s[6],s[5]) ➔ S [2 3 5 4 6 0 1 7] CT → [1 2 2 2]
i=7 j= 5+s[7]+k[7] mod 8
j= (5 + 7 + 6) mod 8 = 2 Swap(s[7],s[2]) ➔ S [2 3 7 4 6 0 1 5]
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of Prepared by: Dr.Swetha.N.G., Asst Prof Senior, Dept of
Analytics, SCOPE, VIT, Vellore. Analytics, SCOPE, VIT, Vellore.
Prepared by: Dr.Swetha.N.G., Asst Prof Senior, SCOPE, VIT, Vellore. Page 45 of 45