Cipher Techniques
April 9, 2013
1
Road Map
Basic Terminology
Cryptosystem
Classical Cryptography
Algorithm Types and Modes
Data Encryption Standard
Other Stream & Block Ciphers
April 9, 2013
2
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
April 9, 2013
3
Cryptosystem
A cryptosystem is a five-tuple (P,C,K,E,D),
where the following are satisfied:
1. P is a finite set of possible plaintexts.
2. C is a finite set of possible ciphertexts.
3. K, the key space, is a finite set of possible
keys
4. ∀K∈K, ∃EK∈E (encryption rule), ∃DK∈D
(decryption rule).
Each EK: P→C and DK: C→P are functions
such that ∀x∈P, DK(EK(x)) = x.
April 9, 2013
4
Cryptography
Cryptography
Symmetric / private key / single key
Asymmetric / public-key / two - key
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
adversary’s attacks cipher
can be weaker chosen text
April 9, 2013
select either plaintext or ciphertext to en/decrypt 10
to
Brute Force Search
always possible to simply try every key
most basic attack, proportional to size of key
space
assume either know / recognise plaintext
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
can recognise these since have the same
frequency distribution as the original text
April 9, 2013
12
Rail Fence cipher
writemessage letters out diagonally over a
number of rows
then read off cipher row by row
eg. 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
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
first attested use in military affairs
replaces each letter by 3rd letter after it
example:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
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
invented by Charles Wheatstone in 1854, but
named after his friend Baron Playfair
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
key is multiple letters long K = k1 k2 ... kd
ith letter specifies ith alphabet to use
use each alphabet in turn
repeat from start after d letters in message
decryption simply works in reverse
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