Formal Verification of Masked Implementations Sonia Bela d - - PowerPoint PPT Presentation

formal verification of masked implementations
SMART_READER_LITE
LIVE PREVIEW

Formal Verification of Masked Implementations Sonia Bela d - - PowerPoint PPT Presentation

Formal Verification of Masked Implementations Sonia Bela d Benjamin Gr egoire CHES 2018 - Tutorial September 9th 2018 1 / 47 1 Side-Channel Attacks and Masking 2 Formal Tools for Verification at Fixed Order 3 Formal Tools


slide-1
SLIDE 1

Formal Verification of Masked Implementations

Sonia Bela¨ ıd Benjamin Gr´ egoire

CHES 2018 - Tutorial September 9th 2018

1 / 47

slide-2
SLIDE 2

1 Side-Channel Attacks and Masking 2 Formal Tools for Verification at Fixed Order 3 Formal Tools for Verification of Generic Implementations

2 / 47

slide-3
SLIDE 3

1 Side-Channel Attacks and Masking 2 Formal Tools for Verification at Fixed Order 3 Formal Tools for Verification of Generic Implementations

3 / 47

slide-4
SLIDE 4

Cryptanalysis

➜ Black-box cryptanalysis ➜ Side-channel analysis Alice Bob

c= 011100110101010110001010

ENC m k c DEC c k m

4 / 47

slide-5
SLIDE 5

Cryptanalysis

➜ Black-box cryptanalysis: A ← (m, c) ➜ Side-Channel Analysis Alice Bob

c= 011100110101010110001010

ENC m k c DEC c k m

4 / 47

slide-6
SLIDE 6

Cryptanalysis

➜ Black-box cryptanalysis ➜ Side-Channel Analysis: A ← (m, c, L) Alice Bob

c= 011100110101010110001010

ENC ENC m k c DEC DEC c k m L

4 / 47

slide-7
SLIDE 7

Cryptanalysis

➜ Black-box cryptanalysis ➜ Side-Channel Analysis: A ← (m, c, L) Alice Bob

c= 011100110101010110001010

ENC ENC m k c DEC DEC c k m L

4 / 47

slide-8
SLIDE 8

Cryptanalysis

➜ Black-box cryptanalysis ➜ Side-Channel Analysis: A ← (m, c, L) Alice Bob

c= 011100110101010110001010

ENC ENC m k c DEC DEC c k m L

4 / 47

slide-9
SLIDE 9

Cryptanalysis

➜ Black-box cryptanalysis ➜ Side-Channel Analysis: A ← (m, c, L) Alice Bob

c= 011100110101010110001010

ENC ENC m k c DEC DEC c k m L

4 / 47

slide-10
SLIDE 10

Cryptanalysis

➜ Black-box cryptanalysis ➜ Side-Channel Analysis: A ← (m, c, L) Alice Bob

c= 011100110101010110001010

ENC ENC m k c DEC DEC c k m L

4 / 47

slide-11
SLIDE 11

Example of SPA

Algorithm 1 Example

for i = 1 to n do if key[i] = 0 then do treatment 0 else do treatment 1 end if end for

SPA: one single trace to recover the secret key

5 / 47

slide-12
SLIDE 12

Example of DPA

DPA: several traces to recover the secret key

6 / 47

slide-13
SLIDE 13

How to thwart SCA?

m k c L

Issue: leakage L is key-dependent

7 / 47

slide-14
SLIDE 14

How to thwart SCA?

m k c L

Issue: leakage L is key-dependent Idea of masking: make leakage L random sensitive value: v = f(m, k) v0 ← v ⊕

  • 1it

vi

  • v1 ← $

... vt ← $ ➜ any t-uple of vi is independent from v

7 / 47

slide-15
SLIDE 15

Masked Implementations

Linear functions: apply the function to each share

v ⊕ w → (v0 ⊕ w0, v1 ⊕ w1, . . . , vt ⊕ wt)

8 / 47

