elliptic curve cryptography for those who are afraid of maths

100
Ellipc Curve Cryptography for those who are afraid of math(s) Marjn Grooten, Virus Bullen @marjn_grooten BSides San Francisco, 29 February 2016

Upload: martijn-grooten

Post on 09-Jan-2017

773 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Elliptic Curve Cryptography for those who are afraid of maths

Elliptic Curve Cryptographyfor those who are afraid of math(s)

Martijn Grooten, Virus Bulletin@martijn_grooten

BSides San Francisco, 29 February 2016

Page 2: Elliptic Curve Cryptography for those who are afraid of maths
Page 3: Elliptic Curve Cryptography for those who are afraid of maths

Disclaimer:

This talk will be useless.

Page 4: Elliptic Curve Cryptography for those who are afraid of maths

Disclaimer:

This talk will be useless.

I am not a cryptographer.

Page 5: Elliptic Curve Cryptography for those who are afraid of maths

Disclaimer:

This talk will be useless.

I am not a cryptographer.

Some things are wrong.

Page 6: Elliptic Curve Cryptography for those who are afraid of maths

Elliptic curves

y2 = x3 + a·x + b

Page 7: Elliptic Curve Cryptography for those who are afraid of maths

Elliptic curves

y2 = x3 + a·x + b

…and a prime number p.

Page 8: Elliptic Curve Cryptography for those who are afraid of maths

Elliptic curves

y2 = x3 + a·x + b

…and a prime number p.

choice!

Page 9: Elliptic Curve Cryptography for those who are afraid of maths
Page 10: Elliptic Curve Cryptography for those who are afraid of maths

points

Page 11: Elliptic Curve Cryptography for those who are afraid of maths

points≈numbers

Page 12: Elliptic Curve Cryptography for those who are afraid of maths

P Q

Page 13: Elliptic Curve Cryptography for those who are afraid of maths

P Q

Page 14: Elliptic Curve Cryptography for those who are afraid of maths

P Q

Page 15: Elliptic Curve Cryptography for those who are afraid of maths

P Q

P+Q

Page 16: Elliptic Curve Cryptography for those who are afraid of maths

P Q

P+Q

“point addition”

Page 17: Elliptic Curve Cryptography for those who are afraid of maths

P

Page 18: Elliptic Curve Cryptography for those who are afraid of maths

P

Page 19: Elliptic Curve Cryptography for those who are afraid of maths

P

Page 20: Elliptic Curve Cryptography for those who are afraid of maths

P

P+P

Page 21: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

Page 22: Elliptic Curve Cryptography for those who are afraid of maths

P

“point doubling”2·P

Page 23: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

Page 24: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

Page 25: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

2·P+P

Page 26: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

3·P

Page 27: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

3·P4·P

Page 28: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

3·P4·P

5·P

Page 29: Elliptic Curve Cryptography for those who are afraid of maths

P

2·P

3·P

“(integer) multiplication”6·P

4·P

5·P

Page 30: Elliptic Curve Cryptography for those who are afraid of maths

So:

Page 31: Elliptic Curve Cryptography for those who are afraid of maths

So:We can “add” points to each other.

Page 32: Elliptic Curve Cryptography for those who are afraid of maths

So:We can “add” points to each other.

We can “multiply” points by an integer.

Page 33: Elliptic Curve Cryptography for those who are afraid of maths

So:We can “add” points to each other.

We can “multiply” points by an integer.P + Q = Q + P3·P + P = 2·P + 2·P = 4·P5·(7·P) = 7·(5·P)etc.

Page 34: Elliptic Curve Cryptography for those who are afraid of maths

So:We can “add” points to each other.

We can “multiply” points by an integer.P + Q = Q + P3·P + P = 2·P + 2·P = 4·P5·(7·P) = 7·(5·P)etc.

The points on a curve form an Abelian Group (very exciting!).

Page 35: Elliptic Curve Cryptography for those who are afraid of maths

From P to 100·P in eight steps

Page 36: Elliptic Curve Cryptography for those who are afraid of maths

From P to 100·P in eight steps

To go from a point P to 100·P :

Page 37: Elliptic Curve Cryptography for those who are afraid of maths

From P to 100·P in eight steps

To go from a point P to 100·P :P → 2·P 2·P → 3·P 3·P → 6·P 6·P → 12·P

12·P → 24·P 24·P → 25·P 25·P → 50·P 50·P → 100·P

Page 38: Elliptic Curve Cryptography for those who are afraid of maths

“Division” is very slow

Page 39: Elliptic Curve Cryptography for those who are afraid of maths

“Division” is very slow

Given points P and Q, where Q=n·P, the best way to find the number n is to try P, 2·P, 3·P, etc. That is very slow.

Page 40: Elliptic Curve Cryptography for those who are afraid of maths

“Division” is very slow

Given points P and Q, where Q=n·P, the best way to find the number n is to try P, 2·P, 3·P, etc. That is very slow.

