SlideShare a Scribd company logo
Cryptography Seminar
Substitution Cipher And It’s
Cryptanalysis
Presented by – Sunil Meena 2017UCP1593
Rahul Yadav 2017UCP1268
Content :-
Substitution Cipher
Cryptanalysis
 Definition
 Substitution Techniques
 Working with Example
 Definition
 Working with Example
 Issues
 Solutions
Know About it…..
CLASSICAL ENCRYPTION TECHNIQUES
=> Symmetric Encryption ( Where Key should
be same at Sender and Receiver side to Encrypt and Decrypt message)
Techniques
Substitution
Cipher Tech.
( Talking in later
slides )
Transposition Cipher Tech.
( Transposition means
Encryption by permutation of
alphabets )
Substitution Cipher
• Definition
► It means the letters of the plain text are replaced by other letters
or by numbers or symbols.
►Basic example
Plain text = NAME
Cipher text = IWPX
►Here we can say that N replaced by I , I replaced by W,
M replaced by P , E replaced by X.
Substitution Techniques
► Basically there are many substitution techniques but here we are talking
about two important techniques
Monoalphabetic Cipher
(One to One
Substitution)
Polyalphabetic Cipher
(One to many
Substitution)
Caesar Cipher
• Before talking about Monoalphabetic Cipher we need to know about Caesar
Cipher
• It is also called Shift cipher or Additive Cipher .
• In this cipher each letter in the plain text is replaced by a letter corresponding
to a number of shift in the alphabet.
• ALGO
We have Key = n(number), p=plain text, c = cipher text;
Encryption (C) = E( k , p ) = (p + k)mod26
Decryption (P) = D( k , c ) = (c - k)mod26
Monoalphabetic Cipher
• It’s a fixed substitution cipher technique
• Fixed means if we used ‘ X ’ for ‘ N ‘ then always we will use ‘ X ‘ only
in place of ‘ N ‘.
• In monoalphabetic cipher , relation between a character in the
plaintext to a symbol in the cipher text is always one-to-one
• For example we have given alphabetic letter table with
corresponding cipher text
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
N O A T R B E C F U X D Q G Y L K H V I J M P Z S W
Monoalphabetic cipher example
Plain Text
Cipher Text
Ex :- We can use the KEY in given above table to encrypt the message
Plain Text :- “ this message is easy to encrypt but hard to find the key “
Corresponding Cipher Text :-
“ICFVQRVVNEFVRNVSIYRGAAHSLIOJICNHTIYBFGTICRXRS “
Polyalphabetic Cipher
• There is no fixed substitution.
• Each occurrence of a character may have a different substitute it
means we can use more than one substitution for the same letter
• The relationship between a character in the plain text to a character
in the cipher text is one-to-many.
Example:-
M y na m e O Z RS W D
Vigenere Cipher
• It is a polyalphabetic substitution cipher
• The encryption is done using a 26x26 matrix or that matrix called
vigenere table
• Example :- Basic steps
We have
Plain text = P( size ‘n’)
Key = K(size ‘m’)
Now if (n>m) :- we divide the plain text into some blocks(
where each block size is equal to ‘m’(size of key))
Vigenere Example
• We have two method to encrypt the plain text
• Method :- 1 Using Vigenere table (used to find cipher text)
Cont..
Message = GIVEMONEY
Key = LOCK
Plaintext G I V E M O N E Y
Key L O C K L O C K L
Ciphertext R W X O X C P O J
Ciphertext R W X O X C P O L
Key L O C K L O C K L
Plaintext G I V E M O N E Y
Encryption
Decryption
Cont..
• Method – 2 :- When we don’t have vigenere table
We can express the vigenere cipher in the following manner :-
Plain text (P) = p0,p1,p2…….p(n-1)
Key (K) = k0,k1,k2……..k(m-1)
Cipher text (C) = E(K,P) = E[(k0,k1…k(m-1)) , (p0,p1….p(n-1))]
=> (p0+k0)mod26 , (p1+k1)mod26……(p(m-1)+k(m-1))mod26
General equation
Encryption :-
C(i) = [ p(i) + k(i) ] mod 26
Decryption :-
P(i) = [ C(i) – k(i) ] mod 26
Cont..
• Example :-
Key = “ deceptive ’’
Plain text = ‘ wearediscoveredsaveyourself ’
Cipher text = ‘ ZICVTWQNGRZGVTWAVZHCQYGLMGJ ’
Expressed numerically , we have the following results.
Key 3 4 2 4 15 19 8 21 4 3 4 2 4 15
Plain text 22 4 0 17 4 3 8 18 2 14 21 4 17 4
Cipher text 25 8 2 21 19 22 16 13 6 17 25 6 21 19
Key 3 4 2 4 15 19 8 21 4 3 4 2 4 15
Cipher text 25 8 2 21 19 22 16 13 6 17 25 6 21 19
Plain text 22 4 0 17 4 3 8 18 2 14 21 4 17 4
Encryption
Decryption
Cryptanalysis of substitution cipher
What is Cryptanalysis ?
► It is the study of ciphertext , ciphers and cryptosystem and
understand how they work , their weakness and techniques to improve
them.
In cryptanalysis we need to check two property
Correctness Security
Caesar Cipher Cryptanalysis
• Correctness :-
Plain text :- meet me after the toga party
, if k=3
Cipher text :- PHHW PH DIWHU WKH WRGD SWUWB
CORRECTNESS
Security :-
- It is not secure because
1. There are only 25 keys to try.
2. The language of the plain text is known and easily
recognizable.
Brute force cryptanalysis
Learnings
 Key space should be large enough to decrypt with brute force.
 If the language of plaintext is unknown ,then plaintext output may not be
