Lecture 10: Cryptography creditSagnik Credit: https://xkcd.com/177/ - - PowerPoint PPT Presentation

lecture 10 cryptography
SMART_READER_LITE
LIVE PREVIEW

Lecture 10: Cryptography creditSagnik Credit: https://xkcd.com/177/ - - PowerPoint PPT Presentation

Lecture 10: Cryptography creditSagnik Credit: https://xkcd.com/177/ 1/20 Basic Setup ELM Elm receiver sender Credit: https://flylib.com/books/en/1.581.1.188/1/ 2/20 Recall: XOR Recall the XOR operation: M b f x y x y x b b 0 0


slide-1
SLIDE 1 1/20

Lecture 10: Cryptography

Credit: https://xkcd.com/177/

creditSagnik

slide-2
SLIDE 2 2/20

Basic Setup

Credit: https://flylib.com/books/en/1.581.1.188/1/ ELM

Elm sender

receiver

slide-3
SLIDE 3 3/20

Recall: XOR

Recall the XOR operation: x y x y 1 1 1 1 1 1 Notice that for any bits x, b we have (x b) b = x

M

b

f

x b

b

O

O

I

l

E

slide-4
SLIDE 4 4/20

One-Time Pad

Alice (the sender) wants to send a n-bit message m to Bob (the receiver). Setup: I Alice and Bob generate a random key k. Encryption: Decryption: Notice that D(E(m)) = (m k) k = m, i.e. Bob always receives the message Alice sent.

slide-5
SLIDE 5 4/20

One-Time Pad

Alice (the sender) wants to send a n-bit message m to Bob (the receiver). Setup: I Alice and Bob generate a random key k. Encryption: I Alice encrypts c = E(m) := m k. Decryption: Notice that D(E(m)) = (m k) k = m, i.e. Bob always receives the message Alice sent.

slide-6
SLIDE 6 4/20

One-Time Pad

Alice (the sender) wants to send a n-bit message m to Bob (the receiver). Setup: I Alice and Bob generate a random key k. Encryption: I Alice encrypts c = E(m) := m k. Decryption: I Bob decrypts D(c) := c k. Notice that D(E(m)) = (m k) k = m, i.e. Bob always receives the message Alice sent.

slide-7
SLIDE 7 5/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m;

slide-8
SLIDE 8 5/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m; I k truly random (not generated by a simple computer function);

slide-9
SLIDE 9 5/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m; I k truly random (not generated by a simple computer function); I each key is used only once;

slide-10
SLIDE 10 5/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m; I k truly random (not generated by a simple computer function); I each key is used only once; I there should only be two copies of the key; one for Alice and

  • ne for Bob.
slide-11
SLIDE 11 6/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m; I k truly random (not generated by a simple computer function); I each key is used only once; I there should only be two copies of the key; one for Alice and

  • ne for Bob.

But what if I (Alice) want to send my credit card information to Amazon (Bob) to make a purchase? I Not practical; I would need to somehow communicate with Amazon to agree on a key for every single purchase.

slide-12
SLIDE 12 6/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m; I k truly random (not generated by a simple computer function); I each key is used only once; I there should only be two copies of the key; one for Alice and

  • ne for Bob.

But what if I (Alice) want to send my credit card information to Amazon (Bob) to make a purchase? I Not practical; I would need to somehow communicate with Amazon to agree on a key for every single purchase. I And every single user would’ve had to do this.

slide-13
SLIDE 13 7/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m; I k truly random (not generated by a simple computer function); I each key is used only once; I there should only be two copies of the key; one for Alice and

  • ne for Bob.

Solve these issues with public-key cryptography: use pairs of keys I public keys: everyone knows!

slide-14
SLIDE 14 7/20

One-Time Pad: Disadvantages

One-Time Pad is the only existing mathematically unbreakable

  • encryption. But if only one of the following is not met, it is no

longer unbreakable: I k is at least as long as m; I k truly random (not generated by a simple computer function); I each key is used only once; I there should only be two copies of the key; one for Alice and

  • ne for Bob.

Solve these issues with public-key cryptography: use pairs of keys I public keys: everyone knows! I private keys: only Bob knows.

slide-15
SLIDE 15 8/20

RSA Protocol

Everyone can send messages to Bob. For now, let’s say Alice wants to send a message m to Bob. Setup: I Bob chooses two large (2048-bit) distinct primes p, q. Encryption: Decryption:

slide-16
SLIDE 16 8/20