slide-16
SLIDE 16

Masked Implementations

Linear functions: apply the function to each share

v ⊕ w → (v0 ⊕ w0, v1 ⊕ w1, . . . , vt ⊕ wt)

Non-linear functions: much more complex

∀ 0 ≤ i < j ≤ t − 1, ri,j ← $ ∀ 0 ≤ i < j ≤ t − 1, rj,i ← (ri,j ⊕ viwj) ⊕ vjwi ∀ 0 ≤ i ≤ d − 1, ci ← viwi ⊕

  • j=i

ri,j vw → (c0, c1, . . . , ct)

8 / 47

slide-17
SLIDE 17

Leakage Models

Probing model by Ishai, Sahai, and Wagner (Crypto 2003) ◮ a circuit is t-probing secure iff any set composed of the exact

values of at most t intermediate variables is independent from the secret

9 / 47

slide-18
SLIDE 18

Leakage Models

Probing model by Ishai, Sahai, and Wagner (Crypto 2003) ◮ a circuit is t-probing secure iff any set composed of the exact

values of at most t intermediate variables is independent from the secret

Noisy leakage model by Chari, Jutla, Rao, and Rohatgi

(Crypto 1999) then Rivain and Prouff (EC 2013)

◮ a circuit is secure in the noisy leakage model iff the adversary

cannot recover information on the secret from the noisy values

  • f all the intermediate variables

9 / 47

slide-19
SLIDE 19

Leakage Models

Probing model by Ishai, Sahai, and Wagner (Crypto 2003) ◮ a circuit is t-probing secure iff any set composed of the exact

values of at most t intermediate variables is independent from the secret

Noisy leakage model by Chari, Jutla, Rao, and Rohatgi

(Crypto 1999) then Rivain and Prouff (EC 2013)

◮ a circuit is secure in the noisy leakage model iff the adversary

cannot recover information on the secret from the noisy values

  • f all the intermediate variables

Reduction by Duc, Dziembowski, and Faust (EC 2014) ◮ t-probing security ⇒ security in the noisy leakage model for

some level of noise

9 / 47

slide-20
SLIDE 20

How to Verify Probing Security?

variables: secret, shares, constant masking order t = 3

function Ex-t3(x0, x1, x2, x3, c):

(* x0, x1, x2 = $ *) (* x3 = x + x0 + x1 + x2 *)

r0 ← $ r1 ← $ y0 ← x0 + r0 y1 ← x3 + r1 t1 ← x1 + r0 t2 ← (x1 + r0) + x2 y2 ← (x1 + r0 + x2) + r1 y3 ← c + r1 return(y0, y1, y2, y3)

10 / 47

slide-21
SLIDE 21

How to Verify Probing Security?

variables: secret, shares, constant masking order t = 3

function Ex-t3(x0, x1, x2, x3, c):

(* x0, x1, x2 = $ *) (* x3 = x + x0 + x1 + x2 *)

r0 ← $ r1 ← $ y0 ← x0 + r0 y1 ← x3 + r1 t1 ← x1 + r0 t2 ← (x1 + r0) + x2 y2 ← (x1 + r0 + x2) + r1 y3 ← c + r1 return(y0, y1, y2, y3) independent from the secret?

10 / 47

slide-22
SLIDE 22

How to Verify Probing Security?

variables: secret, shares, constant masking order t = 3

function Ex-t3(x0, x1, x2, x3, c):

(* x0, x1, x2 = $ *) (* x3 = x + x0 + x1 + x2 *)

r0 ← $ r1 ← $ y0 ← x0 + r0 y1 ← x3 + r1 t1 ← x1 + r0 t2 ← (x1 + r0) + x2 y2 ← (x1 + r0 + x2) + r1 y3 ← c + r1 return(y0, y1, y2, y3) independent from the secret?

10 / 47

slide-23
SLIDE 23

Non-Interference (NI)

t-NI ⇒ t-probing secure a circuit is t-NI iff any set of t intermediate variables can be

