02. Symmetric Cipher
02. Symmetric Cipher
Outline
• Overview of Cryptography •
Classical Symmetric Cipher •
Modern Symmetric Ciphers (DES)
Basic Terminology
• plaintext - the original message
• ciphertext - the 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 •
cryptography - study of encryption principles/methods
• cryptanalysis (codebreaking) - the study of principles/
methods of deciphering ciphertext without knowing key
• cryptology - the field of both cryptography and cryptanalysis
Unconditional vs. Computational
Security • Unconditional security
– No matter how much computer power is available, the
cipher cannot be broken
– The ciphertext provides insufficient information to
uniquely determine the corresponding plaintext
– Only one-time pad scheme qualifies, E.g., OTP
• Computational security
– The cost of breaking the cipher exceeds the value of the
encrypted info
– The time required to break the cipher exceeds the useful
lifetime of the info
– E.g., AES, DES, etc
Brute Force Search
• Always possible to simply try every key •
Most basic attack, proportional to key size
Alternative Keys Time required at 106
Time required at 1 decryptions/µs
decryption/µs
Key Size (bits) Number of
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
years 5.4 × 1018 years 5.9 × 1030 years
Outline
• Overview of Cryptography •
Classical Symmetric Cipher –
Substitution Cipher
– Transposition Cipher
Caesar Cipher
• Define transformation as:
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
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C •
Mathematically give each letter a number a
b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
Monoalphabetic Cipher
• Rather than just shifting the alphabet •
Could shuffle (jumble) the letters arbitrarily
• Each plaintext letter maps to a different random
ciphertext letter
utjSeUq_c&t=12s
• Key is 26 letters long
https://www.youtube.com/watch?v=J
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext:
WIRFRWAJUHYFTSDVFSFUUFYA
Example
Cryptanalysis • Given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Playfair Cipher
• not even the large number of keys in a
monoalphabetic cipher provides security
• one approach to improving security was to
encrypt multiple letters
• the Playfair Cipher is an example
• invented by Charles Wheatstone in 1854, but
named after his friend Baron Playfair
Playfair Cipher
• a 5X5 matrix of letters based on a keyword
• fill in letters of keyword (sans duplicates) •
fill rest of matrix with other letters • Eg. Using
the keyword Abhi or AAAbhiiii
A B H I/J C
DEFGK
LMNOP
QRSTU
VWXYZ
Playfair Cipher:
Encryption 4. Code will be formed using
3 rules:
i. if both letters fall in the same row, replace each with
letter to right (wrapping back to start from end)
ii. if both letters fall in the same column, replace each
with the letter below it (again wrapping to top from
bottom)
iii. Otherwise, each letter is replaced by the letter in the
same row and in the column of the other letter of the
pair
Playfair Cipher
A B H I/J C D E F G K L M N O P Q R S T U
VWXYZ
https://www.geeksforgeeks.org/vernam-cipher-in-cryptography/
Example
Vernan Cipher: Example
Vernan Cipher: Example
Vernam Cipher: Cryptoanalysis
• The system worked with a very long but repeating
keyword.
• This technique can be broken with sufficient
ciphertext, the use of known or probable plaintext
sequences, or both.
One time pad
• The two requirements for the One-Time pad are
– The key should be randomly generated as long as
the size of the message.
– The key is to be used to encrypt and decrypt a
single message, and then it is discarded.
One time pad
• So encrypting every new message requires a
new key of the same length as the new message
in one-time pad.
• The ciphertext generated by the One-Time pad
is random, so it does not have any statistical
relation with the plain text.
One time pad
One time pad
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
▪ Ciphertext: GSGSEKFREKEOE
Rail fence cipher
Rail Fence Cipher
• Write message letters out diagonally over a
number of rows
• Then read off cipher row by row
• E.g., write message out as:
m e m a t r h t g p r y
e t e f e t e o a a t
• Giving ciphertext
MEMATRHTGPRYETEFETEOAAT
https://www.geeksforgeeks.org/block-cipher-design-principles/
https://engineering.purdue.edu/kak/compsec/NewLectures/Lecture3.pdf
Feistel
Cipher
Structur
e
Feistel Cipher
Decryption
Electronic Code
Book-Encryption
https://www.youtube.com/watch?v=-j80aA8q_IQ&t=1001s
56 bits
Overview of DES Algorithm
Per-Round Key
Generation Initial Permutation of DES
key
C i-1 D i-1
28 bits 28 bits