54
Robust, low-cost, auditable random number generation for embedded system security Ben Lampert ?, Riad S. Wahby ? , Shane Leonard ? , and Philip Levis ? ? Stanford University NAUTO, Inc. November 14 th , 2016

Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Robust, low-cost, auditable random numbergeneration for embedded system security

Ben Lampert?, Riad S. Wahby?,Shane Leonard?, and Philip Levis?

?Stanford UniversityNAUTO, Inc.

November 14th, 2016

Page 2: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

All secure systems depend on random numbers

Embedded systems face unique challenges

We present a hardware/software system for randomnumber generation tailored to embedded devices:

hardware costs ≈$1.50, 1.5 cm2 board area

run once at boot, takes 25 ms to initialize

energy cost equivalent to 10 ZigBee packets

Page 3: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present
Page 4: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

All secure systems depend on random numbers

Embedded systems face unique challenges

We present a hardware/software system for randomnumber generation tailored to embedded devices:

hardware costs ≈$1.50, 1.5 cm2 board area

run once at boot, takes 25 ms to initialize

energy cost equivalent to 10 ZigBee packets

Page 5: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

All secure systems depend on random numbers

Embedded systems face unique challenges

We present a hardware/software system for randomnumber generation tailored to embedded devices:

hardware costs ≈$1.50, 1.5 cm2 board area

run once at boot, takes 25 ms to initialize

energy cost equivalent to 10 ZigBee packets

Page 6: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

http://xkcd.com/221/ CC BY-NC 2.5

Page 7: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

http://xkcd.com/221/ CC BY-NC 2.5

Page 8: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

A deterministic “random” number generator?

What properties would it have?

Uniformly distributed.

Not enough.

GNU libc’s rand() output is very nearly uniform

But future outputs are easy to predict given past outputs

. . . and no self correlation.

Still no.π is thought to be normal: it will pass many statistical testsWhat if we used digits of π?But future outputs are easy to predict given knowledge of source

Idea: add a secret!

Page 9: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

A deterministic “random” number generator?

What properties would it have?

Uniformly distributed. Not enough.GNU libc’s rand() output is very nearly uniformBut future outputs are easy to predict given past outputs

. . . and no self correlation.

Still no.π is thought to be normal: it will pass many statistical testsWhat if we used digits of π?But future outputs are easy to predict given knowledge of source

Idea: add a secret!

Page 10: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

A deterministic “random” number generator?

What properties would it have?

Uniformly distributed. Not enough.GNU libc’s rand() output is very nearly uniformBut future outputs are easy to predict given past outputs

. . . and no self correlation.

Still no.

π is thought to be normal: it will pass many statistical testsWhat if we used digits of π?

But future outputs are easy to predict given knowledge of source

Idea: add a secret!

Page 11: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

A deterministic “random” number generator?

What properties would it have?

Uniformly distributed. Not enough.GNU libc’s rand() output is very nearly uniformBut future outputs are easy to predict given past outputs

. . . and no self correlation. Still no.π is thought to be normal: it will pass many statistical testsWhat if we used digits of π?But future outputs are easy to predict given knowledge of source

Idea: add a secret!

Page 12: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

A deterministic “random” number generator?

What properties would it have?

Uniformly distributed. Not enough.GNU libc’s rand() output is very nearly uniformBut future outputs are easy to predict given past outputs

. . . and no self correlation. Still no.π is thought to be normal: it will pass many statistical testsWhat if we used digits of π?But future outputs are easy to predict given knowledge of source

Idea: add a secret!

Page 13: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Cryptographically secure pseudorandom number generator

CSPRNG: a deterministic algorithm that generates“good randomness” given a secret key k

Key property (informal): given past outputs, noefficient algorithm can predict future outputs

Concrete example: using AES, encrypt the sequence0, 1, 2, 3, ... under secret key k⇒ can securely generate > 260 bytes!

Figure of merit: entropyinformally: the number of bits in k that anadversary does not know

Page 14: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Cryptographically secure pseudorandom number generator

CSPRNG: a deterministic algorithm that generates“good randomness” given a secret key k

Key property (informal): given past outputs, noefficient algorithm can predict future outputs

Concrete example: using AES, encrypt the sequence0, 1, 2, 3, ... under secret key k⇒ can securely generate > 260 bytes!