perfectly simulated with at most t shares of each input

function Ex-t3(x0, x1, x2, x3, c):

(* x0, x1, x2 = $ *) (* x3 = x + x0 + x1 + x2 *)

r0 ← $ r1 ← $ y0 ← x0 + r0 y1 ← x3 + r1 t1 ← x1 + r0 t2 ← (x1 + r0) + x2 y2 ← (x1 + r0 + x2) + r1 y3 ← c + r1 return(y0, y1, y2, y3) can be simulated with x0 and x1

11 / 47

slide-24
SLIDE 24

Non-Interference (NI)

t-NI ⇒ t-probing secure a circuit is t-NI iff any set of t intermediate variables can be

perfectly simulated with at most t shares of each input Ex-t3 3

  • bservations

x0 x1 x2 x3 (= x + x0 + x1 + x2) y0 y1 y2 y3

12 / 47

slide-25
SLIDE 25

1 Side-Channel Attacks and Masking 2 Formal Tools for Verification at Fixed Order 3 Formal Tools for Verification of Generic Implementations

13 / 47

slide-26
SLIDE 26

State-Of-The-Art

several tools were built to formally verify security of first-order

implementations t = 1

then a sequence of work tackled higher-order implementations

t ≤ 5

◮ maskVerif from Barthe et al.: first tool to achieve verification

at high orders

◮ CheckMasks from Coron: improvements in terms of efficiency ◮ Bloem et al.’s tool: treatment of glitches attacks

14 / 47

slide-27
SLIDE 27

State-Of-The-Art

several tools were built to formally verify security of first-order

implementations t = 1

then a sequence of work tackled higher-order implementations

t ≤ 5

◮ maskVerif from Barthe et al.: first tool to achieve verification

at high orders

◮ CheckMasks from Coron: improvements in terms of efficiency ◮ Bloem et al.’s tool: treatment of glitches attacks

14 / 47

slide-28
SLIDE 28

maskVerif

input: ◮ pseudo-code of a masked implementation ◮ order t

  • utput:

◮ formal proof of t-probing security (or NI, SNI) ◮ potential flaws

Gilles Barthe and Sonia Bela¨ ıd and Fran¸ cois Dupressoir and Pierre-Alain Fouque and Benjamin Gr´ egoire and Pierre-Yves Strub Verified Proofs of Higher-Order Masking, EUROCRYPT 2015, Proceedings, Part I, 457–485.

15 / 47

slide-29
SLIDE 29

Checking probabilistic independence

Problem: Check if a program expression e is probabilistic independent from a secret s Example: e = (s ⊕ r1) · (r1 ⊕ r2) First solution:

for each value of s computes the associate distribution of e if all the resulting distribution are equals then e is independent

  • f s

s = 0            r1 r2 e 1 1 1 1 1 s = 1            r1 r2 e 1 1 1 1 1

16 / 47

slide-30
SLIDE 30

Checking probabilistic independence

Problem: Check if a program expression e is probabilistic independent from a secret s Example: e = (s ⊕ r1) · (r1 ⊕ r2) First solution:

for each value of s computes the associate distribution of e if all the resulting distribution are equals then e is independent

  • f s

Complete Exponential in the number of secret and random values

16 / 47

slide-31
SLIDE 31

Checking probabilistic independence

Second solution, using simple rules:

Rule 1: If e does not use s then it is independent

17 / 47

slide-32
SLIDE 32

Checking probabilistic independence

Second solution, using simple rules:

Rule 1: If e does not use s then it is independent Rule 2: If e can be written as C[f ⊕ r] and r does not occur in

C and f then it is sufficient to test the independence of C[r] The distribution of f ⊕ r is equal to the distribution of r

17 / 47

slide-33
SLIDE 33

Checking probabilistic independence

Second solution, using simple rules:

Rule 1: If e does not use s then it is independent Rule 2: If e can be written as C[f ⊕ r] and r does not occur in

