1 of 36

1

Jonathan Berger

Introduction to Cyber Security

TA 4 part 2: Intro to Cryptography

Based on slides of Avishay Yanai

2 of 36

Cryptographic Hash Function

  •  

2

3 of 36

Cryptographic Hash Function

  •  

3

 

4 of 36

 

  •  

4

5 of 36

 

  •  

5

6 of 36

 

  •  

6

7 of 36

7

Application example of cryptographic hash functions

Merkle Trees

8 of 36

Application: File Storage

  • Consider a client that uploads a file to a server

  • After some time, the client would like to retrieve the file

  • The client would like to make sure that he retrieved the original file that he had stored
    • The server might be malicious

8

9 of 36

Application: File Storage – single file

  •  

9

10 of 36

Application: File Storage – many files

  •  

10

11 of 36

Application: File Storage – many files

  •  

11

12 of 36

Application: File Storage – many files

  •  

12

13 of 36

Application: File Storage – many files

  •  

13

Local storage: Constant.

Communication per file: 2 files + (log n)-1 hashes

14 of 36

Finding Collision

  •  

14

15 of 36

The “Birthday” Problem/Paradox

  •  

15

16 of 36

The “Birthday” Problem/Paradox (cont.)

  •  

16

17 of 36

The “Birthday” Problem/Paradox – Lower bound proof

  •  

17

 

18 of 36

  •  

18

19 of 36

A Reminder – Message Authentication Code (MAC)

  •  

19

20 of 36

Canonical Verification

  •  

20

21 of 36

MAC from Collision Resistant Hash Functions

  •  

21

22 of 36

Timing attacks

  •  

22

Python

C

23 of 36

Timing attacks (cont.)

  • Consider the following (simplified) code for verification:

  • Both memcmp() and python’s ‘==‘ compare the results byte-by-byte
    • This comparison does not run in constant time. First byte is different -> immediate return

23

Python

C

24 of 36

Timing attacks (cont.)

  • The attack concept:
    1. Send a message with a random tag, t
      1. Measure the time

    • Loop over the first byte of the tag
      • If verification took longer -> success with the first byte

    • Repeat until the tag is valid

  • Used to attack Xbox 360 (2.2 milliseconds difference)

  • Takeovers:
    • (Again) Do not implement your own crypto
    • In Python, you can use hmac.compare_digest() to assure constant-time verification

24

Attacker

Verifier

(m,t)

0/1

(m,t’)

25 of 36

Data Integrity, Message Authentication

  • Risk: an active adversary might change messages exchanged between Alice and Bob

page 25

Alice

Eve

Bob

  • Authentication is orthogonal to secrecy. It is a relevant challenge regardless of whether encryption is applied.

M

M

M’

M’

26 of 36

Message Authentication Code (MAC)

 

 

 

 

 

 

 

 

 

26

27 of 36

Requirements

  • Security: The adversary,
    • Knows the MAC algorithm (but not K).
    • Is given many pairs (mi , MACK(mi)), where the mi values might also be chosen by the adversary (chosen plaintext).
    • Cannot compute (m, MACK(m)) for any new m (∀ i m≠mi).
    • The adversary must not be able to compute MACK(m) even for a message m which is “meaningless” (since we don’t know the context of the attack).

  • Efficiency: MAC output must be of fixed length, and as short as possible.
    • ⇒ The MAC function is not 1-to-1.
    • ⇒ An n bit MAC can be broken with prob. of at least 2-n.

page 27

28 of 36

The Security of MACs

 

  • Does not prevent “replay attacks”!

28

29 of 36

A Fixed-Length MAC

 

If F is a PRF, then the above MAC scheme is secure.

29

30 of 36

A Variable-Length MAC (NMAC)

  •  

31 of 36

A Variable-Length MAC (NMAC)

  •  

32 of 36

State of the art – HMAC

  •  

33 of 36

State of the art – HMAC

  •  

34 of 36

Exercises

  •  

34

35 of 36

Questions?

35

36 of 36

(MAC("יאללה עופו הביתה"))

36