RSA Protocol

Everyone can send messages to Bob. For now, let’s say Alice wants to send a message m to Bob. Setup: I Bob chooses two large (2048-bit) distinct primes p, q. I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. Encryption: Decryption:

slide-17
SLIDE 17 8/20

RSA Protocol

Everyone can send messages to Bob. For now, let’s say Alice wants to send a message m to Bob. Setup: I Bob chooses two large (2048-bit) distinct primes p, q. I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. I the public key is (N, e), where N = pq. Encryption: Decryption:

slide-18
SLIDE 18 8/20

RSA Protocol

Everyone can send messages to Bob. For now, let’s say Alice wants to send a message m to Bob. Setup: I Bob chooses two large (2048-bit) distinct primes p, q. I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. I the public key is (N, e), where N = pq. I Bob computes the private key d := e−1 mod (p 1)(q 1). Encryption: Decryption:

slide-19
SLIDE 19 8/20

RSA Protocol

Everyone can send messages to Bob. For now, let’s say Alice wants to send a message m to Bob. Setup: I Bob chooses two large (2048-bit) distinct primes p, q. I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. I the public key is (N, e), where N = pq. I Bob computes the private key d := e−1 mod (p 1)(q 1). Encryption: I Alice encrypts c = E(m) := me mod N Decryption:

slide-20
SLIDE 20 8/20

RSA Protocol

Everyone can send messages to Bob. For now, let’s say Alice wants to send a message m to Bob. Setup: I Bob chooses two large (2048-bit) distinct primes p, q. I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. I the public key is (N, e), where N = pq. I Bob computes the private key d := e−1 mod (p 1)(q 1). Encryption: I Alice encrypts c = E(m) := me mod N Decryption: I Bob decrypts D(c) := cd mod N

Cd

N

s

slide-21
SLIDE 21 9/20

# TODO

We need to analyze: I Correctness: D(E(m)) = m?

slide-22
SLIDE 22 9/20

# TODO

We need to analyze: I Correctness: D(E(m)) = m? I Efficiency: Can Alice and Bob perform their steps efficiently?

slide-23
SLIDE 23 9/20

# TODO

We need to analyze: I Correctness: D(E(m)) = m? I Efficiency: Can Alice and Bob perform their steps efficiently? I Security: Can Eve break it?

slide-24
SLIDE 24 10/20

Fermat’s Little Theorem

Theorem: Let p be a prime and a 6⌘ 0 (mod p). Then ap−1 ⌘ 1 (mod p).

Proof.

f

Goal

O

domain

codomain

h

woo

f

0,1 2 P t 30,1

P I

O

k

t

ax mod p

i

is

a bijection

Since flo

O.amodp

  • modp O

t

Has

ftp

3V

xEl P l

f

Eaxcmodp

un Axmodp

p I

p l

M Tx

Ff

aIII x

mode

1

Kei

since p is a prime god

p

x modulopexists

III.sc Ftx

aP fIixTIIICmodp 71

aP lmodp

slide-25
SLIDE 25 11/20

Goal

D Efm

m

Min are coprime

2

me

N

d

N

m

X

3

moan

q

X E3

mod m

Notice that

OED Elm LN 1

Find me a solution

i

i

avnb

se

Find meall solutions

Dk

cd N

cd

modal

3 1 ask.kz

DIET'D

Ehmd

mId medcmodN

at

CToal Med

m

modN

slide-26
SLIDE 26 12/20

RSA correctness

Theorem: Let D, E be the RSA decryption and RSA encryption functions respectively. Then D(E(m)) = m, i.e. RSA protocol always decrypts correctly.

Proof.

FLT primeP and M

0 mod

mic

Let

med.fm

e

MlmodN

N pq

ioal

x

mCmodNXTE

Since

mod so FREI Ed I

k

pDcgD

Then

z

mltkCPDcgD

th

Ma

l

as If M 0Im

dpMP

modp

x m Mmk

LPDcaDEM modB

If m eocm.TT

pT

TsT

mcmodpsingyT aynes.ie

Thus

Sy

ddDg

byCRT the solutionis

uniquemodulo N pq

Noticethat

x

m is a solution

ie

x

m modN

slide-27
SLIDE 27 13/20

RSA Efficiency

Setup I Bob chooses two large distinct primes p and q. how??? Encryption: Decryption:

e

si

gcdCe CpDog D

slide-28
SLIDE 28 13/20

RSA Efficiency