C and f then it is sufficient to test the independence of C[r]

Rule 3: If Rules 1 and 2 do not apply then use the first

solution (when possible)

17 / 47

slide-34
SLIDE 34

Checking probabilistic independence

Second solution, using simple rules:

Rule 1: If e does not use s then it is independent Rule 2: If e can be written as C[f ⊕ r] and r does not occur in

C and f then it is sufficient to test the independence of C[r]

Rule 3: If Rules 1 and 2 do not apply then use the first

solution (when possible) Problem: finding occurence of Rule 2 is relatively costly

17 / 47

slide-35
SLIDE 35

Independence: dag representation

(s ⊕ r1) · (r1 ⊕ r2)

s r1 r2 ⊕ ⊕ ·

18 / 47

slide-36
SLIDE 36

Independence: dag representation

(s ⊕ r1) · r2

s r1 ⊕ r2 ·

18 / 47

slide-37
SLIDE 37

Independence: dag representation

r1 · r2

r1 r2 ·

Independent from the secret

18 / 47

slide-38
SLIDE 38

First order Dom AND : NI

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0 ⊗ b1} {a1 ⊗ b0} {a0 ⊗ b0} {a1 ⊗ b1} {r} {a0 ⊗ b1 ⊕ r} {a1 ⊗ b0 ⊕ r} {a1 ⊗ b1 ⊕ a0 ⊗ b1 ⊕ r} {a0 ⊗ b0 ⊕ a1 ⊗ b0 ⊕ r}

19 / 47

slide-39
SLIDE 39

Extension to All Possible Sets

Verification of first order masking is just a linear iteration of

the previous algorithm (one call for each program point) 100 checks for a program of 100 lines

20 / 47

slide-40
SLIDE 40

Extension to All Possible Sets

Verification of first order masking is just a linear iteration of

the previous algorithm (one call for each program point) 100 checks for a program of 100 lines

For second order masking:

forall pair of program point, the corresponding pair of expressions is independent from the secrets 4, 950 checks for a program of 100 lines

20 / 47

slide-41
SLIDE 41

Extension to All Possible Sets

Verification of first order masking is just a linear iteration of

the previous algorithm (one call for each program point) 100 checks for a program of 100 lines

For second order masking:

forall pair of program point, the corresponding pair of expressions is independent from the secrets 4, 950 checks for a program of 100 lines

For t-order masking:

forall t-tuple of program point, the corresponding t-tuple of expressions is independent from the secrets N

t

  • where N is the number program points

3, 921, 225 for a program of 100 lines and 4 observations

20 / 47

slide-42
SLIDE 42

Extension to All Possible Sets

Idea: if e1, . . . , ep is independent from the secrets then all subtuples are independent from the secrets.

21 / 47

slide-43
SLIDE 43

Extension to All Possible Sets

Idea: if e1, . . . , ep is independent from the secrets then all subtuples are independent from the secrets.

21 / 47

slide-44
SLIDE 44

Extension to All Possible Sets

Idea: if e1, . . . , ep is independent from the secrets then all subtuples are independent from the secrets.

X

  • 1. select X = (t variables) and prove

its independence

21 / 47

slide-45
SLIDE 45

Extension to All Possible Sets

Idea: if e1, . . . , ep is independent from the secrets then all subtuples are independent from the secrets.

X

  • X
  • 1. select X = (t variables) and prove

its independence

  • 2. extend X to

X with more

  • bservations but still independence

21 / 47

slide-46
SLIDE 46

Extension to All Possible Sets

Idea: if e1, . . . , ep is independent from the secrets then all subtuples are independent from the secrets.

X

  • X

C

  • X
  • 1. select X = (t variables) and prove

its independence

  • 2. extend X to

X with more

  • bservations but still independence
  • 3. recursively descend in set C(

X)

21 / 47

slide-47
SLIDE 47

Extension to All Possible Sets

