eloi sanfelix - hardware security: side channel attacks [rootedcon 2011]

45
Hardware Security: Side Channel Attacks Eloi Sanfelix [email protected]

Post on 21-Oct-2014

3.524 views

Category:

Documents


7 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Hardware Security: Side Channel Attacks

Eloi Sanfelix

[email protected]

Page 2: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Introduction: Secure hardware and attacks

Side Channel Analysis

Conclusion

Protecting your device

Tips for developers

Perturbation attacks

Agenda

Page 3: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Introduction: Secure hardware and attacks

Side Channel Analysis

Conclusion

Protecting your device

Tips for developers

Perturbation Attacks

Agenda

Page 4: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Secure Devices

MainCPU

CryptoCPU

Secure Storage

Tamper-proof enclosure

Page 5: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Example: smart cards

ISO 7816Image source: dhgate.com

Page 6: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Secure device attack types

Invasive Logical

Side Channel

Page 7: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Agenda

Introduction: Secure hardware and attacks

Conclusion

Protecting your device

Tips for developers

Perturbation Attacks

Side Channel Analysis

Page 8: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Side Channels IRL

8

30/7/90 31/7/90 1/8/90 2/8/900

5

10

15

20

25

Iraq invades Kuwait...

Page 9: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

A different threat model

But we also need to

• Beware of leakage

• Protect run-time integrity

Common paradigm

• Do not trust input

• Preserve confidentiality and

integrity in output

Local: at input / output Pervasive: throughout code

Code

Code

Page 10: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

10

Side channel attacks

• Passive (SCA): Read ‘hidden’ signals

– timing

– power consumption

– electromagnetic emission

• Active (FI): Signal injection

– power glitches

– electromagnetic pulses

Page 11: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

SCA Measurement setup

Page 12: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

12

Smart card power reader

Page 13: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Power / EM traces

• Signal leakage from busses, registers, ALUs, etc

PIN verification attempts

Page 14: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

'Simple' Power Analysis

• Analyse few traces (vs statistical analysis)

• Example: COMP128-1 crypto algorithm

• C code: x = table_512[k+d]

k+d < 256

k+d ≥ 256

Page 15: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Data influence

• Example trace of software DES on smart card

• Leaks hamming weight of data

noiseProfit! (data)

Page 16: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Statistical data detection

• Where is data processed in presence of noise?

Page 17: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Statistical data detection

• Where is data processed in presence of noise?

• Collect many traces with different data (n > 1000)

• Use known uniformly random input/output data

• We focus on one bit of one variable in the process

00

00

11

11

Group by known data Average trace

Subtract

Differential trace

Page 18: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Differential trace

• Input: n traces with known variable (e.g. input or output)

• Output: 1 trace with indication where bit causes trace differences

Page 19: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

But…you promised keys !?

• Keys are used in small chunks• Mixed with input data

Use hypothesis testing!

0 1 0 1

1 1 1 0

1 0 1 1

0 1 1 0

H0 H1 H2 H3

Page 20: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Hypothesis incorrect

• Group traces according to hypothesis

• If the actual data does not match the hypothesis:

– We group the wrong traces

– Statistically, the averages will be similar

• Result: noise

01

01

10

01

Group by wrong data Average trace

Subtract

Page 21: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Hypothesis correct

• Group traces according to hypothesis

• If the actual data does match the hypothesis:

– Only differences in measurement caused by different data

between averages

• Result: peaks!

00

00

11

11

Group by right data Average trace

Subtract

Page 22: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Tricky...

Page 23: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

DPA on (3)DES

K1

K2

K15

K16

?!

Page 24: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Use hypothesis testing

• Hypothesis testing; each 6-bit subkey value leads to different hypothesis for the sbox output

TracesH0 H1 ... H63

Sbox output

n

0 1 ... 1

1 1 ... 0

1 0 ... 1

0 1 ... 0

Page 25: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Calculate differential traces

H0 H1 H56 H63Sbox output

n

64 differential traces

0 1 1 1