recognizable .
Cryptanalysis of monoalphabetic cipher
Key size :-26! , Which is greater than 4x10^26
=>Plaintext:-it was disclosed yesterday that several informal but direct
contacts have been made with political representative of the viet cong in
moscow.
Acc. To the table given above
=>Ciphertext:
uzqsovuohxmopvgpozpevsgzwszopfpexsudbmetsxaizvuephzhmdz
shzowsfpappdtsvpquzwymxuzuhsxupyepopdhszufpombzwpfupzhmdjudtmoh
mq
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
s a h v p b c w u d j x e i m f t y o z k r q l g n
Cont..
Correctness
What about security?
Not secure because it can break using frequency analysis and
another patterns in plaintext
Frequency analysis of ciphertext
P-13.33 H-5.83 F-3.33 B-1.67 C-0 Z-11.65 D-5 W-3.33
G-1.67 K-0 S-8.33 E-5 Q-2.5 Y-1.67 L-0 U-8.33
V-4.17 T-2.5 I-0.83 N-0 O-7.5 X-4.17 A-1.67 J-0.83
R-0 M-6.67
Cont..
Relative frequency of letters in English text
Cont..
- After comparing standard frequency and ciphertext frequency we can
easily compute that e is equivalent to p similarly z-t,s-a……
- Also some patterns are common like in our ciphertext ‘zw’ comes
three times and in English most common sequence is ‘th’.
- as p equivalent e so ‘zwp’ equivalent to ‘the’.
- After such type of observation we can generate plaintext
‘it was disclosed yesterday that several informal but direct contacts
have been made with political representative of the viet cong in
Moscow’
Learnings
• Large key space is not enough.
• It is not enough to encrypt one letter at a time because it can easily
analyse by frequency analysis and repeated letter generate same
cipher which is also a loophole.
• So we should use multiple letter encryption.
Cryptanalysis of polyalphabetic cipher
Key :- deceptive
Plaintext:- we are discovered save yourself
using vigenere table or numerical method
Ciphertext:-ZICVTWQNGRZGVTWABZHCQIGLMGJ
Correctness
Security?
This is not secure because if attacker can guess the key length then
it is similar to monoalphabetic cipher for that particular length.
Cont..
In the above plaintext the sequence ‘red’ is repeated after nine character so in
cipher text ‘VTW’ also repeat after nine character so the key is either three or
nine letter in length.
Let in any ciphertext the length of key is m so it consists of m monoalphabetic
substitution it means problem remains same.
Plaintext:- we are discovered save yourself
Cont..
• To solve this problem, vigenere proposed an autokey system in which
keyword is concatenated with plain text itself to provide a running
key .
Example :-
key – deceptivewearediscoveredsav
plaintext- wearediscoveredsaveyourself
ciphertext – ZICVTWQNGKZEIIGASXSTSLVVWLA
even this is not secure because the key and the plaintext share the
same frequency distribution of letters ,a statistical technique can be
applied.
Learning
So multiple letter encryption is also not enough ,that means we need
more mathematical computation to improve our these cipher
techniques.
Reference
CRYPTOGRAPHY AND NETWORK SECURITY BY WILLIAM
STALLINGS
https://en.wikipedia.org/wiki/Substitution_cipher
http://practicalcryptography.com/cryptanalysis/stochastic-
searching/cryptanalysis-simple-substitution-cipher/
THANK YOU

