HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. ·...

33
How Dierential Power Attacks Work Profiled Attack Example Pipeline for Our Example Using SCALE Atmel dataset A Acquire training data traces, random known plaintexts Fixed known key is less ideal Traces are already aligned B Build a profile 1 We already identified potential PoIs 2 Model and profiling tbd C Collect target traces traces, random known plaintexts D Distinguish 1 Template Attack 2 Stochastic Attack

Transcript of HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. ·...

Page 1: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 28

Pipeline for Our ExampleUsing SCALE Atmel dataset

A Acquire training data1000 traces, random known plaintextsFixed known key is less idealTraces are already aligned

B Build a profile1 We already identified potential PoIs2 Model and profiling tbd

C Collect target traces1000 traces, random known plaintexts

D Distinguish1 Template Attack2 Stochastic Attack

Page 2: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 29

Template AttacksNaive Bayes

i xi power0 12 1.35. . .1 123 4.65. . ....

......

......

...999 59 2.79. . .

k0 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

1. From Probability to Likelihood

For each key candidate k determine its a posteriori probabilitygiven the observed leakage L

Page 3: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 29

Template AttacksNaive Bayes

i xi power0 12 1.35. . .1 123 4.65. . ....

......

......

...999 59 2.79. . .

k0 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

1. From Probability to Likelihood

Pr[k | L ] = Pr[L | k ] · Pr[k ]Pr[L]

Pr[L | k ] is the likelihoodPr[k ] and Pr[L] can be ignored

Page 4: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 29

Template AttacksNaive Bayes

i xi power0 12 1.35. . .1 123 4.65. . ....

......

......

...999 59 2.79. . .

k0 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

2. From Likelihood to Sum of Log Likelihoods

Assume each trace leaks independently, then

Pr[L | k ] =∏i

Pr[Li | k ]

Page 5: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 29

Template AttacksNaive Bayes

i xi power0 12 1.35. . .1 123 4.65. . ....

......

......

...999 59 2.79. . .

k0 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

2. From Likelihood to Sum of Log Likelihoods

Assume each trace leaks independently, then a�er taking logs

log2 Pr[L | k ] =∑i

log2 Pr[Li | k ]

Page 6: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 29

Template AttacksNaive Bayes

i xi power0 12 1.35. . .1 123 4.65. . ....

......

......

...999 59 2.79. . .

k0 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

From Log Likelihood to QDA

AssumeL(data) ∼ M̂(xi ⊕ k∗) +N (0, σ)

thenlog2 Pr[Li | k ] = log2N (Li − M̂(xi ⊕ k); 0, σ)

Page 7: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 29

Template AttacksNaive Bayes

i xi power0 12 1.35. . .1 123 4.65. . ....

......

......

...999 59 2.79. . .

k0 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

From Log Likelihood to QDA

AssumeL(data) ∼ M̂(xi ⊕ k∗) +N (0, σ)

then

log2 Pr[Li | k ] = − log2 e(Li − M̂(xi ⊕ k)

)2/2σ2 − 1

2(1+ log2 π)− σ

Page 8: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 29

Template AttacksNaive Bayes

i xi power0 12 1.35. . .1 123 4.65. . ....

......

......

...999 59 2.79. . .

k0 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

QDA Summary

score(k|L) =∑i

(Li − M̂(xi ⊕ k))2

To profile: M̂(z) for all 256 possible z

Warning: Scores can no longer be interpreted as posteriors

Page 9: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 30

Template and Stochastic AttacksSCALE Atmel Profiling

0 50 100 150 200 2500.04

0.02

0.00

0.02

0.04

110050 50 100 150 200 250

0.04

0.02

0.00

0.02

0.04

11223

Template Attack

For all 256 possible S-box input valuesdetermine the sample mean(optional) determine the sample variance

Problem: 1000 traces is not enough to estimate 256 parameters

Page 10: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 30

Template and Stochastic AttacksSCALE Atmel Profiling

0 1 2 3 4 5 6 7 8

0.04

0.02

0.00

0.02

0.04 Original dataFitted line

110050 1 2 3 4 5 6 7 8

0.01

0.00

0.01

0.02

0.03

0.04 Original dataFitted line

11223

Stochastic AttackAssume the leakage modelMa,b(k, x) = a · HammingWeight(Sbox(x ⊕ k)) + b

estimate a and b(Warning: The right estimation is naively unweighted)

Page 11: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 31

Template AttacksSCALE Atmel Scores

0 50 100 150 200 250

2000

3000

4000

5000

6000

7000

110050 50 100 150 200 250

45000

46000

47000

48000

49000