Figure of merit: entropyinformally: the number of bits in k that anadversary does not know

Page 15: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Cryptographically secure pseudorandom number generator

CSPRNG: a deterministic algorithm that generates“good randomness” given a secret key k

Key property (informal): given past outputs, noefficient algorithm can predict future outputs

Concrete example: using AES, encrypt the sequence0, 1, 2, 3, ... under secret key k

⇒ can securely generate > 260 bytes!

Figure of merit: entropyinformally: the number of bits in k that anadversary does not know

Page 16: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Cryptographically secure pseudorandom number generator

CSPRNG: a deterministic algorithm that generates“good randomness” given a secret key k

Key property (informal): given past outputs, noefficient algorithm can predict future outputs

Concrete example: using AES, encrypt the sequence0, 1, 2, 3, ... under secret key k⇒ can securely generate > 260 bytes!

Figure of merit: entropyinformally: the number of bits in k that anadversary does not know

Page 17: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Cryptographically secure pseudorandom number generator

CSPRNG: a deterministic algorithm that generates“good randomness” given a secret key k

Key property (informal): given past outputs, noefficient algorithm can predict future outputs

Concrete example: using AES, encrypt the sequence0, 1, 2, 3, ... under secret key k⇒ can securely generate > 260 bytes!

Figure of merit: entropyinformally: the number of bits in k that anadversary does not know

Page 18: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Why not existing solutions?

Gather entropy from many sourcese.g., hard disk, keyboard, network timing

7 Embedded systems may not have these sources7 Continuous gathering costs energy

RNG built into processor or SoCe.g., RDRAND on Intel processors

7 Embedded processors may not have RNG7 Integrated RNG is opaque, not auditable Becker et al. [CHES ’13] showed that integrated

hardware RNGs can be stealthily backdoored

Page 19: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Why not existing solutions?

Gather entropy from many sourcese.g., hard disk, keyboard, network timing

7 Embedded systems may not have these sources7 Continuous gathering costs energy

RNG built into processor or SoCe.g., RDRAND on Intel processors

7 Embedded processors may not have RNG7 Integrated RNG is opaque, not auditable Becker et al. [CHES ’13] showed that integrated

hardware RNGs can be stealthily backdoored

Page 20: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Why not existing solutions?

Gather entropy from many sourcese.g., hard disk, keyboard, network timing

7 Embedded systems may not have these sources7 Continuous gathering costs energy

RNG built into processor or SoCe.g., RDRAND on Intel processors

7 Embedded processors may not have RNG7 Integrated RNG is opaque, not auditable Becker et al. [CHES ’13] showed that integrated

hardware RNGs can be stealthily backdoored

Page 21: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Why not existing solutions?

Gather entropy from many sourcese.g., hard disk, keyboard, network timing

7 Embedded systems may not have these sources7 Continuous gathering costs energy

RNG built into processor or SoCe.g., RDRAND on Intel processors

7 Embedded processors may not have RNG

7 Integrated RNG is opaque, not auditable Becker et al. [CHES ’13] showed that integrated

hardware RNGs can be stealthily backdoored

Page 22: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Why not existing solutions?

Gather entropy from many sourcese.g., hard disk, keyboard, network timing

7 Embedded systems may not have these sources7 Continuous gathering costs energy

RNG built into processor or SoCe.g., RDRAND on Intel processors

7 Embedded processors may not have RNG7 Integrated RNG is opaque, not auditable Becker et al. [CHES ’13] showed that integrated

hardware RNGs can be stealthily backdoored

Page 23: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Wish list

Inexpensive

Small

Low power

Insensitive to environmental factors(e.g., temperature, RF interference)

Easy to detect failure: simple and auditable

Generates a CSPRNG key quickly

Page 24: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Generating unpredictable bits: two easy pieces

noisesource

conversioncircuit

unpredictablebits

Noise source: a device exhibitingan unpredictable physical phenomenon

Conversion circuit: detects state of device,produces corresponding bits

Page 25: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Generating unpredictable bits: two easy pieces

noisesource

conversioncircuit

unpredictablebits

Example noise sources:

7

Radioactive decay

7

Beam splitting

7

Photoelectric effect

3

Circuit noise

7

thermal noise (all electronic devices)

7

