2. Pfleeger, Security in Computing, ch. 2. Chapter Outline. • 2.1 Terminology and
Background. • 2.2 Substitution Ciphers. • 2.3 Transpositions (Permutations).
Security in Computing Chapter 2 Elementary Cryptography
Pfleeger, Security in Computing, ch. 2
1
Chapter Outline • • • • • • • • •
2.1 Terminology and Background 2.2 Substitution Ciphers 2.3 Transpositions (Permutations) 2.4 Making “Good” Encryption Algorithms 2.5 The Data Encryption Standard (DES) 2.6 The AES Encryption Algorithm 2.7 Public Key Encryption 2.8 Uses of Encryption 2.9 Summary
Pfleeger, Security in Computing, ch. 2
2
Elementary Cryptography • important tool • rooted in some heavy-duty math – – – –
number theory group & field theory computational complexity probability
• our goal: – be able to intelligently use crypto – not design/break cryptosystems
• some more detailed analysis in ch. 10 Pfleeger, Security in Computing, ch. 2
3
Chapter Outline • • • • • • • • •
2.1 Terminology and Background 2.2 Substitution Ciphers 2.3 Transpositions (Permutations) 2.4 Making “Good” Encryption Algorithms 2.5 The Data Encryption Standard (DES) 2.6 The AES Encryption Algorithm 2.7 Public Key Encryption 2.8 Uses of Encryption 2.9 Summary
Pfleeger, Security in Computing, ch. 2
4
Text’s Notation • S sender
O might try to:
• R recipient
• block
• T trans. medium • O outsider or intruder
Pfleeger, Security in Computing, ch. 2
• intercept • modify • fabricate
5
Terminology • • • • •
encryption (or encipher) decryption (or decipher) note: encode/decode different meaning plaintext ciphertext
Pfleeger, Security in Computing, ch. 2
6
Graphical View plaintext
encryption
Pfleeger, Security in Computing, ch. 2
ciphertext
decryption
plaintext
7
Notation • denote plaintext P = • denote ciphertext C = • Example: – – – –
plaintext “I like cheesy poofs” P = ciphertext “X QXVC JMCCZB ARREZ” C =
• More formally: – C=E(P) – P=D(E(P))
P=D(C)
Pfleeger, Security in Computing, ch. 2
8
How Codes Are Different • code uses linguistic units • codebook is the key word
code
bored car poultry students .
9685 2307 7902 1092 .
.
.
Pfleeger, Security in Computing, ch. 2
bored students 9685 1092
• may use phrases as well • e.g., “return to base for supplies” enciphered GIDIZZLEDUNK 9
Cryptographic Keys • most algorithms use keys • encryption: – C = E(K, P) – P = D(K, C) – P = D(K, E(K,P))
Pfleeger, Security in Computing, ch. 2
10
Cryptosystem • Cryptographic algorithm (aka cipher) – mathematical function used for encrypt
• Cryptosystem consists of: – cryptographic algorithm – set of all possible plaintexts – set of all possible ciphertexts
Pfleeger, Security in Computing, ch. 2
11
Symmetric Algorithm • encryption, decryption keys are the same key plaintext
encryption
Pfleeger, Security in Computing, ch. 2
ciphertext
decryption
plaintext
12
Asymmetric Algorithm • encryption, decryption keys different • encryption key: KE • decryption key: KD – C = E(KE, P) – P = D(KD,C) – P = D(KD, E(KE, P))
Pfleeger, Security in Computing, ch. 2
13
Asymmetric Algorithm Diagram KE
plaintext
encryption
Pfleeger, Security in Computing, ch. 2
KD
ciphertext
decryption
plaintext
14
Restricted Algorithms • algorithm itself is secret • security of algorithm depends on its secrecy • bad idea: – can’t be used by large or changing group – if one accidentally reveals algo, everyone must change – how do you know if the algo is strong?
• think of regular (i.e., physical) locks Pfleeger, Security in Computing, ch. 2
15
Kerckhoff’s Principle • secrecy must reside entirely with the key • must assume that the enemy has complete details of the cryptographic algorithm • Kerkhoff’s assumption: people will: – reverse engineer your algorithm – disassemble your code – e.g., RC4 in 1994
Pfleeger, Security in Computing, ch. 2
16
Cryptology
Cryptography
Pfleeger, Security in Computing, ch. 2
Cryptanalysis
17
Cryptanalysis • Cryptanalyst tries to break an algorithm • Categories (due to Lars Knudsen) – total break - find the key K such that D(K,C)=P – global deduction - find alternative algorithm, A, equivalent to D(K,C) without knowing K – instance (or local) deduction - find the plaintext of an intercepted ciphertext – information deduction - get some information about the key or plaintext, e.g., first bits of the key, info about the form of the plaintext, …
• Attempt at cryptanalysis called an attack Pfleeger, Security in Computing, ch. 2
18
How is Cryptanalysis Done? • Analyst works with whatever is available: – – – – – – –
encrypted messages known algorithms intercepted plaintext known or suspected plaintext properties of the likely plaintext properties of computers properties of network protocols
Pfleeger, Security in Computing, ch. 2
19
Breakable Encryption • • • • •
breakable algorithm breakable but not practical to break more breakable with tricks effects of sloppy procedures Moore’s law
Pfleeger, Security in Computing, ch. 2
20
Character Arithmetic • Usually don't consider case • Can do arithmetic on letters • Example: A+2, Y+5, etc.
Letter A B C D E F G H I J K L M Code 0 1 2 3 4 5 6 7 8 9 10 11 12 Letter N O P Q R S T U V W X Y Z Code 13 14 15 16 17 18 19 20 21 22 23 24 25 • What if you go past the end, e.g. Y+3? Pfleeger, Security in Computing, ch. 2
21
modular arithmetic – quick review a and b are integers, b ≥ 1 divide a by b (using regular long division) result is: q (quotient) r (remainder or residue)
a = qb + r, where 0 ≤ r < b r = a mod b Pfleeger, Security in Computing, ch. 2
22
Cryptographic Elements • Primitive operations: – substitutions - exchange one letter for another – transpositions – rearrange the order of the letters
Pfleeger, Security in Computing, ch. 2
23
Chapter Outline • • • • • • • • •
2.1 Terminology and Background 2.2 Substitution Ciphers 2.3 Transpositions (Permutations) 2.4 Making “Good” Encryption Algorithms 2.5 The Data Encryption Standard (DES) 2.6 The AES Algorithm 2.7 Public Key Encryption 2.8 Uses of Encryption 2.9 Summary
Pfleeger, Security in Computing, ch. 2
24
Keyword Mixed Alphabet • Form ciphertext alphabet by: – pick a keyword – spell it without duplicates – then, fill in the rest of the alphabet in order
• Example, keyword VACATION A ABCDEFGHIJKLMNOPQRSTUVWXYZ C V A C T I O N B DE F G H J K L M P Q R S U W X Y Z
• Encrypt “I should be sailing” as: – DQBK SGTA IQVD GDJN Pfleeger, Security in Computing, ch. 2
25
Another Substitution • Shift plaintext chars. three characters A: A B C D E F G H I J K L M C: D E F G H I J K L M N O P A: N O P Q R S T U V W X Y Z C: Q R S T U V W X Y Z A B C
• Example: – P = “Old School cracked me up” – C = ROG VFKRRO FUDFNHG PH XS Pfleeger, Security in Computing, ch. 2
26
Another Substitution • Shift plaintext chars. three characters A: A B C D E F G H I J K L M C: D E F G H I J K L M N O P A: N O P Q R S T U V W X Y Z C: Q R S T U V W X Y Z A B C
• Example: – P = “Old School cracked me up” notice wrap – C = ROG VFKRRO FUDFNHG PH XS Pfleeger, Security in Computing, ch. 2
27
Another Substitution • Shift plaintext chars. three characters A: A B C D E F G H I J K L M C: D E F G H I J K L M N O P A: N O P Q R S T U V W X Y Z C: Q R S T U V W X Y Z A B C
• Algorithm called Caesar Cipher notice wrap Pfleeger, Security in Computing, ch. 2
28
Caesar Example A C
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 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 • What is: VFUXEV LV D IXQQB VKRZ ?
Pfleeger, Security in Computing, ch. 2
29
Caesar Cipher (more formal def) • encryption: – EK(m) = m + 3 mod 26
• decryption: – DK(c) = c – 3 mod 26
• review: – if a and m are positive integers, a mod m is the remainder when a is divided by m
• Caesar cipher special case of shift cipher Pfleeger, Security in Computing, ch. 2
30
Shift Cipher • encryption: – EK(m) = m + K mod 26
• decryption: – DK(c) = c – K mod 26
• example: k=5 A: 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 C: F G H I J K L M N O P Q R S T U V W X Y Z A B C D E • “summer vacation was too short” encrypts to – XZRR JWAF HFYN TSBF XYTT XMTW Y Pfleeger, Security in Computing, ch. 2
31
Breaking Shift Ciphers • How difficult? • How many possibilities? • Example: – AKZC JAQA IZMI TTGN CVVG APWE
Pfleeger, Security in Computing, ch. 2
32
First 13 Possibilities 0 1 2 3 4 5 6 7 8 9 10 11 12
A B C D E F G H I J K L M
K L M N O P Q R S T U V W
Z A B C D E F G H I J K L
C D E F G H I J K L M N O
J K L M N O P Q R S T U V
A B C D E F G H I J K L M
Q R S T U V W X Y Z A B C
A B C D E F G H I J K L M
Pfleeger, Security in Computing, ch. 2
I J K L M N O P Q R S T U
Z 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
I J K L M N O P Q R S T U
T U V W X Y Z A B C D E F
T U V W X Y Z A B C D E F
G H I J K L M N O P Q R S
N O P Q R S T U V W X Y Z
C D E F G H I J K L M N O
V W X Y Z A B C D E F G H
V W X Y Z A B C D E F G H
G H I J K L M N O P Q R S
A B C D E F G H I J K L M
33
P Q R S T U V W X Y Z A B
W X Y Z A B C D E F G H I
Last 13 Possibilities 13 14 15 16 17 18 19 20 21 22 23 24 25
N O P Q R S T U V W X Y Z
X Y Z A B C D E F G H I J
M N O P Q R S T U V W X Y
P Q R S T U V W X Y Z A B
W X Y Z A B C D E F G H I
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
N O P Q R S T U V W X Y Z
V W X Y Z A B C D E F G H
Pfleeger, Security in Computing, ch. 2
M N O P Q R S T U V W X Y
Z A B C D E F G H I J K L
V W X Y Z A B C D E F G H
G H I J K L M N O P Q R S
G H I J K L M N O P Q R S
T U V W X Y Z A B C D E F
A B C D E F G H I J K L M
P Q R S T U V W X Y Z A B
I J K L M N O P Q R S T U
I J K L M N O P Q R S T U
T U V W X Y Z A B C D E F
N O P Q R S T U V W X Y Z
C D E F G H I J K L M N O
J K L M N O P Q R S T U V
34
R S T U V W X Y Z A B C D
So easily crackable • Someone should have explained this to the mafia boss: http://dsc.discovery.com/news/briefs/20060417/mafi aboss_tec.html?source=rss
Pfleeger, Security in Computing, ch. 2
35
Monoalphabetic Ciphers • simple substitutions, e.g., shift, keyword mixed, newspapaer cryptogram ... are monoalphabetic ciphers • how many possible substitution alphabets? • can we try all permutations? • how would you try to break them?
Pfleeger, Security in Computing, ch. 2
36
monoalphabetic – brute force • how many possible substitution alphabets? – 26! ≈ 4 * 1026
• can we try all permutations? – sure. have some time? – at 1 test/μsec, about 12 trillion years.
• how would you try to break them? – use what you know to reduce the possibilities
Pfleeger, Security in Computing, ch. 2
37
breaking substitutions • how do you break the newspaper cryptogram? – look at common letters (E, T, O, A, N, ...) – single-letter words (I, and A) – two-letter words (of, to, in, ...) – three-letter words (the, and, ...) – double letters (ll, ee, oo, tt, ff, rr, nn, ...) – other tricks? Pfleeger, Security in Computing, ch. 2
38
breaking substitutions (cont'd) • use language statistics of plaintext – English, java, TCP packet headers, etc.
• example: – frequencies in English char: A B C D E F G H I J K L M pct: 8 1.5 3 4 13 2 1.5 6 6.5 0.5 0.5 3.5 3 char: N O P Q R S T U V W X Y Z pct: 7 8 2 0.25 6.5 6 9 3 1 1.5 0.5 2 0.25 Pfleeger, Security in Computing, ch. 2
39
Character Frequencies (English) 14 12 10
percent
8 6 4 2 0
A B C D E F G H
I
Pfleeger, Security in Computing, ch. 2
J
K L M N O P Q R S T U V W X Y Z
characters
40
Common English Digrams and Trigrams Digrams EN RE ER NT TH ON IN TF AN OR Pfleeger, Security in Computing, ch. 2
Trigrams ENT ION AND ING IVE TIO FOR OUR THI ONE 41