Introduction to Cryptography - Moodle

16
Gil Segev Cryptography Lecture 1: Classical vs. Modern Cryptography

Transcript of Introduction to Cryptography - Moodle

Gil Segev

Cryptography

Lecture 1:

Classical vs. Modern Cryptography

2

Outline

• Symmetric-key encryption• Historical ciphers• The basic principles of modern cryptography

3

Symmetric-Key Encryption

Alice Bob

Eve

Alice and Bob wish to communicate secretly• Eve observes the communication

Assumption: Alice and Bob share a secret key• The key is not known to Eve• Same key used for both

encryption and decryption

4

Symmetric-Key EncryptionSyntax: Three algorithms (𝐊𝐞𝐲𝐆𝐞𝐧, 𝐄𝐧𝐜,𝐃𝐞𝐜)• Key-generation algorithm KeyGen outputs a key 𝑘 ∈ 𝒦• Encryption algorithm Enc takes a key 𝑘 ∈ 𝒦 and a plaintext 𝑚 ∈ ℳ, and outputs a

ciphertext 𝑐 ∈ 𝒞• Decryption algorithm Dec takes a key 𝑘 ∈ 𝒦 and ciphertext 𝑐 ∈ 𝒞, and outputs a

plaintext 𝑚 ∈ ℳ

𝑘 ← KeyGen() 𝑐 ← Enc𝑘(𝑚) 𝑚 ← Dec𝑘(𝑐)

𝒦 – key space

ℳ – plaintext space, message space

𝒞 – ciphertext space

← randomized assignment= deterministic assignment

5

Symmetric-Key EncryptionSyntax: Three algorithms (𝐊𝐞𝐲𝐆𝐞𝐧, 𝐄𝐧𝐜,𝐃𝐞𝐜)• Key-generation algorithm KeyGen outputs a key 𝑘 ∈ 𝒦• Encryption algorithm Enc takes a key 𝑘 ∈ 𝒦 and a plaintext 𝑚 ∈ ℳ, and outputs a

ciphertext 𝑐 ∈ 𝒞• Decryption algorithm Dec takes a key 𝑘 ∈ 𝒦 and ciphertext 𝑐 ∈ 𝒞, and outputs a

plaintext 𝑚 ∈ ℳ

Enc𝑚

𝑘

Dec𝑚

𝑘

𝑐

Correctness: ∀𝑘 ∈ 𝒦,𝑚 ∈ ℳ

Dec𝑘 Enc𝑘 𝑚 = 𝑚

6

Symmetric-Key EncryptionSyntax: Three algorithms (𝐊𝐞𝐲𝐆𝐞𝐧, 𝐄𝐧𝐜,𝐃𝐞𝐜)• Key-generation algorithm KeyGen outputs a key 𝑘 ∈ 𝒦• Encryption algorithm Enc takes a key 𝑘 ∈ 𝒦 and a plaintext 𝑚 ∈ ℳ, and outputs a

ciphertext 𝑐 ∈ 𝒞• Decryption algorithm Dec takes a key 𝑘 ∈ 𝒦 and ciphertext 𝑐 ∈ 𝒞, and outputs a

plaintext 𝑚 ∈ ℳ

Enc𝑚

𝑘

Dec𝑚

𝑘

𝑐

Kerckhoffs’ principle• KeyGen, Enc, and Dec are publicly known• The only secret is the key 𝑘

7

Shift Cipher (Caesar’s Cipher)• KeyGen uniformly samples 𝑘 ← {0,… , 25}• ℳ = {a,… , z}ℓ and 𝒞 = {A,… , Z}ℓ

• Enc shifts each letter 𝑘 positions forward (wrapping around from Z to A)• Dec shifts backward

Enc𝑘 welcometocryptocourse = XFMDPNFUPDSZQUODOVSTF

Example with 𝑘 = 1:

Is it “secure”?• There are only 26 possible keys…• 𝒦 must not allow exhaustive search!

8

Substitution Cipher• KeyGen uniformly samples a permutation 𝑘 over {a,… , z}• ℳ = {a,… , z}ℓ and 𝒞 = {A,… , Z}ℓ

• Enc applies the permutation 𝑘 to each letter• Dec applied the inverse permutation 𝑘−1

Enc𝑘 tellhimaboutme = GDOOKVCXEFLGCD

Example with 𝑘 =

Is it “secure”?• There are many keys 26! ≈ 288

• But can use statistical patterns of the English language…

X E U A D N B K VMR O C Q F S Y HWG L Z I J P T

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

9

Example: Relative Frequencies

0

2

4

6

8

10

12

14

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

http://en.wikipedia.org/wiki/Letter_frequency

10

Vigenère Cipher• KeyGen uniformly samples 𝑘 = 𝑘0…𝑘𝑡−1 ← 0,… , 25 𝑡

• ℳ = {a,… , z}ℓ and 𝒞 = {A,… , Z}ℓ

• Enc shifts the 𝑖th letter 𝑘𝑖 mod 𝑡 positions forward• Dec shifts backward

Enc𝑘 hello = IGOMQ

Example with 𝑘 = 123:

Is it “secure”?• Trickier than breaking the shift and substitution ciphers• But can still use statistical patterns

11

Historical Ciphers

Fascinating history• Interesting & creative ideas (almost all broken by now…)• Influenced world history (e.g., cryptanalysis of the German Enigma in

World War II)

It’s hard to design secure ciphers

12

Modern Cryptography

The scientific study of techniques for designing systems that withstand adversarial behavior

• What does “secure” mean?• Can we avoid “break → repair → break → repair → ⋯”?• Can we prove “security”?

13

Modern Cryptography

Analyzing the security of a system consists of1. Formalizing a precise definition of security2. Stating the underlying assumptions (if any)3. Proving that the definition is satisfied given the assumptions

14

1. Defining SecurityKnown-ciphertext attack• Eve observes a challenge ciphertext 𝑐∗

Enc Dec𝑐∗

Known-plaintext attack• Eve learns pairs 𝑚, Enc𝑘 𝑚

• Then observes a challenge ciphertext 𝑐∗

Chosen-plaintext attack (CPA)• Even learns pairs 𝑚, Enc𝑘 𝑚 for messages 𝑚 of her choice

• Then observes a challenge ciphertext 𝑐∗

Chosen-ciphertext attack (CCA)• Even learns pairs 𝑚, Enc𝑘 𝑚 for messages 𝑚 of her choice

and pairs 𝑐, Dec𝑘 𝑐 for ciphertexts 𝑐 of her choice

• Then observes a challenge ciphertext 𝑐∗ ≠ 𝑐

15

1. Defining SecurityWhat does it mean to “break” the encryption?• Recover the key?• Recover the plaintext?• Recover part of the plaintext?• Learn anything “meaningful” about the plaintext!!

How to define “meaningful”?

Adversary’s computational abilities• Typically, probabilistic polynomial time (PPT)• Sometimes, computationally unbounded

Security definition =

computational ability × type of attack × notion of “break”

16

Recommended Reading

• J. Katz and Y. Lindell. Introduction to Modern Cryptography. Chapter 1 (Introduction)Appendix A (Mathematical Background)