11223

Final distinguishing scores

A�er incorporating 1000 target tracesleft One candidate key very clearly sticks outright One candidate key sticks out, but not as much

Page 12: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 31

Template AttacksSCALE Atmel Scores

0 200 400 600 800 10000

2

4

6

8

10

110050 200 400 600 800 1000

40.0

42.5

45.0

47.5

50.0

52.5

55.0

57.5

60.0

11223

Evolution of distinguishing scores

Look at scores as a function of number of traces incorporatedleft the true key quickly separates from the restright it takes much longer for the true key to stand out

In blue the actual keybyte

Page 13: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 31

Template AttacksSCALE Atmel Scores

0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.50

2

4

6

8

10

12

14

110050.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5

0

25

50

75

100

125

150

175

11223

Evolution of distinguishing scores

Look at scores as a function of number of traces incorporatedleft the true key quickly separates from the restright it takes much longer for the true key to stand out

In blue the actual keybyte

Page 14: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 32

Template AttacksSCALE Atmel Success Rate

0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.50.0

0.2

0.4

0.6

0.8

110050 25 50 75 100 125 150 175 200

0.00

0.05

0.10

0.15

0.20

0.25

11223

Success Rate: Probability that best guess wins

For each i (x-axis), ran 2000 experiments:1 Selected i out of 1000 traces2 Check if best guess is actual keybyte

Warning: resampling methodology used due to available data

Page 15: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

How Di�erential Power Attacks Work Profiled Attack Example 32

Template AttacksSCALE Atmel Success Rate

0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.50.0

0.2

0.4

0.6

0.8

110050 25 50 75 100 125 150 175 200

0.00

0.05

0.10

0.15

0.20

0.25

11223

Success rate conclusion1 Le� performs better than right2 Success rate 2−2 for a single keybyte, only gives 2−32 for the full16-byte key.

Note: jaggedness likely due to low number of experiments

Page 16: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 33

Different Adversarial ScenariosNot-Quite-Kerckhoffs Principle

A

K∗ ←$ Kg

Leak←$L

assert Leak ∈ L

C ← EK∗ (X)

L←$ Leak(K∗, X)

L← Leak(K,X)

win← K = K∗K

win

The adversary can exhaustively search the key

Page 17: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 33

Different Adversarial ScenariosNot-Quite-Kerckhoffs Principle

A

K∗ ←$ KgLeak←$L

assert Leak ∈ L

C ← EK∗ (X)

L←$ Leak(K∗, X)

X L

L← Leak(K,X)

K,X

L

win← K = K∗K

win

The adversary can enumerate the key

Page 18: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 34

EnumerationEnhancing Divide-and-Conquer Attacks

k0 score0 0.123. . .1 0.127. . ....

...255 0.238. . .

k1 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

. . .

k15 score0 0.184. . .1 0.167. . ....

...255 0.152. . .

Best guess Simply output the most likely 128-bit key overallKey enumeration Test keys frommost likely to least likely until success

Page 19: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 34

EnumerationEnhancing Divide-and-Conquer Attacks

k0 score0 0.123. . .1 0.127. . ....

...255 0.238. . .

k1 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

. . .

k15 score0 0.184. . .1 0.167. . ....

...255 0.152. . .

Best guess obviously k0 = 0, k1 = 255, . . . , k15 = 255

But what about the next best guess?

Question posed by Veyrat-Charvillon et al. (SAC’12)

Page 20: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 34

EnumerationEnhancing Divide-and-Conquer Attacks

k0 score0 0.123. . .1 0.127. . ....

...255 0.238. . .

k1 score0 0.134. . .1 0.116. . ....

...255 0.098. . .

. . .

k15 score0 0.184. . .1 0.167. . ....

...255 0.152. . .

DPA with EnumerationA number of cost metrics

1 The number of traces (profile vs.target)2 The running time of the distinguisher3 The number of keys to test4 The overhead (in time) to enumerate

Page 21: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 34

EnumerationEnhancing Divide-and-Conquer Attacks

Some approaches

Naive Create ordered list of all 2128 keys2012 Tree-like recursion algorithm

[Veyrat-Charvillon, Gérard, Renauld, Standaert / SAC]

2015 Dynamic programming enabling parallellization[Martin, O’Connell, Oswald, Stam / Asiacrypt]

Page 22: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 35

A Typical Side-Channel Attack Pipeline

Adding Enumeration

A�er the Distinguish phase, the scores are fed to an Enumeration phase

Page 23: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Enumeration 35

A Typical Side-Channel Attack Pipeline

Adding Enumeration

