Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

95
Extracting keys from FPGAs, OTP Tokens and Door Locks David Oswald [email protected] Side-Channel (and other) Attacks in Practice

Transcript of Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Page 1: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Extracting keys from FPGAs, OTP Tokens and Door Locks

David Oswald

[email protected]

Side-Channel (and other) Attacks in Practice

Page 2: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

2

No, I did not do all this stuff alone

Christof Paar

Benedikt Driessen

Timo Kasper

Gregor Leander

Amir Moradi

Falk Schellenberg

Daehyun Strobel

Pawel Swierczynski

Bastian Richter

If you wondered about my shirt: http://fb.com/WorldBeatClubTanzenUndHelfen

Page 3: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

3

Page 4: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

4 Sabre: Madboy74

Page 5: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

5

Ruhr-University Bochum: beautiful.

Page 6: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

6

Announcement

Timo at 29C3: „ChameleonMini in 2013“

As of December 22, 2013: https://github.com/skuep/ChameleonMini

Page 7: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Embedded systems everywhere

Page 8: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

8

(The life of) a typical pirate

Pegleg

Eye patch

Pirate hat

Pirate laughter

Page 9: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

9

Page 10: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

10

Page 11: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

11

Page 12: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

12

Page 13: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

13

Report flaws

Improve

Page 14: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Implementation Attacks: …

Page 15: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

15 Based on Skoborogatov

Page 16: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

16

Principle of Side-Channel Analysis (here: listen to sound)

A Bank Robbery

Page 17: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

17

Principle of Side-Channel Analysis

The world is changing…

Page 18: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

18

Principle of Side-Channel Analysis (Now: measure the power consumption / EM)

The world is changing …

… the tools are, too.

Page 19: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

19

Side-Channel Analysis: Leakage

Power consumption / EM depends on processed data

Data = 1111

Data = 0000

Data = 1010

Page 20: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

20

Evaluation Methods: SPA

Simple Power Analysis: Directly analyze (few) traces, for example RSA:

Page 21: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

21

Evaluation Methods: DPA / CPA

Differential Power Analysis

Detect statistical dependency: Key guess ⟺ Side-channel

Idea: Brute-force w/ additional information

Use a statistical test...

Page 22: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

22

Source: phdcomics.com

Wrong key candidate(s)

Correct key candidate

100 – 1 mio. measurements

Page 23: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Implementation Attacks: From Theory to Practice

Page 24: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

24

Case Studies

Locking system

Yubikey 2

Altera Stratix II

Page 25: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

25

Home Port

Bochum

Page 26: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

26

FPGA

2013

Page 27: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

27

Case Studies

Locking system

Yubikey 2

Altera Stratix II

Page 28: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

28

FPGAs widely used in • Routers • Consumer products • Cars • Military

Problem: FPGA design (bitstream) can be easily copied

FPGAs

Page 29: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

29

FPGA 1

Flash

Bitstream

FPGA Power-Up

Page 30: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

30

FPGA 1

Flash

Bitstream

FPGA 2

Clone

Problem: Cloning

Page 31: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

31

FPGA 1

Flash

Encrypted bitstream

Industry‘s Solution

Page 32: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

32

FPGA 1

Flash

Encrypted bitstream

= ?

Industry‘s Solution

Page 33: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

33

Related Work

Bitstream encryption scheme of several Xilinx product lines broken

– Virtex 2 (3DES)

– Virtex 4 & 5 (AES256)

– Spartan 6 (AES256)

Method: Side-Channel Analysis (SCA)

Page 34: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

34

What about Altera?

Target: Stratix II

Bitstream encryption („design security“) uses AES w/ 128-bit key

Side-Channel Analysis possible?

Problem: Proprietary and undocumented mechanisms for key derivation and for encryption

Page 35: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

35 35

Reverse-Engineering

• Reverse-engineer proprietary mechanisms from Quartus II software

• IDA Pro (disassembler / debugger)

Page 36: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

36

KEY1 / KEY2 file for FPGA

Page 37: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

37

Key derivation real key =

f(KEY1,KEY2)

KEY1 / KEY2 file for FPGA

Page 38: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

38

Why this key derivation?

Real key cannot be set directly

Key derivation is performed once when programming the FPGA

Idea: When real key is extracted, KEY1 and KEY2 cannot be found

Prevent cloning: real key of blank FPGA cannot be set

Page 39: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

39

„real key“ = AESKEY1(KEY2)

Is f (KEY1,KEY2) „good“?

Page 40: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

40 40

Good idea?

• In principle: Yes

• But: AES (in this form) is not one-way:

• Pick any KEY1*

• KEY2* = AES-1KEY1*(real key)

• This (KEY1*, KEY2*) leads to same real key

Page 41: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

41

real key = AESKEY1(KEY2)

KEY1 / KEY2 file for FPGA

Page 42: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

42

real key = AESKEY1(KEY2) encreal key(...)

KEY1 / KEY2 file for FPGA

Page 43: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

43

Encrypted block i = AES128real key(IVi) plain block i

Encryption method: AES in Counter mode

Page 44: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

44

Reverse-Engineering: Summary

All „obscurity features“ reverse-engineered

Further details: file format, coding, ...

Black-box white box

Side-channel analysis possible (target: 128-bit real key)

Page 45: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

45

Side-Channel Attack on Stratix II

Page 46: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

46

Page 47: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

47

Mean trace for unencrypted and encrypted bitstream

Page 48: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

48

Mean trace for unencrypted and encrypted bitstream

Page 49: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

49

Further experiments ...

Page 50: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

50

Recover the 128-bit AES key with 30,000 traces (~ 3 hours of measurement)

Page 51: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

51

Conclusion

