Ciphers
Ciphers
April 9, 2013
1
Road Map
Basic Terminology
Cryptosystem
Classical Cryptography
April 9, 2013
2
Basic Terminology
April 9, 2013
3
Cryptosystem
April 9, 2013
5
Symmetric Cryptography
April 9, 2013
6
Asymmetric Cryptography
April 9, 2013
7
Requirements
Two requirements for secure use of
symmetric encryption:
a strong encryption algorithm
a secret key known only to sender / receiver
Y = EK(X)
X = DK(Y)
assume encryption algorithm is known
implies a secure channel to distribute key
April 9, 2013
8
Symmetric cryptography
Transposition Techniques
Substitution techniques
Caesar Cipher
Monoalphabetic Cipher
Polyalphabethic Cipher
Playfair Cipher
April 9, 2013
9
Types of Cryptanalytic Attacks
adversary needs
strongest attack ciphertext only
only know algorithm / ciphertext, statistical, can
identify plaintext, or worse: the key
known plaintext
know/suspect plaintext & ciphertext to attack
cipher
chosen plaintext
select plaintext and obtain ciphertext to attack
cipher
chosen ciphertext
select ciphertext and obtain plaintext to attack
April 9, 2013
11
Transposition Ciphers
Consider classical transposition or
permutation ciphers
these hide the message by rearranging the
letter order
without altering the actual letters used
April 9, 2013
12
Rail Fence cipher
writemessage letters out diagonally over a
number of rows
then read off cipher row by row
April 9, 2013
13
Row Transposition Ciphers
a more complex scheme
write letters of message out in rows over a
specified number of columns
then reorder the columns according to some
key before reading off the rows
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
April 9, 2013
14
Classical Substitution Ciphers
where 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
April 9, 2013
15
Caesar Cipher
earliest known substitution cipher
by Julius Caesar
example:
April 9, 2013
16
Caesar Cipher
can 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
then have Caesar cipher as:
C = E(p) = (p + k) mod (26)
p = D(C) = (C – k) mod (26)
April 9, 2013
17
Monoalphabetic Cipher
rather than just shifting the alphabet
could shuffle (jumble) the letters arbitrarily
each plaintext letter maps to a different random
ciphertext letter
hence key is 26 letters long
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
April 9, 2013
18
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
April 9, 2013
19
Playfair Key Matrix
a 5X5 matrix of letters based on a keyword
(I and J aren’t distinguished)
fill in letters of keyword (sans duplicates)
fill rest of matrix with other letters
eg. using the keyword MONARCHY
MONAR
CHYBD
EFGIK
LPQST
UVWXZ
April 9, 2013
20
Encrypting and Decrypting
plaintext encrypted two letters at a time:
1. each letter is replaced by the one in its row in the column
of the other letter of the pair, eg. “hs" encrypts to "BP",
and “ea" to "IM" or "JM" (as desired). Except when that
doesn’t work!
2. if a pair is a repeated letter, insert a filler like 'X', eg.
"balloon" transformed to "ba lx lo on"
3. if both letters fall in the same row, replace each with
letter to right (wrapping back to start from end), eg.
“ar" encrypts as "RM"
4. if both letters fall in the same column, replace each with
the letter below it (again wrapping to top from bottom),
eg. “mu" encrypts to "CM"
April 9, 2013
21
Polyalphabetic Ciphers
another approach to improving security is to use
multiple cipher alphabets
called polyalphabetic substitution ciphers
makes cryptanalysis harder with more alphabets to
guess and flatter frequency distribution
use a key to select which alphabet is used for each
letter of the message
use each alphabet in turn
repeat from start after end of key is reached
April 9, 2013
22
Vigenère Cipher
simplest polyalphabetic substitution cipher is
the Vigenère Cipher
effectively multiple caesar ciphers
April 9, 2013
23
Example
write the plaintext out
write the keyword repeated above it
use each key letter as a caesar cipher key
encrypt the corresponding plaintext letter
eg using keyword deceptive
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
April 9, 2013
24
Autokey Cipher
ideally want a key as long as the message
Vigenère proposed the autokey cipher
with keyword is prefixed to message as key
knowing keyword can recover the first few letters
use these in turn on the rest of the message
but still have frequency characteristics to attack
eg. given key deceptive
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
April 9, 2013
25