A�er the Distinguish phase, the scores are fed to an Enumeration phase

But how long will it take, roughly?

Question posed by Veyrat-Charvillon et al. (Eurocrypt’13)

Page 24: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Ranking 36

A Typical Side-Channel Attack Pipeline

Emulating Enumeration

A�er the Distinguishing phase,use knowledge of the target key to determine its rank.

Rather than running enumeration, Emulate it to predict its runtime

Page 25: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Ranking 37

Key RankingEmulating the cost of key enumeration

Relevance: EvaluationMany SCA are run by evalution labs:

The care not about actually recovering the keyOnly how di�icult it is to do so

The target key will be known already!

Ranking algorithms

A number of relevant metrics1 The time to compute2 Potential for parallellization3 Quality of the returned rank when approximating

Page 26: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Ranking 37

Key RankingEmulating the cost of key enumeration

Some algorithmic approaches

lore Adding “guessing entropies”2013 Tree-like recursion algorithm

[Veyrat-Charvillon, Gérard, Renauld, Standaert / Eurocrypt]

2015 Dynamic programming enabling parallellization[Martin, O’Connell, Oswald, Stam / Asiacrypt]

2015 Convolution of histograms[Glowacz, Grosso, Poussier, Schüth, Standaert / FSE][Bernstein, Lange, van Vredendaal / eprint]

Page 27: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Ranking 38

Key Rank DistributionsMartin, Mather, Oswald, Stam / Asiacrypt’16

A

K∗ ←$ KgLeak←$L

assert Leak ∈ L

C ← EK∗ (X)

L←$ Leak(K∗, X)

X L

L← Leak(K,X)L← Leak(K,X)

K,X

L

win← K = K∗K

win

The Rank DistributionEvaluator’s task for some keyed device:

How long will it roughly take to recover the keyas a function of the number of traces?

Page 28: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Ranking 38

Key Rank DistributionsMartin, Mather, Oswald, Stam / Asiacrypt’16

A

K∗ ←$ KgLeak←$L

assert Leak ∈ LC ← EK∗ (X)

L←$ Leak(K∗, X)

Leak, X L

L← Leak(K,X)L← Leak(K,X)

K,X

L

win← K = K∗K

win

MMOS Setup

AES-128 with simulated leakageSbox output Hamming weight with Gaussian noiseFor SNRs 2x with x ∈ {−7,−5,−3}Ran an unprofiled Correlation Power Attack (CPA)

Page 29: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Ranking 38

Key Rank DistributionsMartin, Mather, Oswald, Stam / Asiacrypt’16

MMOS Lessons1 Average log rank is more useful than log of average rankgeometric mean versus arithmetic mean

2 The variance in the rank is considerable, esp. in the middle3 SNR does not a�ect the shape of the distribution beyond scaling x-axis

Page 30: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Key Enumeration and Ranking Ranking 38

Key Rank DistributionsMartin, Mather, Oswald, Stam / Asiacrypt’16

Challenges

1 Improved sensor fusion to combine subkey scores2 Optimize distinguishers w.r.t. resulting key ranks

Model and feature selectionScore computation

3 Rank distribution against various countermeasures

Page 31: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Conclusion Want to Learn More? 39

SCALE: A Resource by Dan Pagehttps://github.com/danpage/scale

Side-Channel Attack Lab. ExercisesProvides a suite of material related to side-channel(and fault) attacks that is low-cost, accessible,relevant, coherent, and e�ective.

SCALE Data Sets

1 Four platforms: an Atmel atmega328p (an AVR) plus three NXP ARMCortex-M processors

2 Implementation uses an 8-bit datapath and look-up tables for theS-box and xtime operations (but code not known)

3 2× 1000 traces of AES-128 each (known vs. unknown key)4 Traces acquired using a Picoscope 2206B, using triggers for alignment

Page 32: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Conclusion Want to Learn More? 40

Power Analysis AttacksStefan Mangard, Elisabeth Oswald, and Thomas Popp’s Classic

Revealing the Secrets of Smart Cards

“first comprehensive treatment of poweranalysis attacks and countermeasures”Aimed at the practitionerFrom 2007⇒ nomodern ideas and theory

Page 33: HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 … · 2019. 6. 13. · HowDi˙erentialPowerAttacksWork ProfiledAttackExample 28 Pipeline for Our Example Using SCALE Atmel

Conclusion Want to Learn More? 41

CHESAn IACR Conference

Cryptographic Hardware and EmbeddedSystems

Established in 1999E�icient implementationsHow tomount implementation attacksHow to protect against themNew designs that allow e�icient yet secureimplementations

https://ches.iacr.org