shot noise, flicker noise (diodes and transistors)

3

Zener noise, avalanche noise (diodes)

Page 26: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Generating unpredictable bits: two easy pieces

noisesource

conversioncircuit

unpredictablebits

Example noise sources:

7 Radioactive decay

7 Beam splitting

7 Photoelectric effect

3

Circuit noise

7

thermal noise (all electronic devices)

7

shot noise, flicker noise (diodes and transistors)

3

Zener noise, avalanche noise (diodes)

Page 27: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Generating unpredictable bits: two easy pieces

noisesource

conversioncircuit

unpredictablebits

Example noise sources:

7 Radioactive decay

7 Beam splitting

7 Photoelectric effect

3

Circuit noise

7 thermal noise (all electronic devices)

7

shot noise, flicker noise (diodes and transistors)

3

Zener noise, avalanche noise (diodes)

Page 28: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Generating unpredictable bits: two easy pieces

noisesource

conversioncircuit

unpredictablebits

Example noise sources:

7 Radioactive decay

7 Beam splitting

7 Photoelectric effect

3

Circuit noise

7 thermal noise (all electronic devices)7 shot noise, flicker noise (diodes and transistors)

3

Zener noise, avalanche noise (diodes)

Page 29: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Generating unpredictable bits: two easy pieces

noisesource

conversioncircuit

unpredictablebits

Example noise sources:

7 Radioactive decay

7 Beam splitting

7 Photoelectric effect

3 Circuit noise

7 thermal noise (all electronic devices)7 shot noise, flicker noise (diodes and transistors)3 Zener noise, avalanche noise (diodes)

Page 30: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Generating unpredictable bits: two easy pieces

noisesource

conversioncircuit

unpredictablebits

Example noise sources:

7 Radioactive decay

7 Beam splitting

7 Photoelectric effect

3 Circuit noise

7 thermal noise (all electronic devices)7 shot noise, flicker noise (diodes and transistors)3 Zener noise, avalanche noise (diodes)

Page 31: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Diodes, reverse breakdown, and avalanche

Voltage applied in forward direction:current can flow

+ –

i > 0

Low voltage applied in reversedirection: current cannot flow

– +

i = 0

High voltage applied in reversedirection: breakdown, current flow

– +

i > 0

Avalanche current:electron collisions cause an “avalanche” of charge carriers

Page 32: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Diodes, reverse breakdown, and avalanche

Voltage applied in forward direction:current can flow

+ –

i > 0

Low voltage applied in reversedirection: current cannot flow

– +

i = 0

High voltage applied in reversedirection: breakdown, current flow

– +

i > 0

Avalanche current:electron collisions cause an “avalanche” of charge carriers

Page 33: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Diodes, reverse breakdown, and avalanche

Voltage applied in forward direction:current can flow

+ –

i > 0

Low voltage applied in reversedirection: current cannot flow

– +

i = 0

High voltage applied in reversedirection: breakdown, current flow

– +

i > 0

Avalanche current:electron collisions cause an “avalanche” of charge carriers

Page 34: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Avalanche current

R110 kΩ

Vnoise

12.16 V

0 0.5 1 1.5 2 2.5 30.08

0.1

0.12

0.14

0.16

0.18

0.2

0.22

0.24

Vno

ise, v

olts

time, µs

−0.12 −0.1 −0.08 −0.06 −0.04 −0.02 0 0.02 0.04 0.06 0.08

1

2

3

4

5

6

7

8

9

Vnoise

deviation from 160 mV, volts

freq

uenc

y, p

erce

nt o

f sam

ples

Page 35: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Overcoming manufacturing variations

+Vref

R110 kΩ

Vnoise

+ output bits

Page 36: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Converting Vnoise to bits

+Vref

R110 kΩ

Vnoise

+ output bits

Page 37: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Issue: outside disturbances

+Vref

R110 kΩ

idistVnoise

+ output bits

Page 38: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Overcoming disturbances using a differential circuit

Vref−

+

idist

R110 kΩ

D1Vnoise,1

+

idist

R210 kΩ

D2

Vnoise,2

+ output bits

Page 39: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Overcoming disturbances using a differential circuit

Vref−

+

idistR1

10 kΩ

D1Vnoise,1

+

idistR2

10 kΩ

D2

Vnoise,2

+ output bits

