Intro to Cryptography
CS 161 Fall 2023 - Lecture 6
Computer Science 161
Summary: Memory Safety Vulnerabilities
2
Computer Science 161
Summary: Memory Safety Mitigations
3
Computer Science 161
Summary: Memory Safety Mitigations
4
Computer Science 161
Summary: Memory Safety Mitigations
5
Computer Science 161
Next Unit: Cryptography
6
Computer Science 161
What is cryptography?
7
Textbook Chapter 5.1
Computer Science 161
What is cryptography?
8
Computer Science 161
Don’t try this at home!
9
| |
| February 15, 2017 |
Cryptography is nightmare magic math that cares what kind of pen you use. |
Computer Science 161
Don’t try this at home!
10
Computer Science 161
Definitions
11
Textbook Chapter 5.3–5.9
Computer Science 161
Meet Alice, Bob, Eve, and Mallory
12
Computer Science 161
Meet Alice, Bob, Eve, and Mallory
13
Computer Science 161
Three Goals of Cryptography
14
Computer Science 161
Keys
15
Computer Science 161
Security Principle: Kerckhoff’s Principle
16
Computer Science 161
Confidentiality
17
Message
Key
Lock
Message in locked box
Key
Unlock
Message
Alice
Bob
Insecure Channel
Computer Science 161
Confidentiality
18
Message
Key
Encryption Algorithm
Encrypted Message
Key
Decryption Algorithm
Message
Alice
Bob
Insecure Channel
Computer Science 161
Confidentiality
19
Plaintext
Key
Encryption Algorithm
Ciphertext
Key
Decryption Algorithm
Plaintext
Alice
Bob
Insecure Channel
Computer Science 161
Integrity (and Authenticity)
20
Message
Key
Create Seal
Message
Key
Check Seal
Message
Alice
Bob
Insecure Channel
Seal
Computer Science 161
Integrity (and Authenticity)
21
Message
Key
Create Tag
Message
Key
Check Tag
Message
Alice
Bob
Insecure Channel
Tag
Computer Science 161
Threat Models
22
| Can Eve trick Alice into encrypting messages of Eve’s choosing? | Can Eve trick Bob into decrypting messages of Eve’s choosing? |
Ciphertext-only | No | No |
Chosen-plaintext | Yes | No |
Chosen-ciphertext | No | Yes |
Chosen plaintext-ciphertext | Yes | Yes |
Computer Science 161
Threat Models
23
| Can Eve trick Alice into encrypting messages of Eve’s choosing? | Can Eve trick Bob into decrypting messages of Eve’s choosing? |
Ciphertext-only | No | No |
Chosen-plaintext | Yes | No |
Chosen-ciphertext | No | Yes |
Chosen plaintext-ciphertext | Yes | Yes |
Computer Science 161
Cryptography Roadmap
24
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Symmetric-Key Encryption
25
Textbook Chapter 6.1
Computer Science 161
Cryptography Roadmap
26
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Symmetric-Key Encryption
27
Computer Science 161
Symmetric-Key Encryption: Definition
28
Plaintext
Key
Encryption Algorithm
Ciphertext
Key
Decryption Algorithm
Plaintext
Alice
Bob
Insecure Channel
Computer Science 161
Symmetric-Key Encryption: Definition
29
Plaintext
Key
Encryption Algorithm
Ciphertext
Key
Decryption Algorithm
Plaintext
Alice
Bob
Insecure Channel
Computer Science 161
Defining Confidentiality
30
Computer Science 161
Defining Confidentiality
31
Computer Science 161
Defining Confidentiality: IND-CPA
32
Computer Science 161
Defining Confidentiality: IND-CPA
33
M
Enc(K, M)
(repeat)
Alice (challenger)
Eve (adversary)
Computer Science 161
Defining Confidentiality: IND-CPA
34
M
Enc(K, M)
(repeat)
Alice (challenger)
Eve (adversary)
M0 and M1
Computer Science 161
Defining Confidentiality: IND-CPA
35
M
Enc(K, M)
(repeat)
Alice (challenger)
Eve (adversary)
M0 and M1
Enc(K, Mb)
pick b
Computer Science 161
Defining Confidentiality: IND-CPA
36
M
Enc(K, M)
(repeat)
Alice (challenger)
Eve (adversary)
M0 and M1
Enc(K, Mb)
M
Enc(K, M)
(repeat)
pick b
Computer Science 161
Defining Confidentiality: IND-CPA
37
M
Enc(K, M)
(repeat)
Alice (challenger)
Eve (adversary)
M0 and M1
Enc(K, Mb)
M
Enc(K, M)
Guess b = 0 or b = 1
(repeat)
pick b
Computer Science 161
Defining Confidentiality: IND-CPA
38
Computer Science 161
Edge Cases: Length
39
Computer Science 161
Edge Cases: Attacker Runtime
40
Computer Science 161
Edge Cases: Negligible Advantage
41
Computer Science 161
Edge Cases: Negligible Advantage
42
Computer Science 161
IND-CPA: Putting it together
43
M
Enc(K, M)
(repeat)
Alice (challenger)
Eve (adversary)
M0 and M1
Enc(K, Mb)
M
Enc(K, M)
Guess b = 0 or b = 1
(repeat)
pick b
Computer Science 161
A Brief History of Cryptography
44
Textbook Chapter 5.2
Computer Science 161
Cryptography by Hand: Caesar Cipher
45
K = 3 | |||
M | C | M | C |
A | D | N | Q |
B | E | O | R |
C | F | P | S |
D | G | Q | T |
E | H | R | U |
F | I | S | V |
G | J | T | W |
H | K | U | X |
I | L | V | Y |
J | M | W | Z |
K | N | X | A |
L | O | Y | B |
M | P | Z | C |
Computer Science 161
Cryptography by Hand: Attacks on the Caesar Cipher
46
+1 IBJM DBFTBS
+2 HAIL CAESAR
+3 GZHK BZDRZQ
+4 FYGJ AYCQYP
+5 EXFI ZXBPXO
+6 DWEH YWAOWN
+7 CVDG XVZNVM
+8 BUCF WUYMUL
+9 ATBE VTXLTK
+10 ZSAD USWKSJ
+11 YRZC TRVJRI
+12 XQYB SQUIQH
+13 WPXA RPTHPG
+14 VOWZ QOSGOF
+15 UNVY PNRFNE
+16 TMUX OMQEMD
+17 SLTW NLPDLC
+18 RKSV MKOCKB
+19 QJRU LJNBJA
+20 PIQT KIMAIZ
+21 OHPS JHLZHY
+22 NGOR IGKYGX
+23 MFNQ HFJXFW
+24 LEMP GEIWEV
+25 KDLO FDHVDU
Computer Science 161
Cryptography by Hand: Attacks on the Caesar Cipher
47
Computer Science 161
Cryptography by Hand: Substitution Cipher
48
K | |||
M | C | M | C |
A | N | N | G |
B | Q | O | P |
C | L | P | T |
D | Z | Q | A |
E | K | R | J |
F | R | S | O |
G | V | T | D |
H | U | U | I |
I | E | V | C |
J | S | W | F |
K | B | X | M |
L | W | Y | X |
M | Y | Z | H |
Computer Science 161
Cryptography by Hand: Attacks on Substitution Ciphers
49
K | |||
M | C | M | C |
A | N | N | G |
B | Q | O | P |
C | L | P | T |
D | Z | Q | A |
E | K | R | J |
F | R | S | O |
G | V | T | D |
H | U | U | I |
I | E | V | C |
J | S | W | F |
K | B | X | M |
L | W | Y | X |
M | Y | Z | H |
Computer Science 161
Takeaways
50
Computer Science 161
Cryptography by Machines: Enigma
51
Plugboard
Rotors
Computer Science 161
Enigma Operating Principle: Rotor Machine
52
Computer Science 161
Cryptography by Machines: Enigma
53
Computer Science 161
Cryptography by Machines: Enigma
54
M
Enc(K, M)
(repeat)
Alice (challenger)
Eve (adversary)
M0 and M1
Enc(K, Mb)
M
Enc(K, M)
Guess b = 0 or b = 1
(repeat)
pick b
Computer Science 161
Cryptography by Machines: Attack on Enigma
55
BOMBE machine
Computer Science 161
Cryptography by Machines: Legacy of Enigma
56
Alan Turing
Computer Science 161
Cryptography by Computers
57
One of these is Diffie, and the other one is Hellman.
Computer Science 161
Summary
58
Computer Science 161
Summary
59
Computer Science 161