More Related Content

Substitution cipher and Its Cryptanalysis

  • 1. Cryptography Seminar Substitution Cipher And It’s Cryptanalysis Presented by – Sunil Meena 2017UCP1593 Rahul Yadav 2017UCP1268
  • 2. Content :- Substitution Cipher Cryptanalysis  Definition  Substitution Techniques  Working with Example  Definition  Working with Example  Issues  Solutions
  • 3. Know About it….. CLASSICAL ENCRYPTION TECHNIQUES => Symmetric Encryption ( Where Key should be same at Sender and Receiver side to Encrypt and Decrypt message) Techniques Substitution Cipher Tech. ( Talking in later slides ) Transposition Cipher Tech. ( Transposition means Encryption by permutation of alphabets )
  • 4. Substitution Cipher • Definition ► It means the letters of the plain text are replaced by other letters or by numbers or symbols. ►Basic example Plain text = NAME Cipher text = IWPX ►Here we can say that N replaced by I , I replaced by W, M replaced by P , E replaced by X.
  • 5. Substitution Techniques ► Basically there are many substitution techniques but here we are talking about two important techniques Monoalphabetic Cipher (One to One Substitution) Polyalphabetic Cipher (One to many Substitution)
  • 6. Caesar Cipher • Before talking about Monoalphabetic Cipher we need to know about Caesar Cipher • It is also called Shift cipher or Additive Cipher . • In this cipher each letter in the plain text is replaced by a letter corresponding to a number of shift in the alphabet. • ALGO We have Key = n(number), p=plain text, c = cipher text; Encryption (C) = E( k , p ) = (p + k)mod26 Decryption (P) = D( k , c ) = (c - k)mod26
  • 7. Monoalphabetic Cipher • It’s a fixed substitution cipher technique • Fixed means if we used ‘ X ’ for ‘ N ‘ then always we will use ‘ X ‘ only in place of ‘ N ‘. • In monoalphabetic cipher , relation between a character in the plaintext to a symbol in the cipher text is always one-to-one • For example we have given alphabetic letter table with corresponding cipher text 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 N O A T R B E C F U X D Q G Y L K H V I J M P Z S W
  • 8. Monoalphabetic cipher example Plain Text Cipher Text Ex :- We can use the KEY in given above table to encrypt the message Plain Text :- “ this message is easy to encrypt but hard to find the key “ Corresponding Cipher Text :- “ICFVQRVVNEFVRNVSIYRGAAHSLIOJICNHTIYBFGTICRXRS “
  • 9. Polyalphabetic Cipher • There is no fixed substitution. • Each occurrence of a character may have a different substitute it means we can use more than one substitution for the same letter • The relationship between a character in the plain text to a character in the cipher text is one-to-many. Example:- M y na m e O Z RS W D
  • 10. Vigenere Cipher • It is a polyalphabetic substitution cipher • The encryption is done using a 26x26 matrix or that matrix called vigenere table • Example :- Basic steps We have Plain text = P( size ‘n’) Key = K(size ‘m’) Now if (n>m) :- we divide the plain text into some blocks( where each block size is equal to ‘m’(size of key))
  • 11. Vigenere Example • We have two method to encrypt the plain text • Method :- 1 Using Vigenere table (used to find cipher text)
  • 12. Cont.. Message = GIVEMONEY Key = LOCK Plaintext G I V E M O N E Y Key L O C K L O C K L Ciphertext R W X O X C P O J Ciphertext R W X O X C P O L Key L O C K L O C K L Plaintext G I V E M O N E Y Encryption Decryption
  • 13. Cont.. • Method – 2 :- When we don’t have vigenere table We can express the vigenere cipher in the following manner :- Plain text (P) = p0,p1,p2…….p(n-1) Key (K) = k0,k1,k2……..k(m-1) Cipher text (C) = E(K,P) = E[(k0,k1…k(m-1)) , (p0,p1….p(n-1))] => (p0+k0)mod26 , (p1+k1)mod26……(p(m-1)+k(m-1))mod26 General equation Encryption :- C(i) = [ p(i) + k(i) ] mod 26 Decryption :- P(i) = [ C(i) – k(i) ] mod 26
  • 14. Cont.. • Example :- Key = “ deceptive ’’ Plain text = ‘ wearediscoveredsaveyourself ’ Cipher text = ‘ ZICVTWQNGRZGVTWAVZHCQYGLMGJ ’ Expressed numerically , we have the following results. Key 3 4 2 4 15 19 8 21 4 3 4 2 4 15 Plain text 22 4 0 17 4 3 8 18 2 14 21 4 17 4 Cipher text 25 8 2 21 19 22 16 13 6 17 25 6 21 19 Key 3 4 2 4 15 19 8 21 4 3 4 2 4 15 Cipher text 25 8 2 21 19 22 16 13 6 17 25 6 21 19 Plain text 22 4 0 17 4 3 8 18 2 14 21 4 17 4 Encryption Decryption
  • 16. What is Cryptanalysis ? ► It is the study of ciphertext , ciphers and cryptosystem and understand how they work , their weakness and techniques to improve them. In cryptanalysis we need to check two property Correctness Security
  • 17. Caesar Cipher Cryptanalysis • Correctness :- Plain text :- meet me after the toga party , if k=3 Cipher text :- PHHW PH DIWHU WKH WRGD SWUWB CORRECTNESS Security :- - It is not secure because 1. There are only 25 keys to try. 2. The language of the plain text is known and easily recognizable.
  • 19. Learnings  Key space should be large enough to decrypt with brute force.  If the language of plaintext is unknown ,then plaintext output may not be recognizable .
  • 20. Cryptanalysis of monoalphabetic cipher Key size :-26! , Which is greater than 4x10^26 =>Plaintext:-it was disclosed yesterday that several informal but direct contacts have been made with political representative of the viet cong in moscow. Acc. To the table given above =>Ciphertext: uzqsovuohxmopvgpozpevsgzwszopfpexsudbmetsxaizvuephzhmdz shzowsfpappdtsvpquzwymxuzuhsxupyepopdhszufpombzwpfupzhmdjudtmoh mq 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 s a h v p b c w u d j x e i m f t y o z k r q l g n
  • 21. Cont.. Correctness What about security? Not secure because it can break using frequency analysis and another patterns in plaintext Frequency analysis of ciphertext P-13.33 H-5.83 F-3.33 B-1.67 C-0 Z-11.65 D-5 W-3.33 G-1.67 K-0 S-8.33 E-5 Q-2.5 Y-1.67 L-0 U-8.33 V-4.17 T-2.5 I-0.83 N-0 O-7.5 X-4.17 A-1.67 J-0.83 R-0 M-6.67
  • 22. Cont.. Relative frequency of letters in English text
  • 23. Cont.. - After comparing standard frequency and ciphertext frequency we can easily compute that e is equivalent to p similarly z-t,s-a…… - Also some patterns are common like in our ciphertext ‘zw’ comes three times and in English most common sequence is ‘th’. - as p equivalent e so ‘zwp’ equivalent to ‘the’. - After such type of observation we can generate plaintext ‘it was disclosed yesterday that several informal but direct contacts have been made with political representative of the viet cong in Moscow’
  • 24. Learnings • Large key space is not enough. • It is not enough to encrypt one letter at a time because it can easily analyse by frequency analysis and repeated letter generate same cipher which is also a loophole. • So we should use multiple letter encryption.
  • 25. Cryptanalysis of polyalphabetic cipher Key :- deceptive Plaintext:- we are discovered save yourself using vigenere table or numerical method Ciphertext:-ZICVTWQNGRZGVTWABZHCQIGLMGJ Correctness Security? This is not secure because if attacker can guess the key length then it is similar to monoalphabetic cipher for that particular length.
  • 26. Cont.. In the above plaintext the sequence ‘red’ is repeated after nine character so in cipher text ‘VTW’ also repeat after nine character so the key is either three or nine letter in length. Let in any ciphertext the length of key is m so it consists of m monoalphabetic substitution it means problem remains same. Plaintext:- we are discovered save yourself
  • 27. Cont.. • To solve this problem, vigenere proposed an autokey system in which keyword is concatenated with plain text itself to provide a running key . Example :- key – deceptivewearediscoveredsav plaintext- wearediscoveredsaveyourself ciphertext – ZICVTWQNGKZEIIGASXSTSLVVWLA even this is not secure because the key and the plaintext share the same frequency distribution of letters ,a statistical technique can be applied.
  • 28. Learning So multiple letter encryption is also not enough ,that means we need more mathematical computation to improve our these cipher techniques. Reference CRYPTOGRAPHY AND NETWORK SECURITY BY WILLIAM STALLINGS https://en.wikipedia.org/wiki/Substitution_cipher http://practicalcryptography.com/cryptanalysis/stochastic- searching/cryptanalysis-simple-substitution-cipher/