Full 128-bit AES key of Stratix II can be extracted using 30,000 traces (3 hours)

Key derivation does not prevent cloning

Proprietary security mechanisms can be reverse-engineered from software

Software reverse-engineering enables hardware attack

Page 52: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

52

Page 53: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

53

Page 54: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

54

SAC

2013

Page 55: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

55

Case Studies

Locking system

Yubikey 2

Altera Stratix II

Page 56: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

56

Page 57: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

57

Token Door lock

Auth. protocol

Black-box

Page 58: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

58

Turning a Black-box into a White-box

Door lock

Token

Page 59: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

59

Decapping an IC (1)

White Fuming Nitric Acid (99.5%)

Page 60: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

60

Decapping an IC (2)

Page 61: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

61

Decapping an IC (3)

Page 62: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

62

Decapping an IC (4)

Page 63: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

63

ASIC

Gate Array

2µm technology

28 pads, 14 bonded

Mixed-signal

~1700/2300 transistors utilized

Page 64: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

64

ASIC – Logic Description

Page 65: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

65

Turning a Black-box into a White-box

Door lock

Token

Page 66: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

66

Microscopic View (1)

FLASH

RAM

EEP

RO

M

analog

FUSE

S

Page 67: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

67

UV-C: Disable Read-Out Protection (1)

Page 68: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

68

UV-C: Disable Read-Out Protection (2)

Page 69: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

69

Extraction + Analysis of Embedded Code

After read-out protection disabled: code readable with standard programmer

Reverse-engineering (e.g. IDA Pro)

After some time: all details of system known

Black-box → white-box

Page 70: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

70

System Design: Weaknesses and Attacks (1)

Each token has unique key KT

Each lock has installation-wide key KM

KT = f(KM, IDT) → single point of failure

Obtaining one lock gives access to all doors: Read-out PIC (as explained before) or perform non-invasive side-channel attack

Page 71: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

71

System Design: Weaknesses and Attacks (2)

Problem 1: System uses proprietary cryptography with „bad“ mathematical properties

Problem 2: Re-use of internal values as „random“ numbers

Result: Mathematical attack allows to recover KT with 3 (unsuccessful) protocol runs with any door

Page 72: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

72

Conclusion

Adversary gains full access to any door

Reasons for security flaws

– Insecure hardware

– Proprietary cryptography

– „Bad“ system design

Hardware attacks: Replace all devices (expensive)

Cryptanalytical attacks: Firmware update (cheap)

Hardware reverse-engineering enables mathematical attacks

Page 73: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

73

Page 74: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

74

Page 75: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

75

RAID

2013

Page 76: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

76

Page 77: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

77

Case Studies

Locking system

Yubikey 2

Altera Stratix II

Page 78: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

78

Two-Factor Authentication

Past: One factor: Password/PIN

Today: Two factors: Password/PIN and additionally

Page 79: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

79

Yubikey 2: Overview

Simulates USB keyboard

Generates and enters One-Time Password (OTP) on button press

Based on AES w/ 128-bit key

Page 80: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

80

Yubikey OTP Generation (1)

...

dhbgnhfhjcrl rgukndgttlehvhetuunugglkfetdegjd

dhbgnhfhjcrl trjddibkbugfhnevdebrddvhhhlluhgh

dhbgnhfhjcrl judbdifkcchgjkitgvgvvbinebdigdfd

...

Page 81: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

81

Yubikey OTP Generation (2)

AES-128 Encryption

Modhex Encoding

?

Page 82: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

82

Yubikey Hardware

Page 83: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

83

Measurement Setup

Resistor in USB ground for power measurement

EM measurement with near-field probe

Connecting (capacitive) button to ground triggers the Yubikey

Page 84: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

84

Power vs. EM Measurements

Trigger on falling edge (Yubikey's LED off)

EM yields better signal

AES rounds clearly visible

1 2 3 4 5 6 7 8 9 10

Page 85: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

85

Key Recovery (EM)

Attacking final AES round

Power model hi = HW(SBOX-1(Ci rk))

~ 700 traces needed

~ 1 hour for data acquisition

Byte 1 Byte 2 Byte 8 Byte 9

Page 86: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

86

Implications

128-bit AES key of the Yubikey 2 can be recovered (700 EM measurements = 1 hour physical access)

Attacker can compute OTPs w/o Yubikey

Impersonate user: Username and password still needed

Denial-of-Service: Send an OTP with highly increased useCtr

→ Improved FW version 2.4 for Yubikey 2

Page 87: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Responsible Disclosure When pirates do good ...

Page 88: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

88

Page 89: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

89 By RedAndr, Wikimedia Commons

Page 90: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

90

Responsible Disclosure

Locking system:

– Vendor informed ~ 1 year before

– Deployed patch to fix mathematical attacks

Altera:

– Informed ~ 6 months before

– Acknowledged our results

Yubikey:

– Informed ~ 9 months before

– Improved firmware version 2.4

Page 91: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Countermeasures

Page 92: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

92

Countermeasures

Implementation attacks: Practical threat, but:

First line of defense: Classical countermeasures

– Secure hardware (certified devices)

– Algorithmic level

Second line of defense: System level

–Detect: Shadow accounts, logging

–Minimize impact (where possible): Key diversification

Page 93: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

93

Different Scenarios, different threats

Yubikey 2

Time per key: 1 h

Diversified keys (?)

Each token: new attack

→ Attack does not scale

Locking system

Time per key: 15 min

All doors: same key

Attack one door

→ Attack scales

Page 94: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

94

Page 95: Extracting keys from FPGAs, OTP Tokens and Door Locks - CCC

Thanks for your attention

Questions now?

or later: [email protected]

If you wondered about my shirt: http://fb.com/WorldBeatClubTanzenUndHelfen