Idea: if e1, . . . , ep is independent from the secrets then all subtuples are independent from the secrets.

X

  • X

C

  • X
  • 1. select X = (t variables) and prove

its independence

  • 2. extend X to

X with more

  • bservations but still independence
  • 3. recursively descend in set C(

X)

  • 4. merge

X and C( X) once they are processed separately.

21 / 47

slide-48
SLIDE 48

Extension to All Possible Sets

Idea: if e1, . . . , ep is independent from the secrets then all subtuples are independent from the secrets.

X

  • X

C

  • X
  • 1. select X = (t variables) and prove

its independence

  • 2. extend X to

X with more

  • bservations but still independence
  • 3. recursively descend in set C(

X)

  • 4. merge

X and C( X) once they are processed separately. Finding X can be done very efficiently using a dag representation

21 / 47

slide-49
SLIDE 49

Benchmark

It is working for relatively small programs: Algorithm Order Tuples Secure Verification time Refresh 9 2.1010

  • 2s

Refresh 17 2.1020

  • 3d

Refresh 18 4.1021

  • 1 month

But there is a problem with large programs:

Full AES implementation at order 1

  • nly 4 rounds of AES at order 2

22 / 47

slide-50
SLIDE 50

Demo

https://sites.google.com/view/maskverif/home

Demo maskVerif

23 / 47

slide-51
SLIDE 51

Extending the model: glitches

For hardware implementation a more realistic model need to take into account glitches Example: AND gate A B A B A · B Possible leaks : A · B, A, B

24 / 47

slide-52
SLIDE 52

First order DOM AND : NI with glitches

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0 ⊗ b1} {a1 ⊗ b0} {a0 ⊗ b0} {a1 ⊗ b1} {r} {a0 ⊗ b1 ⊕ r} {a1 ⊗ b0 ⊕ r} {a1 ⊗ b1 ⊕ a0 ⊗ b1 ⊕ r} {a0 ⊗ b0 ⊕ a1 ⊗ b0 ⊕ r}

25 / 47

slide-53
SLIDE 53

First order DOM AND : NI with glitches

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0, b1} {a1, b0} {a0, b0} {a1, b1} {r} {a0, b1, r} {a1, b0, r} {a0, a1, b0, b1, r} {a0, a1, b0, b1, r}

25 / 47

slide-54
SLIDE 54

First order DOM AND : NI with glitches

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0, b1} {a1, b0} {a0, b0} {a1, b1} {r}

FF FF

{a0, b1, r} {a1, b0, r}

25 / 47

slide-55
SLIDE 55

First order DOM AND : NI with glitches

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0, b1} {a1, b0} {a0, b0} {a1, b1} {r}

FF FF

{a0, b1, r} {a1, b0, r} {a0b1 + r}

25 / 47

slide-56
SLIDE 56

First order DOM AND : NI with glitches

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0, b1} {a1, b0} {a0, b0} {a1, b1} {r}

FF FF

{a0, b1, r} {a1, b0, r} {a0b1 + r, a1, b1} {a1b0 + r, a0, b0} {a0b1 + r} {a1b0 + r}

25 / 47

slide-57
SLIDE 57

First order DOM AND : NI with glitches

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0, b1} {a1, b0} {a0, b0} {a1, b1} {r}

FF FF

{a0, b1, r} {a1, b0, r} {a0b1 + r, a1, b1} {a1b0 + r, a0, b0} {a0b1 + r} {a1b0 + r} {a0, b1, r}

25 / 47

slide-58
SLIDE 58

First order DOM AND : NI with glitches

a0 b0 a1 b1

  • r
  • c1

c0

{a0} {b0} {a0} {b1} {a1} {b0} {a1} {b1} {a0, b1} {a1, b0} {a0, b0} {a1, b1} {r}

FF FF

{a0, b1, r} {a1, b0, r} {a0b1 + r, a1, b1} {a1b0 + r, a0, b0} {a0b1 + r} {a1b0 + r} {a0, b1, r} {a0b1 + r, a1, b1} {a1b0 + r, a0, b0} {a1, b0, r}

