60
1

588-w11-Crypto Notes

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 588-w11-Crypto Notes

1

Page 2: 588-w11-Crypto Notes

2

Page 3: 588-w11-Crypto Notes

3

Page 4: 588-w11-Crypto Notes

4

Page 5: 588-w11-Crypto Notes

5

Page 6: 588-w11-Crypto Notes

Auguste Kerckhoffs (1853)

Why Kerchoffs’s Principle?1. can quantify probability that adversary will guess 

key because chosen randomly from known space2. different people can use same system, different 

keys:Alice and Bob use one key, Charlie and Diane use another

3. can change key if something goes wrong

6

Page 7: 588-w11-Crypto Notes

*actually, it’s OK if Mallory has a negligible advantage over guessing, so long as it’s vanishingly g g g g g ysmall

‐‐‐

Important fact:Important fact: 

There is an algorithm that always wins for Mallory1. get a long list of (x, g(x)) pairs2. try every value of k to see whether fk matches 

h lthat list3. guess b=1 iff some fk matches

To fix this, need to limit Mallory to “practical” or “efficient” algorithmsg

Won’t define this precisely in this course (but precise definitions do exist)

7

Page 8: 588-w11-Crypto Notes

Important Assumptions:‐ Physical securityy y‐ Key management‐ Note key exchange in advance

‐‐

What if Alice and Bob want to send more than one message?‐ can’t just redo same plan‐ replay attacks / reordering attacks

Solutions:‐ add sequence number to message‐ or, use different key each time

8

Page 9: 588-w11-Crypto Notes

9

Page 10: 588-w11-Crypto Notes

10

Page 11: 588-w11-Crypto Notes

Pad using a fixed algorithm – why?‐ Part of the definition of the function‐ Otherwise different implementations would calculate different outputs for the same inputs

Compression function h:‐ designed to be really hairy‐ lots of bit twiddling‐ look up in book if you want; not very enlightening

11

Page 12: 588-w11-Crypto Notes

If you don’t need a secret key, pick a key and announce it, use different keys for different purposes to be safe.

‐‐

Alternate ending if out of time here:

Also useful to “stretch” a shared secret: given one shared secret key, generate two Do this trick over and over to generate N shared secret keys“pseudorandom generator”pseudorandom generatortopic of the next lecture

12

Page 13: 588-w11-Crypto Notes

Intro:

Randomness has a central role in cryptography, but randomness is hard to get, hard to share,so want to use pseudorandomness instead.

13

Page 14: 588-w11-Crypto Notes

we’re often sloppy about what is “random”e.g., rand() function is C library is not at all random“some random kids were there”

need to be precise in crypto ‐‐‐ or we’ll be sorry

14

Page 15: 588-w11-Crypto Notes

This should sound familiar… 

15

Page 16: 588-w11-Crypto Notes

*usual caveats:‐ OK if negligible advantage, ‐ only practical strategies allowed

16

Page 17: 588-w11-Crypto Notes

…it seems like we’re in good shape, but we still need a truly random value k. 

We could measure physical randomness…but: often, bits are biased, not independent… and how do we know if we have enough 

“randomness”?

And: Does physical randomness actually exist?i.e., Is the universe inherently random?while philosophers are debating that question, let’s 

try another approach 

17

Page 18: 588-w11-Crypto Notes

Examples of random sources?*exact* history of keypresses, including micro‐time*exact* path of mouse*exact* history of network packet arrivalinternal temperature of computerambient noise picked up by the microphonemaybe even add hardware that will behave unpredictablyexample: camera pointed at lava lamps

‐‐

Problem: Adversary can predict some of this• Not a problem, as long as there is “enough 

randomness” in the data• Gather data for “a long time” then run it through a 

PRF• Intuition: “distill out” the randomness, reduce size 

but keep randomness

Problem: How do you know when you have enough randomness?‐ If you use PRF output before you have enough, you’ll be sorry‐ Usual solution: Collect way too much, just to be sure

18

Page 19: 588-w11-Crypto Notes

19

Page 20: 588-w11-Crypto Notes

20

Page 21: 588-w11-Crypto Notes

21

Page 22: 588-w11-Crypto Notes

k=3 – This happens to be the key Caesar always used.

22

Page 23: 588-w11-Crypto Notes

23

Page 24: 588-w11-Crypto Notes

24

Page 25: 588-w11-Crypto Notes

Charles Babbage

25

Page 26: 588-w11-Crypto Notes

26

Page 27: 588-w11-Crypto Notes

27

Page 28: 588-w11-Crypto Notes

With a PRF, diff. inputs can generate same outputRandom functions will have collisions,  so will PRF

28

Page 29: 588-w11-Crypto Notes

Design challenges:When designing a PRF: pile on the hairy nonlinearity; more is better However, can’t use that here, since need invertibility‐with‐key

Ideally, changing one bit of plaintext or key should change about half the bits of the ciphertext

Simple definition of nonlinear: having no simple proportional relation between cause and effect

29

Page 30: 588-w11-Crypto Notes

30

Page 31: 588-w11-Crypto Notes

31

Page 32: 588-w11-Crypto Notes

32

Page 33: 588-w11-Crypto Notes

33

Page 34: 588-w11-Crypto Notes

34

Page 35: 588-w11-Crypto Notes

Disadvantages of ECB mode:‐ Same plaintext yields same ciphertext(at block and message level)‐ Rearrangeable

