You are on page 1of 37

Cryptography and Network Security

CS 701

SK Hafizul Islam
hafi786@gmail.com
Department of CSE
IIIT Kalyani
10 July 2018 CS 701 1
Symmetric Encryption
• Conventional / private-key / single-key
• Sender and recipient share a common key
• All classical encryption algorithms are private-key
• Was only type prior to invention of public-key in 1970’s

10 July 2018 CS 701 2


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 ciphertext from plaintext

10 July 2018 CS 701 3


Symmetric Cipher Model

10 July 2018 CS 701 4


Requirements
• Two requirements for secure use of symmetric encryption:
– a strong encryption algorithm
– a secret key known only to both sender and receiver
• Mathematically,
Y = EK(X)
X = DK(Y)
• assume encryption algorithm is known
• implies a secure channel to distribute key

10 July 2018 CS 701 5


Cryptography
• Systems are characterized along three independent dimensions:
– type of encryption operations used
• substitution / transposition / product
– number of keys used
• single-key or private / two-key or public
– way in which plaintext is processed
• block / stream

10 July 2018 CS 701 6


Cryptanalysis
• objective to recover key not just message
• general approaches:
– Cryptanalytic attack: Cryptanalytic attacks rely on the nature of
the algorithm plus perhaps some knowledge of the general
characteristics of the plaintext or even some sample plaintext –
ciphertext pairs. This type of attack exploits the characteristics
of the algorithm to attempt to deduce a specific plaintext or to
deduce the key being used.
– Brute-force attack: The attacker tries every possible key on a
piece of ciphertext until an intelligible translation into plaintext
is obtained. On average, half of all possible keys must be tried
to achieve success.
10 July 2018 CS 701 7
Cryptanalytic Attacks
• ciphertext only
• known plaintext
• chosen plaintext
• chosen ciphertext

10 July 2018 CS 701 8


Ciphertext only attacks
• Only know algorithm & ciphertext, is statistical, know or can
identify plaintext
– Brute-Force attack
– Statistical attack
– Pattern attack

10 July 2018 CS 701 9


Known plaintext attacks
• know/suspect plaintext & ciphertext

10 July 2018 CS 701 10


Chosen plaintext attacks
• Select plaintext and obtain ciphertext

10 July 2018 CS 701 11


Chosen ciphertext attacks
• Select ciphertext and obtain plaintext

10 July 2018 CS 701 12


More Definitions
• unconditional security
– no matter how much computer power or time is available, the
cipher cannot be broken since the ciphertext provides
insufficient information to uniquely determine the
corresponding plaintext
• computational security
– given limited computing resources (e.g., time needed for
calculations is greater than age of universe), the cipher cannot
be broken

10 July 2018 CS 701 13


Brute Force Search
• always possible to simply try every key
• most basic attack, proportional to key size
• assume either know / recognise plaintext
Key Size (bits) Number of Alternative Time required at 1 Time required at 106
Keys decryption/µs decryptions/µs

32 232 = 4.3  109 231 µs = 35.8 minutes 2.15 milliseconds

56 256 = 7.2  1016 255 µs = 1142 years 10.01 hours

128 2128 = 3.4  1038 2127 µs = 5.4  1024 years 5.4  1018 years

168 2168 = 3.7  1050 2167 µs = 5.9  1036 years 5.9  1030 years

26 characters 26! = 4  1026 2  1026 µs = 6.4  1012 years 6.4  106 years
(permutation)

10 July 2018 CS 701 14


Classical Substitution Ciphers
• Letters of plaintext are replaced by other letters or by numbers or
symbols or if plaintext is viewed as a sequence of bits, then
substitution involves replacing plaintext bit patterns with
ciphertext bit patterns.
• Substitution ciphers can be categorized as either monoalphabetic
ciphers or polyalphabetic ciphers.

10 July 2018 CS 701 15


Additive/shift/Caesar Cipher
• earliest known substitution cipher
• by Julius Caesar
• first attested use in military affairs
• replaces each letter by 3rd letter on
• example:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB

10 July 2018 CS 701 16


Caesar Cipher
• can define transformation as:
abcdefghijklmnopqrstuvwxyz
DEFGHIJKLMNOPQRSTUVWXYZABC

• mathematically give each letter a number


abcdefghij 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

• then have Caesar cipher as:


c = E(p) = (p + k) mod (26)
p = D(c) = (c – k) mod (26)

10 July 2018 CS 701 17


Example of Caesar Cipher
Use the additive cipher with key = 15 to encrypt the
message “hello”.
Solution:
We apply the encryption algorithm to the plaintext,
character by character:

18
10 July 2018 CS 701
Example of Caesar Cipher...
Use the additive cipher with key = 15 to decrypt the
message “WTAAD”.
Solution:
We apply the decryption algorithm to the plaintext
character by character:

19
10 July 2018 CS 701
Cryptanalysis of Caesar Cipher
• only have 26 possible ciphers
– A maps to A,B,..Z
• could simply try each in turn
• a brute force search
• given ciphertext, just try all shifts of letters
• do need to recognize when have plaintext
• eg. break ciphertext "GCUA VQ DTGCM"

10 July 2018 CS 701 20


Cryptanalysis of Caesar Cipher...
Eve has intercepted the ciphertext “UVACLYFZLJBYL”. Show
how she can use a brute-force attack to break the cipher.
Solution:
Eve tries keys from 1 to 7. With a key of 7, the plaintext is
“not very secure”, which makes sense.

21
10 July 2018 CS 701
Language Redundancy and Cryptanalysis
• human languages are redundant
• letters are not equally commonly used
• in English E is by far the most common letter
– followed by T, R, N, I, O, A, S
• other letters like Z, J, K, Q, X are fairly rare
• have tables of single, double & triple letter frequencies
for various languages

https://www.tandfonline.com/doi/abs/10.1080/0161-117991854133

10 July 2018 CS 701 22


English Letter Frequencies

10 July 2018 CS 701 23


Use in Cryptanalysis
• key concept - monoalphabetic substitution ciphers do not
change relative letter frequencies
• discovered by Arabian scientists in 9th century
• calculate letter frequencies for ciphertext
• compare counts/plots against known values

10 July 2018 CS 701 24


Example Cryptanalysis
• given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZVUEPHZHMDZSHZOW
SFPAPPDTSVPQUZWYMXUZUHSXEPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
• count relative letter frequencies (see text)
• guess P & Z are e and t
• guess ZW is th and hence ZWP is the
• proceeding with trial and error finally get:
it was disclosed yesterday that several informal but
direct contacts have been made with political
representatives of the viet cong in moscow

10 July 2018 CS 701 25


Multiplicative Cipher

In a multiplicative cipher, the plaintext (P) and ciphertext


(C) are integers in Z26; the key is an integer in Z26*.

26
10 July 2018 CS 701
Example of Multiplicative Cipher
What is the key domain for any multiplicative cipher?

Solution
The key needs to be in Z26*. This set has only 12 members: 1, 3, 5, 7,
9, 11, 15, 17, 19, 21, 23, 25.

We use a multiplicative cipher to encrypt the message “hello” with a


key of k=7. The ciphertext is “XCZZU”.

27
10 July 2018 CS 701
Affine Cipher

28
10 July 2018 CS 701
Example of Affine Cipher
The affine cipher uses a pair of keys (k1, k2) in which the
first key is from Z26* and the second is from Z26. The size of
the key domain is (26 × 12) = 312.

Use an affine cipher to encrypt the message “hello” with


the key pair (7, 2).

29
10 July 2018 CS 701
Example of Affine Cipher…
Use the affine cipher to decrypt the message “ZEBBW” with
the key pair (7, 2) in modulus 26.
Solution

The additive cipher is a special case of an affine cipher in


which k1 = 1. The multiplicative cipher is a special case of
affine cipher in which k2 = 0.
30
10 July 2018 CS 701
Frequency analysis of Affine Cipher

31
10 July 2018 CS 701
Frequency analysis of Affine Cipher…

32
10 July 2018 CS 701
Frequency analysis of Affine Cipher…
• There are only 57 characters of ciphertext.
• The most frequent ciphertext characters are: R(8 times), D(7
times), E, H, K (5 times) and F, S, V (4 times).
• First guess, R is the encryption of e and D is the encryption of t,
since e and t are most common letters.
• We have EK(4)=17 and EK(19)=3. Thus, 4K1+K2=17 and 19K1+K2=3

33
10 July 2018 CS 701
Frequency analysis of Affine Cipher…
• Unique solution of 4K1+K2=17 and 19K1+K2=3 is K1=6, K2=19. Since
gcd(K1, 26)=2>1. So the hypothesis is incorrect.
• Second guess, R is the encryption of e and E is the encryption of t.
• We have EK(4)=17 and EK(19)=4. Thus, 4K1+K2=17 and 19K1+K2=4
• It leads K1=13, Since gcd(K1, 26)=2>1. So the hypothesis is
incorrect.

34
10 July 2018 CS 701
Frequency analysis of Affine Cipher…
• Third guess, R is the encryption of e and H is the encryption of t.
• We have EK(4)=17 and EK(19)=7. Thus, 4K1+K2=17 and 19K1+K2=7
• It leads K1=8, Since gcd(K1, 26)=2>1. So the hypothesis is incorrect.

35
10 July 2018 CS 701
Frequency analysis of Affine Cipher…
• Continuing, we suppose that, R is the encryption of e and K is the
encryption of t.
• We have EK(4)=17 and EK(19)=10. Thus, 4K1+K2=17 and 19K1+K2=10
• It leads K1=3, K2=5, Since gcd(K1, 26)=1.
• The key K = (3, 5) gives a meaningful plaintext: “algorithms are
quite general definitions of arithmetic processes”

36
10 July 2018 CS 701
Thank You

10 July 2018 CS 701 37