25 / 47

slide-59
SLIDE 59

Hardware implementation

We have extended maskVerif to

take Verilog implementation as input take extra information on input shares (random, shares secret,

public input)

Check the security with or without glitches

26 / 47

slide-60
SLIDE 60

Demo Hardware

https://sites.google.com/view/maskverif/home

yosys + maskVerif

27 / 47

slide-61
SLIDE 61

Examples (provided by Bloem et al)

Algo # obs probing wG woG wG woG first-order verification Trichina AND 2 13 0.01s ✗ 0.01s ✗ ISW AND 1 13 0.01s ✗ 0.01s DOM AND 4 13 0.01s 0.01s DOM Keccak S-box 20 76 0.01s 0.01s DOM AES S-box 96 571 2.3s 0.4s second-order verification DOM Keccak S-box 60 165 0.02s 0.02s third-order verification DOM Keccak S-box 100 290 0.28s 0.25s fourth-order verification DOM Keccak S-box 150 450 11s 14s fifth-order verification DOM Keccak S-box 210 618 9m44s 18m39s

28 / 47

slide-62
SLIDE 62

1 Side-Channel Attacks and Masking 2 Formal Tools for Verification at Fixed Order 3 Formal Tools for Verification of Generic Implementations

29 / 47

slide-63
SLIDE 63

Probing Model

Require: Encoding [x] Ensure: Fresh encoding [x] for i = 1 to t do r ← $ x0 ← x0 + r xi ← xi + r end for return [x]

30 / 47

slide-64
SLIDE 64

Probing Model

Require: Encoding [x] Ensure: Fresh encoding [x] for i = 1 to t do r ← $ x0 ← x0 + r xi ← xi + r end for return [x]

Simulation-based proof:

show that any set of t variables can be simulated with at most

t input shares xi

any set of t shares xi is independent from x

30 / 47

slide-65
SLIDE 65

Probing Model

Require: Encoding [x] Ensure: Fresh encoding [x] for i = 1 to t do r ← $ x0 ← x0 + r xi ← xi + r end for return [x]

Simulation-based proof:

show that any set of t variables can be simulated with at most

t input shares xi

any set of t shares xi is independent from x exactly relies on the notion of non interference (NI)

30 / 47

slide-66
SLIDE 66

And then?

  • nce done for small gadgets, how to extend it?

31 / 47

slide-67
SLIDE 67

Until Recently

composition probing secure for 2t + 1 shares no solution for t + 1 shares

32 / 47

slide-68
SLIDE 68

First Proposal

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

[x] [·2] [×] [x] [·2] R [×]

Require: Encoding [x] Ensure: Fresh encoding [x] for i = 1 to t do r ← $ x0 ← x0 + r xi ← xi + r end for return [x]

33 / 47

slide-69
SLIDE 69

First Proposal

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

[x] [·2] [×] [x] [·2] R [×]

Require: Encoding [x] Ensure: Fresh encoding [x] for i = 1 to t do r ← $ x0 ← x0 + r xi ← xi + r end for return [x]

⇒ Flaw from t = 2 (FSE 2013: Coron, Prouff, Rivain, and Roche)

33 / 47

slide-70
SLIDE 70

Why This Flaw?

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0

  • bservations

t1

  • bservations

t2

  • bservations

t3

  • bservations

34 / 47

slide-71
SLIDE 71

Why This Flaw?

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0

  • bservations

t1

  • bservations

t2

  • bservations

t3

  • bservations

34 / 47

slide-72
SLIDE 72

Why This Flaw?

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1

  • bservations

t2 + t3

  • bservations

34 / 47

slide-73
SLIDE 73

Why This Flaw?

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1

  • bservations

t2 + t3

  • bservations

34 / 47

slide-74
SLIDE 74

Why This Flaw?

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1 + t2 + t3

  • bservations