The Discrete Logarithm Problem for elliptic curves.

Page 41: Elliptic Curve Cryptography for those who are afraid of maths

ECDH (Elliptic Curve Diffie-Hellman)

Page 42: Elliptic Curve Cryptography for those who are afraid of maths

ECDH (Elliptic Curve Diffie-Hellman)

The challenge: Alice and Bob want to “agree” on a secret key over a public channel.

Page 43: Elliptic Curve Cryptography for those who are afraid of maths

ECDH (Elliptic Curve Diffie-Hellman)

The challenge: Alice and Bob want to “agree” on a secret key over a public channel.

For example: Alice is a web browser, Bob a web server and they want to exchange a key to encrypt a TLS session.

Page 44: Elliptic Curve Cryptography for those who are afraid of maths

ECDH (Elliptic Curve Diffie-Hellman)

Page 45: Elliptic Curve Cryptography for those who are afraid of maths

Alice and Bob have agreed (publicly!) on an elliptic curve and a point P on the curve.

ECDH (Elliptic Curve Diffie-Hellman)

Page 46: Elliptic Curve Cryptography for those who are afraid of maths

Alice and Bob have agreed (publicly!) on an elliptic curve and a point P on the curve.

Alice chooses secret large random number a.

ECDH (Elliptic Curve Diffie-Hellman)

Page 47: Elliptic Curve Cryptography for those who are afraid of maths

Alice and Bob have agreed (publicly!) on an elliptic curve and a point P on the curve.

Alice chooses secret large random number a.Bob chooses secret large random number b.

ECDH (Elliptic Curve Diffie-Hellman)

Page 48: Elliptic Curve Cryptography for those who are afraid of maths

ECDH (Elliptic Curve Diffie-Hellman)

Page 49: Elliptic Curve Cryptography for those who are afraid of maths

Alice computes a·P (a times the point P) and shares the answer with Bob.

ECDH (Elliptic Curve Diffie-Hellman)

Page 50: Elliptic Curve Cryptography for those who are afraid of maths

Alice computes a·P (a times the point P) and shares the answer with Bob.Bob computes b·P and shares this too.

ECDH (Elliptic Curve Diffie-Hellman)

Page 51: Elliptic Curve Cryptography for those who are afraid of maths

Alice computes a·P (a times the point P) and shares the answer with Bob.Bob computes b·P and shares this too.

Alice computes a·(b·P) (a times the point Bob gave her).

ECDH (Elliptic Curve Diffie-Hellman)

Page 52: Elliptic Curve Cryptography for those who are afraid of maths

Alice computes a·P (a times the point P) and shares the answer with Bob.Bob computes b·P and shares this too.

Alice computes a·(b·P) (a times the point Bob gave her).Bob computes b·(a·P).

ECDH (Elliptic Curve Diffie-Hellman)

Page 53: Elliptic Curve Cryptography for those who are afraid of maths

Alice computes a·P (a times the point P) and shares the answer with Bob.Bob computes b·P and shares this too.

Alice computes a·(b·P) (a times the point Bob gave her).Bob computes b·(a·P). Secret key: a·(b·P) = b·(a·P)

ECDH (Elliptic Curve Diffie-Hellman)

Page 54: Elliptic Curve Cryptography for those who are afraid of maths

Homework: find ECDH in Wireshark

Page 55: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators

Page 56: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators

True randomness

Page 57: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators

True randomness

Page 58: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators

True randomness

Page 59: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators

True randomness

output

Page 60: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators

True randomness

output

Page 61: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Discrete Logarithm Problem:n → n·P

gives “random” points/numbers.

Page 62: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Discrete Logarithm Problem:n → n·P

gives “random” points/numbers.

n0

Page 63: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Discrete Logarithm Problem:n → n·P

gives “random” points/numbers.

n0 n1

n0·P

Page 64: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Discrete Logarithm Problem:n → n·P

gives “random” points/numbers.

n0 n1 n2

n0·P n1·P

Page 65: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Discrete Logarithm Problem:n → n·P

gives “random” points/numbers.

n0 n1 n2

n0·P n1·P n2·P

Page 66: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Discrete Logarithm Problem:n → n·P

gives “random” points/numbers.

n0 n1 n2

n0·P n1·P n2·P

n1 n2

Page 67: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Discrete Logarithm Problem:n → n·P

gives “random” points/numbers.

n0 n1 n2

n0·P n1·P n2·P

n1 n2

n1·P

Page 68: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Given: elliptic curve with two points P and Q.

Page 69: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0

Given: elliptic curve with two points P and Q.

32-byte seed

Page 70: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1

Given: elliptic curve with two points P and Q.

n0·P

32-byte seed

Page 71: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1

Given: elliptic curve with two points P and Q.

n0·P

n1·Q32-byte seed

30 bytes

