2. classical techniqueS
2. classical techniqueS
1
Topic
• Symmetric cipher model
– Cryptography
– Cryptanalysis
• Substitution techniques
– Caesar cipher
– Monoalphabetic cipher
– Polyalphabetic cipher
– One time pad
– Playfair cipher
2
Symmetric Encryption
• Referred to as conventional / private-key /
single-key
• sender and recipient share a common key
• all classical encryption algorithms are private-
key
• most widely used
3
Some Basic Terminology
• plaintext - original message
• ciphertext - coded message
• cipher - algorithm for transforming plaintext to ciphertext
• key - info used in cipher known only to sender/receiver
• encipher (encrypt) - converting plaintext to ciphertext
• decipher (decrypt) - recovering plaintext from ciphertext
7
Cryptanalysis
• Two general approaches to attacking a
conventional encryption scheme:
8
More Definitions
• Encryption scheme is unconditional secure
– Cipher text generated by the scheme does not contain
enough information to determine corresponding plaintext.
– the cipher text cannot be broken.
– no matter how much computer power or time is available.
• Encryption scheme is computational secure
– given limited computing resources so the cipher cannot be
broken
9
Brute Force Search
• always possible to simply try every key
• most basic attack, proportional to key size
Key Size Number of Time required at 1 Time required at
(bits) Alternative Keys decryption/µs 106 decryptions/µs
32 232 = 4.3 x 109 231 µs = 35.8 2.15 milliseconds
minutes
56 256 = 7.2 x 1016 255 µs = 1142 years 10.01 hours
128 2128 = 3.4 x 1038 2127 µs = 5.4 x 1024 5.4 x 1018 years
years
168 2168 = 3.7 x 1050 2167 µs = 5.9 x 1036 5.9 x 1030 years
years
26 26! = 4 x 1026 2 x 1026 µs = 6.4 x 106 years
characters 6.4 x 1012 years
(permutation
)
10
Classical Substitution Ciphers
• plaintext letters are replaced by other letters
or by numbers or symbols.
11
Caesar Cipher
• Also known substitution cipher
• first attested use in military.
• replaces each letter by 3rd letter further down
the alphabet
• example:
m e e t m e
P H H W P H
12
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
14
Monoalphabetic Cipher
• Caesar cipher is one of the example of
monoalphabetic cipher.
• Monoalphabetic cipher is special substitution
technique.
• each plaintext letter maps to a different random
ciphertext letter
• So there are 26! Different cipher alphabets (4 x 1026 )
possible.
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
15
Continued
Monoalphabetic Substitution Cipher
16
Continued
Example
We can use the given key to encrypt the message.
The ciphertext is
17
Monoalphabetic Cipher Security
• Caesar cipher is far from secure because only 25
possible keys.
• now have a total of 26! = 4 x 1026 keys
• with so many keys, might think is secure
• If the cryptanalyst knows the nature of the
plaintext(non compressed English text) then analyst
can exploit the data.
• Relative frequency of cipher text letters can be
determined and compare to a standard frequency
distribution for English.
18
English Letter Frequencies
19
Example
• Cipher text:
• UZQSOVUOHXMOPVGPZW………….
• Relative frequency of letter in percentage is:
• P: 13.33 e
• Z: 11.67 t
• S,U,O,M,H {a,h,i,n,o,r,s} probably frequency.
• ZW: three time repeated in above cipher.
so, z with ‘t’ and w with ‘h’ so ZW->th
next, ZWP -> the
next, ZWSZ -> th_t
20
Polyalphabetic Ciphers
• Monoalphabetic cipher encoded using only
one fixed alphabet. Spaces between words are
still there, these are fairly easy to break.
• So improve security use multiple cipher
alphabets for same plaintext letters.
• make cryptanalysis harder with more
alphabets to guess.
• One such cipher is the famous vigenere
cipher.
21
Vigenère Cipher
• simplest polyalphabetic substitution cipher
• Pick a keyword (example: MEC)
• Write this keyword on top of the plaintext and
repeat it many times if necessary.
• To retrieve cipher text of plain text use vigenere
table. (row: keys letter and column: plaintext letter).
• Keyword: M E C M E C M E C M E C M E C
• Plaintext: w e n e e d m o r e m o n e y
• Cipher : I I P Q I F Y S T Q Q Q Z I A
22
Continued
Vigenere Cipher
Example
We can encrypt the message “She is listening” using the 6-
character keyword “PASCAL”.
23
Continued
Example
Let us see how we can encrypt the message “She is listening”
using the 6-character keyword “PASCAL”. The initial key stream
is (15, 0, 18, 2, 0, 11). The key stream is the repetition of this
initial key stream (as many times as needed).
24
Table: A Vigenere Tableau
25
Security of Vigenère Ciphers
• have multiple ciphertext letters for each
plaintext letter
• hence letter frequencies are hidden.
• start with letter frequencies
– see if look monoalphabetic or not
• if not, then need to determine number of
alphabets, since then can attach each
26
One-Time Pad (Vernam Cipher)
• The cipher will be more secure. Key need not be
repeated. (Random Key)
• The key is used to encrypt and decrypt a single
message and then discarded.
• Key length is same as plaintext msg.
• It is unbreakable scheme. It offer complete security
but in practice, has two fundamental difficulties:
– Problem of making large quantities of random keys.
– Problem of key distribution & protection.
27
One-Time Pad
• Plain text: H O W A R E Y O U
7 14 22 0 17 4 24 14 20
+
OTP: 13 2 1 19 25 16 0 17 23
N C B T Z Q A R X
Initial total: 20 16 23 19 42 20 24 31 43
Mod 26: 20 16 23 19 16 20 24 5 17
Ciphertext: U Q X T Q U Y F R
28
Playfair cipher
• Playfair is multiple letter encryption cipher
• It is based on the use of a 5 x 5 matrix of letters
constructed using keyword.
• Example:
• keyword: “playfair is a diagram cipher”
P L A Y F
I/J R S D G (p1,p2) (c1,c2)
M C H E B
K N O Q T
U V W X Z
29
Playfair cipher
• Plaintext is encrypted two letters at a time based on following
rules:
me et at fi ve pm be hi nd pl ab.
• p1 & p2 in distinct row & column, then define the corner of a
submatrix. Ex: ET QB.
• P1 & p2 in common row, c1 is defined as the character
immediately to the right of p1 & c2 is defined right of p2. Ex:
ME CB.
• p1,p2 in same column, then character immediately (circularly)
below them are c2 & c3. Ex: PM IK.
• p1=p2 then infrequent plaintext character(such as x) inserted
between them and regrouped plaintext.
Ex: balloon ba lx lo on
30
Continued
Playfair Cipher
An example of a secret key in the Playfair cipher
Example :
Let us encrypt the plaintext “hello” using the key in Figure.
31
Hill cipher
• Another Multi letter cipher technique.
Note
Note: For Matrix Multiplication no. of columns of 1st matrix should be equal to
no. of rows of 2nd matrix.
Continued
Example (Continued)
Now she has the key and can break any ciphertext encrypted
with
3.35 that key.
Transposition Ciphers
• these hide the message by rearranging the
letter order
36
Rail Fence cipher
• Text is written down as sequence of diagonal.
m t a e h o p t
e m f r e g a y
e e t t t a r
• giving ciphertext
mtaehoptemfregayeetttar
38
Row Transposition Ciphers
• a more complex transposition is to write the
message in a rectangle row by row.
• Next, read the message column by column but
specify which order of column to convert plaintext
data into cipher text.
• write letters of message out in rows over a specified
number of columns.
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
39
Row Transposition Ciphers
• In double transposition method convert single
transposition cipher text into another cipher text.
Key: 4 3 1 2 5 6 7
Plaintext: t t n a a p t
m t s u o a o
d w c o i x k
n l y p e t z
Ciphertext: NSCYAUOPTTWLTMDNAOIEPAXTTOKZ
40
Continued
43