Setup I Bob chooses two large distinct primes p and q. how??? I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. how??? (choose a prime, like 3) Encryption: Decryption:

e 1mod

pDcgD

slide-29
SLIDE 29 13/20

RSA Efficiency

Setup I Bob chooses two large distinct primes p and q. how??? I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. how??? (choose a prime, like 3) I Bob computes d := e−1 mod (p 1)(q 1). how??? (extended Euclidean algorithm is fast!) Encryption: Decryption:

Elm

me

N

slide-30
SLIDE 30 13/20

RSA Efficiency

Setup I Bob chooses two large distinct primes p and q. how??? I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. how??? (choose a prime, like 3) I Bob computes d := e−1 mod (p 1)(q 1). how??? (extended Euclidean algorithm is fast!) Encryption: I Alice encrypts c = E(m) := me mod N. how??? (repeated squaring is fast!) Decryption:

D c Cd

N

slide-31
SLIDE 31 13/20

RSA Efficiency

Setup I Bob chooses two large distinct primes p and q. how??? I Bob chooses e such that gcd(e, (p 1)(q 1)) = 1. how??? (choose a prime, like 3) I Bob computes d := e−1 mod (p 1)(q 1). how??? (extended Euclidean algorithm is fast!) Encryption: I Alice encrypts c = E(m) := me mod N. how??? (repeated squaring is fast!) Decryption: I Bob decrypts D(c) := cd mod N. how??? (repeated squaring is fast!)

slide-32
SLIDE 32 14/20

RSA Efficiency: Sampling Primes

We need two large (2048-bit) primes. I By the Prime Number Theorem, number of primes  N is at least

N ln(N).

slide-33
SLIDE 33 14/20

RSA Efficiency: Sampling Primes

We need two large (2048-bit) primes. I By the Prime Number Theorem, number of primes  N is at least

N ln(N).

I We need to generate and check ⇡ ln N primes. This is linear in the number of bits of N.

we

slide-34
SLIDE 34 14/20

RSA Efficiency: Sampling Primes

We need two large (2048-bit) primes. I By the Prime Number Theorem, number of primes  N is at least

N ln(N).

I We need to generate and check ⇡ ln N primes. This is linear in the number of bits of N. I ...but how to check primes?

slide-35
SLIDE 35 14/20

RSA Efficiency: Sampling Primes

We need two large (2048-bit) primes. I By the Prime Number Theorem, number of primes  N is at least

N ln(N).

I We need to generate and check ⇡ ln N primes. This is linear in the number of bits of N. I ...but how to check primes? I there is an efficient algorithm that tests if N is prime (polynomial time in the number of bits of N).

slide-36
SLIDE 36 15/20

RSA Security

Cryptograph relies on assumptions. RSA Assumption: Given N, e, and me mod N, there is no efficient algorithm for finding m. We believe Eve cannot break RSA. I Eve can break RSA by factoring N = pq to get (p 1)(q 1) to compute d.

slide-37
SLIDE 37 15/20

RSA Security

Cryptograph relies on assumptions. RSA Assumption: Given N, e, and me mod N, there is no efficient algorithm for finding m. We believe Eve cannot break RSA. I Eve can break RSA by factoring N = pq to get (p 1)(q 1) to compute d. I But prime factorization is hard!

slide-38
SLIDE 38 15/20

RSA Security

Cryptograph relies on assumptions. RSA Assumption: Given N, e, and me mod N, there is no efficient algorithm for finding m. We believe Eve cannot break RSA. I Eve can break RSA by factoring N = pq to get (p 1)(q 1) to compute d. I But prime factorization is hard! I For large N, no efficient, non-quantum algorithm is known.

slide-39
SLIDE 39 16/20

Replay Attack

Does Eve really need to know d to attack? I Suppose my credit card number is m.

slide-40
SLIDE 40 16/20

Replay Attack

Does Eve really need to know d to attack? I Suppose my credit card number is m. I I send Amazon E(m) to make a purchase.

slide-41
SLIDE 41 16/20

Replay Attack

Does Eve really need to know d to attack? I Suppose my credit card number is m. I I send Amazon E(m) to make a purchase. I Eve can’t recover m from E(m).

slide-42
SLIDE 42 16/20

Replay Attack

Does Eve really need to know d to attack? I Suppose my credit card number is m. I I send Amazon E(m) to make a purchase. I Eve can’t recover m from E(m). I But Eve was listening to our communication and now she knows E(m).