35

Page 36: 588-w11-Crypto Notes

Lame‐CBCpro: same plaintext yields different ciphertextcon: ciphertext is 2x size of plaintext

36

Page 37: 588-w11-Crypto Notes

space‐efficient?Clearly we need to add something to make same py g pyield diff. cHere we only add one block

37

Page 38: 588-w11-Crypto Notes

Message ending at block boundaryif message ends at block boundary, have to add whole block of padding.Otherwise might be tricked into interpreting end of message as padding – caution!

38

Page 39: 588-w11-Crypto Notes

39

Page 40: 588-w11-Crypto Notes

40

Page 41: 588-w11-Crypto Notes

41

Page 42: 588-w11-Crypto Notes

42

Page 43: 588-w11-Crypto Notes

43

Page 44: 588-w11-Crypto Notes

Notice what we’ve done: Alice and Bob had public conversation to derive pshared secret!  it’s a very short conversation, too

44

Page 45: 588-w11-Crypto Notes

We’ve been talking about confidentiality in terms of a passive eavesdropper, Evep ppBut some attacks can do more than listen in—remember Mallory, from our discussion of integrity?D‐H can only give us confidentiality if we alreadyhave some assurance of integrityhave some assurance of integrity

chess storyI know how to play chess against the two best 

players in the world, and beat oneplay black vs. Anand on Board 1, white vs. 

Topalov on Board 2algorithmwait for Anand to move on Board 1copy Anand’s move on Board 2copy Anand s move on Board 2wait for Topalov to reply on Board 2copy Topalov’s reply on Board 1etc.

Anand and Topalov are really playing each thother

but they both think they’re playing memoral of the story:

“in the middle” is a powerful place to beshape the parties’ views of the world

45

Page 46: 588-w11-Crypto Notes

Out‐of‐band communication (e.g., SSH)Example: I call you on the phone, confirm my key –p y p y yworks if we recognize each others’ voices

Physical contact (e.g., smartcards)

46

Page 47: 588-w11-Crypto Notes

47

Page 48: 588-w11-Crypto Notes

48

Page 49: 588-w11-Crypto Notes

49

Page 50: 588-w11-Crypto Notes

50

Page 51: 588-w11-Crypto Notes

2128 is approx. 1039at 1 trillion guesses/sec., takes 10 quadrillion times lifetime of universe

Birthday paradox: By the pigeonhole principle, 100% probability of two same birthdays with 367 people;but counter‐intuitively, reach 99% probability with only 57 people, and 50% probability with just 23 peopleIntuition?  (23 choose 2) = 253 pairs – chances for a collision

51

Page 52: 588-w11-Crypto Notes

1. Each key should have only one purpose:‐ diff keys for signing, encrypting‐ diff keys for encrypting MACingdiff keys for encrypting, MACing‐ diff keys for Alice‐>Bob and Bob‐>Alice‐ diff keys for diff protocolsreason: prevent attacker from “repurposing” contentexample: reflection attack

2. Vulnerability of a key increases…2. Vulnerability of a key increases…consequences:‐ change your keys periodically, use session keys‐ take care to erase keys from memory when you’re done with them‐ don’t let your keys get swapped out to disk

3. Keep your keys far from the attacker‐memory of networked, unguarded PC: bad‐memory of non‐networked, guarded PC: not as bad‐ stored in tamper‐resistant device: better‐ stored in tamper resistant device, locked in safe: best

4. Protect yourself against compromise of old keys‐ bad practice: Alice tells Bob, “Here’s the new key: ...” encrypted under old key

adversary can record this, then attack old keyget old key, then he can get new keyworse yet: if long chain of keys, he can attack any one, 

chain unravelschain as strong as its weakest link!

goal: “forward secrecy” learning old key doesn’t help adversary learn new keyhow to do? 

Diffi H ll t ti t f h t– use Diffie‐Hellman to negotiate a fresh secret‐ can use old key to provide integrity (as long as attacker doesn’t know it today,learning old key tomorrow won’t let attacker 

discover new key)

also actively destroy old key when you’re done with italso: actively destroy old key when you’re done with itfind all copies, write zeroes over them

52

Page 53: 588-w11-Crypto Notes

existing scheme is impractical

Alice would have to share an integrity key with everybody, but then anybody could put integrity mark on message

Recall that Alice and Bob know the same key soRecall that Alice and Bob know the same key, so Bob can make integ. marks‐ Not a problem if only Alice and Bob 

(Bob tricking himself?)‐ Trouble if many recipients

53

Page 54: 588-w11-Crypto Notes

54

Page 55: 588-w11-Crypto Notes

55

Page 56: 588-w11-Crypto Notes

56

Page 57: 588-w11-Crypto Notes

57

Page 58: 588-w11-Crypto Notes

For both, use RSA twice, once for each purpose (w/ separate key‐pairs)

58

Page 59: 588-w11-Crypto Notes

Reasons for larger key size:‐ Unlike w/ symmetric key, p and q can’t be chosen uniformly at random (only primes will do)‐ Also, can attack by factoring (known factoring algorithms are better than dumb brute force)‐ Need some cushion for when factoring algorithms improve

Good advice today: 2048‐bit p and q seem safe for foreseeable futureUse 1024‐bit only if you need performance boost

59

Page 60: 588-w11-Crypto Notes

60