Sei sulla pagina 1di 51

Cryptography

 Cryptographic systems are characterized along three


independent dimensions:
The type of operations used for transforming
plaintext to ciphertext.
The number of keys used.
The way in which the plaintext is processed.
3- Dimensions of cryptography

1- The type of operations used for transforming


plaintext to ciphertext.
All encryption algorithms are based on two general
principles: substitution, in which each element in the
plaintext (bit, letter, group of bits or letters) is mapped into
another element, and transposition, in which elements in
the plaintext are rearranged. The fundamental requirement
is that no information be lost (i.e., that all operations are
reversible). Most systems, referred to as product systems,
involve multiple stages of substitutions and transpositions.
3- Dimensions of cryptography

2- The number of keys used.


If both sender and receiver use the same key, the system
is referred to as symmetric, single-key, secret-key, or
conventional encryption. If the sender and receiver use
different keys, the system is referred to as asymmetric,
two-key, or public-key encryption.
3- Dimensions of cryptography

3- The way in which the plaintext is processed.


A block cipher processes the input one block of elements
at a time, producing an output block for each input block. A
stream cipher processes the input elements continuously,
producing output one element at a time, as it goes along.
Unconditional Security Vs Computational
Security
 Unconditional Security
 The cipher cannot be broken no matter how much
computer power or time is available
 The only example is OTP (one time passwords)
 Computational Security
 The cipher cannot be broken given limited computing
resources
 The examples are DES, AES, RC4, etc.
Kerckhoff’s Principle

 In modern cryptography, the assumptions are


 Algorithm is public
 Key is secret
Secret Vs Public Algorithm
 Benefits of having algorithm secret
 Two levels of secrecy
 Benefits of having algorithm public
 Peer review & evaluation
Cryptanalysis and Brute-Force Attack

 Typically, the objective of attacking an encryption system


is to recover the key in use rather than simply to recover
the plaintext of a single ciphertext. There are two general
approaches to attacking a conventional encryption
scheme:
Cryptanalysis

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.
Brute Force Attack

 Try every possible combination until you find the


result
Key Size (bits) Number of Time required at 1 Time required at 106
Alternative 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 5.4  1018 years
years
168 2168 = 3.7  1050 2167 µs = 5.9  1036 5.9  1030 years
years
26 characters 26! = 4  1026 2  1026 µs= 6.4  1012 6.4  106 years
(permutation) years
Classical Ciphers
 Substitution Ciphers
 Transposition Ciphers
Substitution Ciphers
 Substitution Ciphers
 Shift Ciphers (Caesar Cipher)
 Monoalphabetic
 Polyalphabetic
 Letters of plaintext are replaced by other letters, numbers or symbols
The Caesar cipher (e.g)

 The Caesar cipher is a substitution cipher, named after


Julius Caesar.

 Operation principle:
each letter is translated into the letter a fixed number of
positions after it in the alphabet table.

 The fixed number of positions is a key both for


encryption and decryption.
The Caesar cipher

K=3
Outer: plaintext

Inner: ciphertext
An example
 For a key K=3,
plaintext letter: ABCDEF...UVWXYZ
ciphtertext letter: DEF...UVWXYZABC
 Hence
TREATY IMPOSSIBLE
is translated into
WUHDWB LPSRVVLEOH
Concepts

 A private key cipher is composed of two algorithms


 encryption algorithm E
 decryption algorithm D
 The same key K is used for encryption & decryption
 K has to be distributed beforehand
Caesar Cipher

 If each letter is assigned a number (a=0, z=25),


Encryption/Decryption defined as:
C = E(p) = (P + 3) mod (26)
P = D(c) = (C – 3) mod (26)
 Example:
meet me after the toga party
phhw ph diwhu wkh wrjd sduwb
Caesar Cipher: Encryption Example
 K=7
 P = Rome is the greatest empire
 C = yvtl pz aol nylhalza ltwpyl
