Symmetric Encryption and Message
Confidentiality
By
Dr. Amjad Ali
Department of Computer Science,
COMSATS University Islamabad, Lahore Campus
Outline
Overview of Cryptography
Classical Symmetric Cipher
Substitution Cipher
Transposition Cipher
Modern Symmetric Ciphers (DES)
Secret Key Cryptography
Important
Each party needs access to the secret key
This needs to be known to both sides, but needs to be kept secret
Usually in cryptography the parties are denoted by
Alice
Bob
Someone listening is denoted by
Eve (Eavesdropper)
What is Cryptography?
It all started with
Encryption / Decryption
Cryptography
Cryptography means “hidden writing” (in Greek).
It is the study of encoding meaningful information (also called the
message or the plaintext) using a secret transformation function (called
the cipher) so that nobody will understand the encoded message (called
the ciphertext) unless they have knowledge of the cipher.
The process of encoding plaintext to ciphertext is called encryption.
The process of decoding ciphertext back to the original message
(plaintext) is called decryption.
Conventional cryptography
Shared Secret (key)
Sender Receiver
plaintext
plaintext
Ciphertext
Encryption Decryption
Attacker
Types of Cryptographic Functions
Cryptographic Functions
Secret Key Public Key
Hash Functions
Cryptography Cryptography
Use of one key Use of two keys Use of no key
Secret Key Cryptography
Involves the use of single key
Sometimes referred as conventional cryptography or symmetric
cryptography
Secret Key Cryptography
Uses of Secret Key Cryptography
Transmitting Over an Insecure Channel
Secure Storage on Insecure Media
Authentication
Integrity Check
Transmitting Over an Insecure Channel
Secure Storage on Insecure Media
Secret Key Cryptography
The number and size of keys must be large to prevent exhaustive search
Worst case assumptions - assume attacker has
Full knowledge of the cipher algorithm F()
A number of plaintext/ciphertext pairs associated to the target key k
The cipher designer must play the role of the cryptanalyst.
In practice ciphers are used which are believed to be strong
All this means is that the best attempts of experienced cryptanalysts cannot
break them.
Symmetric Encryption
Conventional / private-key / single-key
Sender and recipient share a common key
All classical encryption algorithms are private-key
It was the only type prior to invention of public-key in 1970’s
By far most widely used
Shift Cipher
Each letter we identify with a number
A=0
B=1
C=2
...
Z = 25
The key k is a number in the range 0 − 25
Encryption is add k onto each letter modulo 26.
Use the key k = 3.
HELLO becomes
KHOOR
ROT-13 cipher
The ROT-13 cipher was commonly used to hide the meaning of
messages on the Internet (particularly on Usenet and E-mail).
Each letter in the plaintext is substituted with the ciphertext letter
according to the following mapping:
p : ABCDEFGHIJKLMNOPQRSTUVWXYZ
F(p) : NOPQRSTUVWXYZABCDEFGHIJKLM
ROT-13 cipher (2)
Example:
Plain text: This Is A Secret
Ciphertext : GUVF VF N FRPERG
The ROT-13 cipher is involution (e.g., self reverse) so that encoding
twice will result in original message.
This means separate decoding function is not needed
Cryptanalysis of Shift Cipher
Only have 25 possible ciphers
A maps to B,..Z
Given ciphertext: just try all shifts of letters
Do need to recognize when have plaintext
E.g., break ciphertext "GCUA VQ DTGCM"
Example: Exhaustive key search
Suppose we have the ciphertext:
TYQZCXLETZYDPNFCTEJ
We decrypt the ciphertext by trying all 25 possible valid keys:
Example: Exhaustive key search (2)
1. UZRADYMFUAZEQOGDUFK 14.HMENQLZSHNMRDBTQHSX
2. VASBEZNGVBAFRPHEVGL 15.INFORMATIONSECURITY
3. WBTCFAOHWCBGSQIFWHM 16.JOGPSNBUJPOTFDVSJUZ
4. XCUDGBPIXDCHTRJGXIN 17.KPHQTOCVKQPUGEWTKVA
5. YDVEHCQJYEDIUSKHYJO 18.LQIRUPDWLRQVHFXULWB
6. ZEWFIDRKZFEJVTLIZKP 19.MRJSVQEXMSRWIGYVMXC
7. AFXGJESLAGFKWUMJALQ 20.NSKTWRFYNTSXJHZWNYD
8. BGYHKFTMBHGLXVNKBMR 21.OTLUXSGZOUTYKIAXOZE
9. CHZILGUNCIHMYWOLCNS 22.PUMVYTHAPVUZLJBYPAF
10.DIAJMHVODJINZXPMDOT 23.QVNWZUIBQWVAMKCZQBG
11.EJBKNIWPEKJOAYQNEPU 24.RWOXAVJCRXWBNLDARCH
12.FKCLOJXQFLKPBZROFQV 25.SXPYBWKDSYXCOMEBSDI
13.GLDMPKYRGMLQCASPGRW
Monoalphabetic Cipher
Rather than just shifting the alphabet
Could shuffle (jumble) the letters arbitrarily
Each plaintext letter maps to a different random ciphertext letter
Key is 26 letters long
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
Cipher: D K V Q F I B J W P E S C X H T M YAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
Monoalphabetic Cipher Security
Now have a total of 26! = 4 x 1026 keys
Is that secure?
Problem is language characteristics
Human languages are redundant
Letters are not equally commonly used
English Letter Frequencies
Note that all human languages have varying letter frequencies, though the
number of letters and their frequencies varies.
Example Cryptanalysis
Given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
How we can break this ciphertext ?
Example Cryptanalysis
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
One-Time Pad
If a truly random key as long as the message is used, the cipher will be
secure - One-Time Pad (e.g., a random sequence of 0’s and 1’s XORed
to plaintext, no repetition of keys)
Unbreakable since ciphertext bears no statistical relationship to the
plaintext
For any plaintext, it needs a random key of the same length
Hard to generate large amount of keys
Have problem of safe distribution of key
Transposition Ciphers
Now consider classical transposition or permutation ciphers
These hide the message by rearranging the letter order, without
altering the actual letters used
Can recognise these since have the same frequency distribution as
the original text
Rail Fence Cipher (Encryption)
For encryption we write the message diagonally in zigzag form in a matrix
having total rows = key and total columns = message length.
Then read the matrix row wise horizontally to get encrypted message.
Example:
Key = 2
Plaintext : Exam date is changed
Ciphertext: Eadticagdxmaeshne
E a d t i c a g d
x m a e s h n e
Rail Fence Cipher (Decryption)
Key = 2
Ciphertext:Eadticagdxmaeshne
Plaintext: Exam date is changed
E a d t i c a g d
x m a e s h n e
Product Ciphers
Ciphers using substitutions or transpositions are not secure because of
language characteristics
Hence consider using several ciphers in succession to make harder, but:
Two substitutions make another substitution
Two transpositions make a more complex transposition
But a substitution followed by a transposition makes a new much harder
cipher
This is bridge from classical to modern ciphers
Rotor Machines
Before modern ciphers, rotor machines were
most common complex ciphers in use
Widely used in WW2
Implemented a very complex, varying
substitution cipher