34 / 47

slide-75
SLIDE 75

Why This Flaw?

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1 + t2 + t3

  • bservations

34 / 47

slide-76
SLIDE 76

Why This Flaw?

Rivain and Prouff (CHES 2010): add refresh gadgets (NI) Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3 +t1 + t2 + t3

  • bservations

34 / 47

slide-77
SLIDE 77

Second Proposal

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

[x] [·2] [×] [x] [·2] R [×]

Require: Encoding [x] Ensure: Fresh encoding [x] for i = 0 to t do for j = i + 1 to t do r ← $ xi ← xi + r xj ← xj + r end for end for return [x]

35 / 47

slide-78
SLIDE 78

Second Proposal

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

[x] [·2] [×] [x] [·2] R [×]

Require: Encoding [x] Ensure: Fresh encoding [x] for i = 0 to t do for j = i + 1 to t do r ← $ xi ← xi + r xj ← xj + r end for end for return [x]

⇒ Formal security proof for any order t

35 / 47

slide-79
SLIDE 79

Strong Non-Interference (SNI)

t-SNI ⇒ t-NI ⇒ t-probing secure a circuit is t-SNI iff any set of t intermediate variables, whose

t1 on the internal variables and t2 and the outputs, can be perfectly simulated with at most t1 shares of each input

function Ex-t3(x0, x1, x2, x3, c):

(* x0, x1, x2 = $ *) (* x3 = x + x0 + x1 + x2 *)

r0 ← $ r1 ← $ y0 ← x0 + r0 y1 ← x3 + r1 t1 ← x1 + r0 t2 ← (x1 + r0) + x2 y2 ← (x1 + r0 + x2) + r1 y3 ← c + r1 return(y0, y1, y2, y3) require x0 and x1 to be perfectly simulated ⇒ not 3-SNI since y0 is an output variable

36 / 47

slide-80
SLIDE 80

Strong Non-Interference (SNI)

t-SNI ⇒ t-NI ⇒ t-probing secure a circuit is t-SNI iff any set of t intermediate variables, whose

t1 on the internal variables and t2 and the outputs, can be perfectly simulated with at most t1 shares of each input Refresh 2 internal

  • bservations

+ 1 output

  • bservation

x0 x1 x2 x3 y0 y1 y2 y3

37 / 47

slide-81
SLIDE 81

Why Does It Works?

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0

  • bservations

t1

  • bservations

t2

  • bservations

t3

  • bservations

38 / 47

slide-82
SLIDE 82

Why Does It Works?

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0

  • bservations

t1

  • bservations

t2

  • bservations

t3

  • bservations

38 / 47

slide-83
SLIDE 83

Why Does It Works?

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1

  • bservations

t2 internal observations t3 output observations

38 / 47

slide-84
SLIDE 84

Why Does It Works?

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1

  • bservations

t2 internal observations t3 output observations

38 / 47

slide-85
SLIDE 85

Why Does It Works?

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1 + t2

  • bservations

t3 output observations

38 / 47

slide-86
SLIDE 86

Why Does It Works?

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3

  • bservations

t1 + t2

  • bservations

t3 output observations

38 / 47

slide-87
SLIDE 87

Why Does It Works?

Barthe, B., Dupressoir, Fouque, Gr´

egoire, Strub, Zucchini (CCS 2016): add stronger refresh gadgets (SNI)

Example: AES S-box on GF(28)

Constraint: t0 + t1 + t2 + t3 t [x] [·2] R [×] t0 + t3 +t1 + t2

  • bservations

t3 output ob- servations

38 / 47

slide-88
SLIDE 88

Tool maskComp

from t-NI and t-SNI gadgets ⇒ build a t-NI circuit by

inserting t-SNI refresh gadgets at carefully chosen locations

formally proven

maskComp

Implementation in C language with no countermeasure t-NI secure implementation in C language