Caesar Cipher: Decryption Example

 K=7
 C = yvtl dhz uva ibpsa pu h khf
 P = Rome was not built in a day
Caesar Cipher: Decryption with Unknown Key

 C=tfnriujuzvdrepkzdvjsvwfivkyvziuvrkyjkyvmrczrekevmvikrjkvfwuvrkyslkfetv
 tfnriuj uzv drep kzdvj svwfiv kyvzi uvrkyj; kyv mrczrek evmvi krjkv fw uvrky
slk fetv
 P = Cowards die many times before their deaths; the valiant never taste of
death but once. (K = 17)
 Julius Caesar by William Shakespeare
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
Monoalphabetic Cipher

 Instead of substituting each letter in a sequential order


(shift), substitute the letters arbitrarily
 Each plaintext letter maps to a unique ciphertext letter
 Hence key is 26 letters long
Monoalphabetic Cipher Security

 How many total keys are there?


 26! = 4 x 1026 keys
 With so many keys, is it secure?
 No
 It is secure against brute force attack but problem lies in
language characteristics
 Called frequency analysis attack
Language Redundancy and Cryptanalysis

 Human languages are redundant


 Thats why we can compress text files
 Letters are not equally commonly used
 Which is the most common letter?
 E
 Which is the least common letter?
 Z
English Letter Frequencies
Language Redundancy and Cryptanalysis

 Have tables of single, double & triple letter


frequencies for various languages
 Which is the most common digram?
 TH
 Which is the most common trigram?
 THE
Use in Cryptanalysis

 Key concept – mono-alphabetic substitution


ciphers do not change relative letter frequencies
 Each occurrence of a particular plaintext letter
maps to the same ciphertext letter
 So attack is easy:
 Calculate letter frequencies for ciphertext
 Compare counts/plots against known values
Example Cryptanalysis

 Given ciphertext
uzqsovuohxmopvgpozpevsgzwszopfpesxudbmetsxaiz
vuephzhzshzowsfpappdtsvpquzwymxuzuhsxepyepopd
zszufpombzwpfupzhmdjudtmohmq
 Frequency Analysis

P 13.33 H 5.83 F 3.33 B 1.67 C 0.00

Z 11.67 D 5.00 W 3.33 G 1.67 K 0.00


S 8.33 E 5.00 Q 2.50 Y 1.67 L 0.00
U 8.33 V 4.17 T 2.50 I 0.83 N 0.00
O 7.50 X 4.17 A 1.67 J 0.83 R 0.00
M 6.67
Example Cryptanalysis

 Guess P & Z are E and T, respectively


 utqsovuohxmoevgeoteevsgtwstoefeesxud
bmetsxaitvueehthtshtowsfeaeedtsvequt
wymxutuhsxeeyeeoedtstufeombtwefuethm
djudtmohmq
Example Cryptanalysis

 Among digrams starting with Z, ZW has the


highest occurrence (3 times)
 Guess ZW is TH
 Utqsovuohxmoevgeoteevsgthstoefeesxud
bmetsxaitvueehthtshtowsfeaeedtsvequt
hymxutuhsxeeyeeoedtstufeombthefuethm
djudtmohmq
 Hence ZWP is THE
Example Cryptanalysis

 Utqsovuohxmoevgeoteevsgthstoefeesxud
bmetsxaitvueehthtshtowsfeaeedtsvequt
hymxutuhsxeeyeeoedtstufeombthefuethm
djudtmohmq
 Guess S is A
 Utqaovuohxmoevgeoteevagthatoefeeaxud
bmetaxaitvueehthtahtowafeaeedtavequt
hymxutuhaxeeyeeoedtatufeombthefuethm
djudtmohmq
Example Cryptanalysis

 U, V and M may correspond to O, I and N


 Continuing with trial and error, we finally get the
