Lecture#02 - Classical Encryption Techniques
Lecture#02 - Classical Encryption Techniques
Lecture#02
Classical Encryption Techniques
Course: Cryptography & Network Security (CE-408)
Course Teacher: Dr. Rukaiya
Contact Info:
Email: [email protected]
1
Definitions
• PLAINTEXT: An original message
• CIPHERTEXT: A coded/unintelligent/transformed/scrambled message
• ENCIPHERING/ENCRYPTION: The process of converting from
plaintext to ciphertext.
• DECIPHERING/DECRYPTION: Restoring the plaintext from the
ciphertext
• CRYPTOGRAPHY: The area of study of many schemes used for
encryption (crypto – secret graphy – writing)
• CRYPTOGRAPHIC SYSTEM/CIPHER: A scheme used for encryption
process
• CRYPTANALYSIS: Techniques used for deciphering a message without
any knowledge of the enciphering details (“breaking the code”)
• CRYPTOLOGY: The areas of cryptography and cryptanalysis
2
Figure: Simplified Model of Symmetric Encryption
3
Symmetric Cipher Model
4
^
X
Cryptanalyst
^
K
Secure Channel
Key
Source
5
Cryptographic Systems
• Characterized along three independent dimensions
Symmetric,
single-key,
Substitution secret-key, Block cipher
conventional
encryption
Asymmetric,
two-key, or
Transposition Stream cipher
public-key
encryption
6
Cryptanalysis and Brute-force Attack
Cryptanalysis
• Attack relies on the nature of the algorithm plus some knowledge
of the general characteristics of the plaintext
Brute-force attack
• Attacker tries every possible key on a piece of ciphertext until an
intelligible translation into plaintext is obtained
Differential Cryptanalysis
8
Encryption Scheme Security
• The users of an encryption algorithm can strive for is an
algorithm that meets following criteria:
• Unconditionally secure
No matter how much time an opponent has, it is impossible for
him or her to decrypt the ciphertext simply because the required
information is not there
• Computationally secure
The cost of breaking the cipher exceeds the value of the encrypted
information
The time required to break the cipher exceeds the useful lifetime of
the information
E.g., OTP (One Time Pad)
9
Key Strength
10
Strong Encryption
11
Classical Cryptographic
Techniques
12
Substitution Technique
13
Caesar Cipher
• Simplest and earliest known use of a substitution cipher
• Used by Julius Caesar about 2000 years ago
• Involves replacing each letter of the alphabet with the letter standing
three places further down the alphabet
• Alphabet is wrapped around so that the letter following Z is A
General Algorithm
Encryption: A shift may be of any amount, so that the general
Caesar algorithm is:
𝑪 = 𝑬 𝒌, 𝒑 = 𝒑 + 𝒌 𝒎𝒐𝒅 𝟐𝟔
Decryption: Where k takes on a value in the range 1 to 25; the
decryption algorithm is simply:
P= 𝑫 𝒌, 𝑪 = 𝑪 − 𝒌 𝒎𝒐𝒅 𝟐𝟔
14
Caesar Cipher
• Mathematically give each letter a number
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
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
Example:
plain: meet me after the toga party
cipher: PHHW PH DIWHU WKH WRJD SDUWB
15
Caesar Cipher
Activity #01:
plain: SSUET
cipher: ?????
Activity #02:
cipher: L FDPHL VDZL FRQTXHUHG
plain: ??????
16
Brute-force Cryptanalysis of Caesar Cipher
PHHW PH DIWHU WKH WR JD SDUWB
KEY
1 oggv og chvgt vjg vqic rctva
2 nffu nf bgufs uif uphb qbsuz
3 meet me after the toga party
4 ldds ld zesdq sgd snfz ozqsx
5 kccr kc ydrcp rfc rmey nyprw
Three important characteristics of this 6 jbbq jb xcqbo qeb qldx mxoqv
7 iaap ia wbpan pda pkcw lwnp u
problem enabled us to use a brute-force
8 hzzo hz vaozm ocz ojbv kvmot
cryptanalysis: 9 gyyn gy uznyl nby niau julns
10 fxxm fx tymxk max mhzt itkmr
1. The encryption and decryption algorithms 11 ewwl ew sxlwj lzw lgys hsjlq
are known. 12 dvvk dv rwkvi kyv kfxr grikp
2. There are only 25 keys to try. 13 cuuj cu qvjuh jxu jewq fqhjo
14 btti bt puitg iwt idvp epgin
3. The language of the plaintext is known
15 assh as othsf hvs hcu o dofhm
and easily recognizable
16 zrrg zr nsgre gur gbtn cnegl
17 yqqf yq mrfqd ftq fasm bmdfk
18 xppe xp lqepc esp ezrl alcej
19 wood wo kpdob dro dyqk zkbdi
20 vnnc vn jocna cqn cxpj yjach
21 ummb um inbmz bpm bwoi xizbg
22 tlla tl hmaly aol avnh whyaf
23 skkz sk glzkx znk zumg vgxze
24 rjjy rj fkyjw ymj ytlf ufwyd
17
25 qiix qi ejxiv xli xske tevxc
Figure
(This 3.3can
chart Brute-Force Cryptanalysis
be found on of Caesar
page 71 in the Cipher
textbook)
TASK
• Break Cipher
GCUA VQ DTGCM
18
Sample Compressed Text
19
Monoalphabetic Cipher
• Permutation
Of a finite set of elements S is an ordered sequence of all the elements
of S , with each element appearing exactly once
For example,
if S = {a, b, c}, there are six permutations of S : abc, acb, bac, bca, cab,
cba
In general, there are n! permutations of a set of n elements, because the
first element can be chosen in one of n ways, the second in n - 1 ways,
the third in n - 2 ways, and so on.
20
Monoalphabetic Cipher
• Example
OPEN ALPHABET: A B C D E F G H I J K L M N O P Q R S
TUVWXYZ
KEYWORD: K E Y W O R D
PLAINTEXT: A L K I N D I
Plaintext: A L K I N D I
Ciphertext: K G F B I W B
21
Cryptanalysis of Monoalphabetic Cipher
Step #01: Determine relative frequency of the letters can be determined and compared to
a standard frequency distribution for English
• In any case, the relative frequencies of the letters in the ciphertext (in percentages) are
as follows:
P 13.33 H 5.83 F 3.33 B 1.67 C 0.00 Z 11.67 D 5.00 W 3.33
G 1.67 K 0.00 S 8.33 E 5.00 Q 2.50 Y 1.67 L 0.00 U 8.33
V 4.17 T 2.50 I 0.83 N 0.00 O 7.50 X 4.17 A 1.67 J 0.83
R 0.00 M 6.67
Step #02 After Comparing this breakdown, it seems likely P and Z = e and t, but it is not
certain which is which.
S, U, O, M, and H are all of relatively high frequency and probably correspond to plain
letters from the set {a, h, i, n, o, r, s}.
The letters with the lowest frequencies (namely, A, B, G, Y, I, J) are likely included in the
set {b, j, k, q, v, x, z}.
23
Cryptanalysis of Monoalphabetic Cipher
• Easy to break because they reflect the frequency data of the original
alphabet
• Digram
Two-letter combination
Most common is th
• Trigram
Three-letter combination
Most frequent is the
24
Cryptanalysis of Monoalphabetic Cipher
• Ciphertext: UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
• The most common digram is ZW, which appears three times. So we make the
correspondence of Z with t and W with h. Then, by our earlier hypothesis, we can
equate P with e.
• Now notice that the sequence ZWP appears in the ciphertext, and we can translate
that sequence as “the.” This is the most frequent trigram (three-letter combination)
• Next, notice the sequence ZWSZ in the first line. We do not know that these four
letters form a complete word, but if they do, it is of the form th_t. If so, S equates
with a.
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ’
t a e e te a that e e a a
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
e t ta t ha e ee a e th t a
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
e e e tat e the t
25
Playfair Cipher
26
Playfair Cipher
Example:
Plaintext: BALLOON
Key: MONARCHY
1. Construct the matrix by filling in the letters of the keyword and remaining
letters in alphabetical order. The letters I and J count as one letter.
BA LX LO ON
27
Playfair Cipher
4. Look into the matrix for the pair encryption,
5. Two PT letter fall in same column are replaced with the letter beneath
them
BA LX LO ON
I/J B
6. The PT letter lies in different row and column are replaced by letter lies
at the intersection of them (same row and column)
BA LX LO ON
I/J B SU PM
7. Two PT letter fall in same row are replaced with the letter on right side
BA LX LO ON
I/J B SU PM NA
28
Playfair Cipher
Activity #03
29
Cryptanalysis of Playfair Cipher
• Security much improved over monoalphabetic since have
26 × 26 = 676 digrams.
30
Hill Cipher
• Developed by the mathematician Lester Hill in 1929
Encryption: C = K P mod 26
Decryption: P = 𝐾 −1 C mod 26
Where, 𝐾 −1 = inverse of K
K(𝐾 −1 )=1 mod 26
31
Hill Cipher
Example
Plaintext: ATTACK
Key: CDDG
32
Hill Cipher
33
Hill Cipher
34
Hill Cipher
35
Hill Cipher
Finding 𝑲−𝟏
• Suppose
3 −8
−17 5
• For Adj of A =
9
36
Hill Cipher
Finding Modular Inverse
38
Hill Cipher
Finding Inverse
𝟑 −𝟖 𝟐𝟕 −𝟕𝟐
𝑲−𝟏 = 𝟗 = mod 26
−𝟏𝟕 𝟓 −𝟏𝟓𝟑 𝟒𝟓
𝟏 𝟔
𝑲−𝟏 = mod 26
𝟑 𝟏𝟗
Find P ?
39
Hill Cipher
Finding |A| of 3 × 3 Matrix
Suppose
0 11 15
A= 7 0 1
4 19 0
0 1 7 1 7 0
|A|=0 − 11 + 15
19 0 4 0 4 19
= 11 mod 26
Practice Question:
Plaintext = THEY ARE GOING TO ATTEND CONFERENCE
5 6
Key =
2 3
Perform encryption and decryption both
40
Hill Cipher
41
Polyalphabetic Cipher
• Polyalphabetic substitution cipher
• Improves on the simple monoalphabetic technique by
using different monoalphabetic substitutions as one
proceeds through the plaintext message
42
Polyalphabetic Cipher
• For the next m letters of the plaintext, the key letters are
repeated.
• This process continues until all of the plaintext sequence
is encrypted.
• A general equation of the encryption process is
43
Polyalphabetic Cipher
• Repeat the key from start after end of the key is reached
45
Example of Vigenère Cipher
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Key 3 4 2 4 15 19 8 21 4 3 4 2 4 15
PT 22 4 0 17 4 3 8 18 2 14 21 4 17 4
CT 25 8 2 21 19 22 16 13 6 17 25 6 21 19
46
Vigenère Cipher
47
Vigenère Autokey System
• Example:
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGKZEIIGASXSTSLVVWLA
48
Vernam Cipher
• Introduced by AT&T engineer named Gilbert Vernam.
• Scheme is unbreakable
• Produces random output that bears no statistical relationship to
the plaintext
• Because the ciphertext contains no information whatsoever about
the plaintext, there is simply no way to break the code
50
Difficulties
• The one-time pad offers complete security but, in practice, has
two fundamental difficulties:
52
Transposition Cipher
53
Rail Fence Cipher
• Simplest transposition cipher
MEMATRHTGPRYETEFETEOAAT
54
Rail Fence Cipher
Activity:
Plaintext = I CAME I SAW I CONQUERED
CT=???
55
Row Transposition Cipher
• Is a more complex transposition
• Write the message in a rectangle, row by row, and read the
message off, column by column, but permute the order of the
columns
• The order of the columns then becomes the key to the algorithm
• Plaintext: Attack postponed until two am
Key: 4 3 1 2 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
• Pure transposition cipher is easily recognized because it has the same letter
frequency as the original Plaintext. Digram and trigram frequency
tables can be useful
• Can be more secure by performing more than once stage of
transposition. The result will be more complex permutation that is not
easily reconstructed.
56
Summary
57