Page 40: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Issue: how do we generate 12 V?

M1

L110 µH

3.3 V

Cout

10 µF

D1 Vboost > 3.3 V

Controlleren

Issue: the boost converter causes large disturbances

Solution: interleave boost and output sampling

Page 41: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Issue: how do we generate 12 V?

M1

L110 µH

3.3 V

Cout

10 µF

D1 Vboost > 3.3 V

Controlleren

Issue: the boost converter causes large disturbances

Solution: interleave boost and output sampling

Page 42: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Issue: how do we generate 12 V?

M1

L110 µH

3.3 V

Cout

10 µF

D1 Vboost > 3.3 V

Controlleren

Issue: the boost converter causes large disturbances

Solution: interleave boost and output sampling

Page 43: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Interleaved boost operation

Vboost

iboost

comparator output

Page 44: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Putting it all together

At boot:

1. run circuit to gather 1024 bits, braw2. compute k = SHA256 (braw)3. initialize global counter c = 0

To generate a random number:

1. increment counter c2. use AES to encrypt c under key k3. return resulting ciphertext

Page 45: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Putting it all together

At boot:

1. run circuit to gather 1024 bits, braw2. compute k = SHA256 (braw)3. initialize global counter c = 0

To generate a random number:

1. increment counter c2. use AES to encrypt c under key k3. return resulting ciphertext

Page 46: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Testing and monitoring

In the paper, we define methods for:

Acceptance testing:after assembly and before deployment, eachdevice should be checked for proper operation

Online auditing:for systems requiring high assurance, furtheronline testing in the field

Page 47: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Evaluation questions

How quickly should the system samplethe bit generator’s output?

What are the statistical properties of the rawoutput versus time and temperature?

What is the cost, in energy and time, ofgenerating a CSPRNG key?

Page 48: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Built systems

Cost ≈ $1.50

Page 49: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Determining the sample rate

Sampling Frequency (Hz)103 104 105 106 107 108

Ser

ial C

orre

latio

n

-0.2

-0.1

0

0.1

0.2

0.3

0.4

0.5

0.6Serial Correlation vs Sampling Frequency

Page 50: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Statistical properties versus temperature

−20 −10 0 10 20 30 40 50 600.985

0.99

0.995

1

Temperature (°C)

Ent

ropy

(clo

ser

to 1

is b

ette

r)

Entropy vs. Temperature

−20 −10 0 10 20 30 40 50 60−0.02

−0.01

0

0.01

0.02

Temperature (°C)

Ser

ial C

orre

latio

n(c

lose

r to

0 is

bet

ter)

Serial Correlation vs. Temperature

Page 51: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Statistical properties versus time

0 1 2 3 4 5 6 7 8 9 100.985

0.99

0.995

1E

ntro

py(c

lose

r to

1 is

bet

ter)

Long Term Entropy

days

0 1 2 3 4 5 6 7 8 9 10−0.02

−0.01

0

0.01

0.02

Ser

ial C

orre

latio

n(c

lose

r to

0 is

bet

ter)

Long Term Serial Correlation

days

Page 52: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Time and energy costs to generate CSPRNG key

Time to gather 1024 bits:≈13 ms running dc/dc converter≈12 ms sampling output of bit generator

Energy to gather 1024 bits:≈3 µJ per bit≈ 10× more energy per bit than a ZigBee radio,amortized over all CSPRNG outputs

Page 53: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

Conclusions

You should worry about your random numbers!

A CSPRNG can generate secure, effectivelylimitless output given a hard-to-guess key. . .

. . . but in embedded systems, generatinga CSPRNG key is challenging

We have presented a design tailored to embeddedsystems for secure, inexpensive pseudorandomness

Future work: smaller, cheaper, faster

https://github.com/helena-project/imix

Page 54: Robust, low-cost, auditable random number generation for embedded … · 2017-08-31 · All secure systems depend on random numbers Embedded systems face unique challenges We present

R110 kΩ

D1

Vhigh

Vref

Cf

0.47 µF

Op-amp 1

+

Vhigh

R210 kΩ

D2Vnoise,1

Op-amp 2

+

Vhigh

R310 kΩ

D3

Vnoise,2

Comparator

+3.3 V

Vout

Boost converter

VinVout

3.3 VVhigh

en enable