slide-43
SLIDE 43 16/20

Replay Attack

Does Eve really need to know d to attack? I Suppose my credit card number is m. I I send Amazon E(m) to make a purchase. I Eve can’t recover m from E(m). I But Eve was listening to our communication and now she knows E(m). I Eve sends E(m) to Amazon.

slide-44
SLIDE 44 16/20

Replay Attack

Does Eve really need to know d to attack? I Suppose my credit card number is m. I I send Amazon E(m) to make a purchase. I Eve can’t recover m from E(m). I But Eve was listening to our communication and now she knows E(m). I Eve sends E(m) to Amazon. I Now Eve can use my credit card.

slide-45
SLIDE 45 17/20

Defense Against Replay Attacks

Even secure protocol can be vulnerable, need careful implementation. To defend against replay attacks, I before encrypt m, randomly generate a string s.

slide-46
SLIDE 46 17/20

Defense Against Replay Attacks

Even secure protocol can be vulnerable, need careful implementation. To defend against replay attacks, I before encrypt m, randomly generate a string s. I Send E(concatenate(m, s)).

slide-47
SLIDE 47 17/20

Defense Against Replay Attacks

Even secure protocol can be vulnerable, need careful implementation. To defend against replay attacks, I before encrypt m, randomly generate a string s. I Send E(concatenate(m, s)). I If Amazon gets same message twice, reject.

slide-48
SLIDE 48 18/20

Flipping RSA: Digital Signature

RSA can be used as in proof of identity. I How does Alice know the receiver is Bob?

slide-49
SLIDE 49 18/20

Flipping RSA: Digital Signature

RSA can be used as in proof of identity. I How does Alice know the receiver is Bob? I Bob could prove his identity by showing Alice d, but he doesn’t want to do that.

slide-50
SLIDE 50 18/20

Flipping RSA: Digital Signature

RSA can be used as in proof of identity. I How does Alice know the receiver is Bob? I Bob could prove his identity by showing Alice d, but he doesn’t want to do that. I Alice chooses a message m and asks Bob to send her md mod N.

slide-51
SLIDE 51 18/20

Flipping RSA: Digital Signature

RSA can be used as in proof of identity. I How does Alice know the receiver is Bob? I Bob could prove his identity by showing Alice d, but he doesn’t want to do that. I Alice chooses a message m and asks Bob to send her md mod N. I Alice can verify (md)e ⌘ m (mod N).

EMMA D Elms

m

slide-52
SLIDE 52 19/20

Digital Signature Attack

Should Bob sign arbitrary messages? I Alice encrypts a top-secret message m and sends it to Bob.

slide-53
SLIDE 53 19/20

Digital Signature Attack

Should Bob sign arbitrary messages? I Alice encrypts a top-secret message m and sends it to Bob. I Eve intercepts the cipher E(m).

slide-54
SLIDE 54 19/20

Digital Signature Attack

Should Bob sign arbitrary messages? I Alice encrypts a top-secret message m and sends it to Bob. I Eve intercepts the cipher E(m). I Eve chooses a number r and asks Bob to sign reE(m).

slide-55
SLIDE 55 19/20

Digital Signature Attack

Should Bob sign arbitrary messages? I Alice encrypts a top-secret message m and sends it to Bob. I Eve intercepts the cipher E(m). I Eve chooses a number r and asks Bob to sign reE(m). I Bob agrees and sends Eve (reE(m))d mod N.

e

slide-56
SLIDE 56 19/20

Digital Signature Attack

Should Bob sign arbitrary messages? I Alice encrypts a top-secret message m and sends it to Bob. I Eve intercepts the cipher E(m). I Eve chooses a number r and asks Bob to sign reE(m). I Bob agrees and sends Eve (reE(m))d mod N. I Now Eve knows (reE(m))d ⌘ redmed ⌘ rm (mod N).

Ttm

Frmged

slide-57
SLIDE 57 19/20

Digital Signature Attack

Should Bob sign arbitrary messages? I Alice encrypts a top-secret message m and sends it to Bob. I Eve intercepts the cipher E(m). I Eve chooses a number r and asks Bob to sign reE(m). I Bob agrees and sends Eve (reE(m))d mod N. I Now Eve knows (reE(m))d ⌘ redmed ⌘ rm (mod N). I Eve knows r; so Eve computes r−1 mod N to recover m.

slide-58
SLIDE 58 20/20

THE END!

Thank you for coming!