following plaintext
It was disclosed yesterday that several
informal but direct contacts have been
made with political representatives of the
Viet Cong in Moscow
Polyalphabetic Ciphers

 Improve security using different cipher letters for


different occurrences of same plaintext letter
 Make cryptanalysis harder with more letters to
guess and flatter frequency distribution
 Use a key to select which cipher letter is used
for each letter of the message
 Repeat from start after end of key is reached
Vigenère Cipher

 Simplest polyalphabetic substitution cipher


 Effectively multiple Caesar ciphers
 Key is multiple letters long K = k1 k2 ... kd
 ith letter specifies ith alphabet to use
 Repeat from start after d letters in message
 Decryption simply works in reverse
Example of Vigenère Cipher

 Write the plaintext out


 Write the keyword repeated
 Use each key letter as a Caesar cipher key
 Encrypt the corresponding plaintext letter
 Eg using keyword deceptive
plaintext: wearediscoveredsaveyourself
key: deceptivedeceptivedeceptive
ciphertext: zicvtwqngrzgvtwavzhcqyglmgj
Security of Vigenère Cipher

 Much more secure than the ciphers we discussed earlier


 Have multiple ciphertext letters for each plaintext letter
 Hence letter frequencies are obscured
 But not totally lost
Security of Vigenère Ciphers

 Need to determine key size, since then can attack each


Caesar cipher
 Repetitions in ciphertext give clues to period
 Find same plaintext an exact period apart which results
in the same ciphertext
 E.g, repeated “VTW” in previous example is at a
distance of 9 (zicvtwqngrzgvtwavzhcqyglmgj)
One-Time Pad

 If a truly random key as long as the message is


available, we can build an unbreakable cipher called a
one-time pad
 It is unconditionally secure since ciphertext bears no
statistical relationship to the plaintext
Problems with OTP

 Key must be as long as the plaintext

 Key cannot be repeated

 Distribution of keys is an even bigger issue


Transposition Ciphers

 Transposition Ciphers hide the message by rearranging


the letter order
 No substitution takes place
 Relative letter frequency remains unchanged so these
are good candidates for frequency analysis attack
Rail Fence Cipher

 Write message letters out diagonally over a


number of rows
 Then read off cipher row by row
 Eg. Write message “Meet me after the toga
party” 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
 key=?
 Depth of rail fence (no. of rows)
 Easy to attack using frequency analysis
Row Transposition Ciphers
 A more complex transposition
 Write letters of message out in rows over a specified number of columns
 Then reorder the columns according to some key and read column by
column
Key: 3 4 2 1 5 6 7
Plaintext : attack postponed until two am
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
Product Ciphers

 Ciphers using either substitutions or


transpositions are not secure because of
language characteristics
 We can use combinations
 Two substitutions make a more complex substitution
 Two transpositions make more complex
transposition
 But a substitution followed by a transposition makes
a new much harder cipher (product cipher)
 This is bridge from classical to modern ciphers
Row transposition
 Write message row by row in rectangle and read message column by
column, but permute the order of column.

4 3 1 2 5 6 7
m e e t m e a
f t e r t h e
t o g a p a r
t y v w x y z

Ciphertext: eegv traw etoy mftt mtpx ehay


aerz
47
Row transposition

 More than one stage of transposition is more secure

Ciphertext: eegv traw etoy mftt mtpx ehay aerz

4 3 1 2 5 6 7
e e g v t r a
w e t o y mf
t t mt p x e
h a y a e r z
Hill Cipher
 Encryption algo takes m plaintext letter and substitute for them m ciphertext
letters
 The system can be describe as
C = KP mod 26
P = K-1C mod 26

49
Example
 Consider the message 'ACT', and the key below
(or GYBNQKURP in letters):

 Since 'A' is 0, 'C' is 2 and 'T' is 19, the message


is the vector:

 Thus the enciphered vector is given by:

 which corresponds to a ciphertext of 50


'POH‘.
The End

Potrebbero piacerti anche