Page 72: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Given: elliptic curve with two points P and Q.

n0·P n1·P

n1·Q32-byte seed

30 bytes

Page 73: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Given: elliptic curve with two points P and Q.

n0·P n1·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

Page 74: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Given: elliptic curve with two points P and Q.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

Page 75: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Given: elliptic curve with two points P and Q.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

Note: ideas from this slide and the next are borrowed from Bernstein, Heninger and Lange (NCSC ‘14).

Page 76: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

Fact: P=d·Q for some (large) number d.

Page 77: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Fact: P=d·Q for some (large) number d.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

Page 78: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Fact: P=d·Q for some (large) number d.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

216 possibilities

Page 79: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Fact: P=d·Q for some (large) number d.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

216 possibilities r1

Page 80: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Fact: P=d·Q for some (large) number d.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

216 possibilities r1

d·r1

Page 81: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Fact: P=d·Q for some (large) number d.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

216 possibilities r1

d·r1

n2 = n1·P = n1(d·Q)

Page 82: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Fact: P=d·Q for some (large) number d.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

216 possibilities r1

d·r1

n2 = n1·P = n1(d·Q)

= d·(n1·Q)

Page 83: Elliptic Curve Cryptography for those who are afraid of maths

Random number generators using ECC

n0 n1 n2

Fact: P=d·Q for some (large) number d.

n0·P n1·P n2·P

n1·Q n2·Q32-byte seed

30 bytes 30 bytes

216 possibilities r1

d·r1

n2 = n1·P = n1(d·Q)

= d·(n1·Q)

= d·r1

Page 84: Elliptic Curve Cryptography for those who are afraid of maths

So who, if anyone, knows d?

Page 85: Elliptic Curve Cryptography for those who are afraid of maths

So who, if anyone, knows d?

Page 86: Elliptic Curve Cryptography for those who are afraid of maths

So who, if anyone, knows d?

“Dual_EC_DRBG”

Page 87: Elliptic Curve Cryptography for those who are afraid of maths

So who, if anyone, knows d?

“Dual_EC_DRBG”

NB: this RNG is bad for many otherreasons!

Page 88: Elliptic Curve Cryptography for those who are afraid of maths

What happened at Juniper?

Page 89: Elliptic Curve Cryptography for those who are afraid of maths

What happened at Juniper?

Juniper used Dual_EC_DRBG (in ScreenOS) but with different P, Q.

Page 90: Elliptic Curve Cryptography for those who are afraid of maths

What happened at Juniper?

Juniper used Dual_EC_DRBG (in ScreenOS) but with different P, Q.

In theory that is OK, but…

Page 91: Elliptic Curve Cryptography for those who are afraid of maths

What happened at Juniper?

Juniper used Dual_EC_DRBG (in ScreenOS) but with different P, Q.

In practice… Oops.

In theory that is OK, but…

Page 92: Elliptic Curve Cryptography for those who are afraid of maths

Anything else up their sleeve?

Page 93: Elliptic Curve Cryptography for those who are afraid of maths

Anything else up their sleeve?

The widely used curves (P-256 etc.) use “unexplained” constants. We can't exclude that they weren't chosen to create a backdoor.

Page 94: Elliptic Curve Cryptography for those who are afraid of maths

Anything else up their sleeve?

The widely used curves (P-256 etc.) use “unexplained” constants. We can't exclude that they weren't chosen to create a backdoor.

There probably isn't such a backdoor, but we should aim for “nothing up my sleeve” constants (e.g. Curve25519).

Page 95: Elliptic Curve Cryptography for those who are afraid of maths

Suggested reading

"A Riddle Wrapped in an Enigma"by Neal Koblitz and Alfred J. Menezes

http://eprint.iacr.org/2015/1018.pdf

Page 96: Elliptic Curve Cryptography for those who are afraid of maths

ECC: a good idea?

Elliptic curve cryptography is a good idea because we can do with much smaller keys.

Page 97: Elliptic Curve Cryptography for those who are afraid of maths

ECC: a good idea?

Elliptic curve cryptography is a good idea because we can do with much smaller keys.

256-bit ECC ≈ 3072-bit RSA.

Page 98: Elliptic Curve Cryptography for those who are afraid of maths

ECC: a good idea?

Elliptic curve cryptography is a good idea because we can do with much smaller keys.

256-bit ECC ≈ 3072-bit RSA.

Elliptic curve crypto uses complicated maths. That is its biggest weakness.

Page 99: Elliptic Curve Cryptography for those who are afraid of maths

Thank you!

@[email protected]

www.virusbulletin.com

PS “How Broken Is Our Crypto Really?” 3 March, 8:00am, room 2005 @ RSA.

Page 100: Elliptic Curve Cryptography for those who are afraid of maths

Thank you!

@[email protected]

www.virusbulletin.com

PS “How Broken Is Our Crypto Really?” 3 March, 8:00am, room 2005 @ RSA.