1 1 1 0

1 0 1 1

0 1 0 0

Page 26: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Find best candidate

64 differential traces

Repeat for other sboxes and

rounds for full key

Page 27: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

DEMOs

Page 28: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Reality check

• Smart card manufacturers know about DPA

• Often difficult finding correct filtering and alignment

– Advanced preprocessing necessary

• Countermeasures in hard- and software

• On embedded systems, not so much...

Page 29: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Agenda

Side Channel Analysis

Conclusion

Protecting your device

Tips for developers

Perturbation attacks

Introduction: Secure hardware and attacks

Page 30: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Fault Injection

• Chip/Hardware operating conditions

– Temperature

– Frequency

– Power supply (input voltage)

– Localized energy increase (Laser, EM, others?)

• Fault injection modifies operating conditions

– Bring chip outside normal situation to make it fail

Page 31: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Fault Injection Setup

Page 32: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Voltage glitching

1

A power dip at the moment of reading a memory cell

0

Page 33: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Fault Injection Effects

Laser/voltageglitch

Data/Memory manipulation

Page 34: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Fault Injection Effects

Laser/voltageglitch

Program flow manipulation

Page 35: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Differential Fault Analysis

Correct result

Faulty result

Correct result

Faulty result

Correct result

Faulty result

Correct result

Faulty result

DFA

Page 36: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

RSA and RSA-CRT

• RSA works with modular exponentiations

• RSA-CRT splits big exponentiation in two smaller ones

dp = d mod (p-1)

dq = d mod (q-1)

K = p-1 mod q

Sp = Mdp mod p

Sq = Mdq mod q

S = ( ( (Sq - Sp)*K ) mod q ) * p + Sp

S = Md (mod n)

Page 37: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Bellcore attack on RSA-CRT

• Suppose single fault into one exponentiation

• Now, subtract S’ from S

• Now take gcd(s-s’,n)

– gcd(x*p,p*q) = p

– Compute q=n/p and you’re done!

• An attack variant exists that only requires S’ and M

S’ = ( ( (S’q - Sp)*K ) mod q ) * p + Sp

S - S’ = (((Sq - Sp)*K) mod q)*p - (((S’q - Sp)*K) mod q)*p= (x1-x2)*p mod N

Page 38: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Demo: Bellcore’s attack

Page 39: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Agenda

Side Channel Analysis

Conclusion

Perturbation Attacks

Protecting your device

Tips for developers

Introduction: Secure hardware and attacks

Page 40: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

SCA Countermeasures

• Application level

– NEVER brew your own crypto

– Introduce random delays between critical functions

– Avoid branches related to secret data

– See helpful patterns in reference [1]

• Operating System level

– Masking and hiding countermeasures. See e.g. [2],[3]

• Have your systems tested

– Side channel vulnerabilities can be very subtle!

Page 41: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Fault Injection countermeasures

• Double check critical results

– Encrypt-Decrypt-Compare

– Two comparisons in authentication checks

– Add a random wait between the two checks

• Protect code flow integrity

– Introduce ‘shadow program counters’

• Never output wrong results

– Most DFA attacks are based on this!

• See more at [1]

Page 42: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Side Channel Analysis

Perturbation Attacks

Introduction: Secure hardware and attacks

Protecting your device

Tips for developers

Conclusion

Agenda

Page 43: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Conclusion

• Devices under attacker’s control

– Physical threats need to be considered

– Complete protection very difficult

– Countermeasures based on increasing attack effort

• Side channel problems are difficult to spot

– Compiler and hardware behavior could break your code!

– Impossible to know without testing

Page 44: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

Thank you!!

[email protected]

Page 45: Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]

References

[1] Secure Application Programming in the Presence of Side

Channel Attacks – Download link

[2] Power Analysis Attacks – http://www.dpabook.org

[3] Cryptography Research Inc. – DPA Countermeasures

[4] Riscure – Publications

[5] E. Bhiam, A.Shamir – Differential Fault Analysis of Secret Key

Cryptosystems