Gilles Barthe and Sonia Bela¨ ıd and Fran¸ cois Dupressoir and Pierre-Alain Fouque and Benjamin Gr´ egoire and Pierre-Yves Strub Strong Non-Interference and Type-Directed Higher-Order Masking and Rebecca Zucchini, ACM CCS 2016, Proceedings, 116–129.

39 / 47

slide-89
SLIDE 89

Demo AES S-box without refresh

https://sites.google.com/site/maskingcompiler/home

[x] [·2] [×] > ./maskcomp.native − o myoutput masked.c x3.c

40 / 47

slide-90
SLIDE 90

Demo AES S-box with refresh

https://sites.google.com/site/maskingcompiler/home

[x] [·2] R [×] > ./maskcomp.native − o myoutput masked.c x3.c

41 / 47

slide-91
SLIDE 91

Demo full AES

https://sites.google.com/site/maskingcompiler/home

> ./maskcomp.native − o myoutput masked.c aes.c

42 / 47

slide-92
SLIDE 92

Limitations of maskComp

maskComp adds a refresh gadget to Circuit 1 but Circuit 1 was already t-probing secure

[x1] [x2] [+] [×]

Figure: Circuit 1.

[x1] [x2] [+] R [×]

Figure: Circuit 1 after maskComp.

43 / 47

slide-93
SLIDE 93

Tool tightPROVE

Joint work with Dahmun Goudarzi and Matthieu Rivain to

appear in Asiacrypt 2018

Apply to tight shared circuits: ◮ sharewise additions, ◮ ISW-multiplications, ◮ ISW-refresh gadgets Determine exactly whether a tight shared circuit is probing

secure for any order t

  • 1. Reduction to a simplified problem
  • 2. Resolution of the simplified problem
  • 3. Extension to larger circuits

44 / 47

slide-94
SLIDE 94

Demo tightPROVE 1

[x1] [x2] [⊕] [⊗] (1) (2) (3)

in 0 in 1 xor 0 1 and 0 2

  • ut 3

  • list_comb =

[1, 3]

  • comb =

1 => NO ATTACK (G2 = G1) G: [[(1 ,3)], []] O: [[3] , []]

  • comb =

3 => NO ATTACK (G2 = G1) G: [[(1 ,3)], []] O: [[1] , []]

  • No attack

found

> sage verif.sage example1.circuit

45 / 47

slide-95
SLIDE 95

Demo tightPROVE 2

[x1] [x2] [x3] [⊕] [⊕] [⊗] [⊗] [⊗] (1) (2) (4) (3) (6)

in 0 in 1 in 2 xor 0 1 xor 1 2 and 0 1 and 3 4 and 2 3

  • ut 5
  • ut 6
  • ut 7

> sage verif.sage example2.circuit

46 / 47

slide-96
SLIDE 96

Demo tightPROVE 2

[x1] [x2] [x3] [⊕] [⊕] [⊗] [⊗] [⊗] (1) (2) (4) (3) (6)

in 0 in 1 in 2 xor 0 1 xor 1 2 and 0 1 and 3 4 and 2 3

  • ut 5
  • ut 6
  • ut 7

  • list_comb =

[1, 3, 2, 4, 6]

  • comb =

1 => NO ATTACK (G3 = G2) G: [[(1 ,2)], [(3 ,6) ,(3,4)], []] O: [[2] , [6, 4], []]

  • comb =

3 => NO ATTACK (G3 = G2) G: [[(3 ,6) ,(3,4)], [(1 ,2)], []] O: [[6, 4], [2], []]

  • comb =

2 => ATTACK G: [[(1 ,2)], [(3 ,6) ,(3,4)]] O: [[1] , [6, 4]]

  • Attack

found: 2 in span [1, 6, 4]

> sage verif.sage example2.circuit

46 / 47

slide-97
SLIDE 97

Conclusion

In a nutshell...

Formal tools to verify security of masked implementations Trade-off between security and performances

To continue...

Achieve better performances Apply such formal verifications to every circuit

47 / 47