Modern Session Encryption

60
Modern Session Encryption David Wong

Transcript of Modern Session Encryption

Page 1: Modern Session Encryption

Modern Session EncryptionDavid Wong

Page 2: Modern Session Encryption

2. STROBE

outline

1. KECCAK

3. NOISE

4. ???

Page 3: Modern Session Encryption

f

⊕ ⊕

f

f f f

squeezing

Sponge Construction

absorbing

0

0

0

0

0

0

0

0

00101 01001 01100 11001 01011 10101

Page 4: Modern Session Encryption

f

input

init

output

duplexing

Duplex Construction

f

input

output

duplexing

f

input output

duplexing

0

0

0

0

0

0

0

0

Page 5: Modern Session Encryption

Keyed-mode

f

key

init duplexing

0

0

0

0

0

0

0

0

Page 6: Modern Session Encryption

f

key

init duplexing

0

0

0

0

0

0

0

0

Encryption?

Page 7: Modern Session Encryption

f

key

init duplexing

0

0

0

0

0

0

0

0

ciphertext1

plaintext1⊕

Encryption

Page 8: Modern Session Encryption

f

key

init duplexing

0

0

0

0

0

0

0

0

ciphertext1

plaintext1⊕

f

tag1

duplexing

Authenticated Encryption

Page 9: Modern Session Encryption

f

key

init duplexing

0

0

0

0

0

0

0

0

ciphertext1

plaintext1⊕

f

tag1

duplexing

f

ciphertext2

duplexing

f

tag2

duplexing

plaintext2⊕

Sessions

Page 10: Modern Session Encryption

0

0

0

0

0

0

0

0

f

key

init duplexing

ciphertext1

plaintext1⊕

f⊕

tag1

duplexing

f

ciphertext2

duplexing

f⊕

tag2

duplexing

plaintext2⊕

f

ciphertext3

duplexing

f⊕

tag3

duplexing

plaintext3⊕

f

ciphertext4

duplexing

f⊕

tag4

duplexing

plaintext4⊕

Page 11: Modern Session Encryption

2. STROBE

outline

1. KECCAK

Page 12: Modern Session Encryption

operation = AD

data = 010100…

ADoperation = KEY

data = 010100…

KEY

f

operation = PRF

⊕00000…

PRF

f

output

operation = send_CLR

data = 010100…

send_CLRoperation = recv_CLR

data = 010100…

recv_CLR

operation = send_ENC

⊕ciphertext

send_ENC

f

plaintext

operation = send_MAC

⊕tag

send_MAC

f

operation = RATCHET

RATCHET

f

0000operation = recv_ENC

plaintext

recv_ENC

f⊕ ciphertext

operation = recv_MAC

recv_MAC

f

0000…

⊕ tag

Strobe functions

Page 13: Modern Session Encryption

myProtocol = Strobe_init(“myWebsite.com”)

myProtocol.AD(sharedSecret)

buffer = myProtocol.send_ENC(“GET /”)

buffer += myProtocol.send_MAC(len=16)

// send the buffer

// receive a ciphertext

message = myProtocol.recv_ENC(ciphertext[:-16])

ok = myProtocol.recv_MAC(ciphertext[-16:])

if !ok {

// reset the connection

}

Strobe protocol example

Page 14: Modern Session Encryption

buffer = myProtocol.send_ENC(plaintext1)

buffer += myProtocol.send_MAC(len=16)

// send the buffer

buffer = myProtocol.send_ENC(plaintext2)

buffer += myProtocol.send_MAC(len=16)

// send the buffer

buffer = myProtocol.send_ENC(plaintext3)

buffer += myProtocol.send_MAC(len=16)

// send the buffer

buffer = myProtocol.send_ENC(plaintext4)

buffer += myProtocol.send_MAC(len=16)

// send the buffer

Page 15: Modern Session Encryption

Strobe

• flexible framework to support a large number of protocols • large symmetric cryptography library

Page 16: Modern Session Encryption

myHash = Strobe_init(“david_wong_hash”)

myHash.AD(“something to be hashed”)

hash = myHash.PRF(outputLen=32)

Strobe as a Hash Function

Page 17: Modern Session Encryption

operation = AD

⊕rate

capacity

Page 18: Modern Session Encryption

operation = AD

data = 010100…

⊕rate

capacity

Page 19: Modern Session Encryption

operation = AD

data = 010100…

operation = send_ENC

⊕rate

capacity

Page 20: Modern Session Encryption

operation = AD

data = 010100…

f

operation = send_ENC

⊕rate

capacity

Page 21: Modern Session Encryption

operation = AD

data = 010100…

f

operation = send_ENC

data = hello

ciphertext

⊕rate

capacity

Page 22: Modern Session Encryption

operation = AD

data = 010100…

f f

operation = send_ENC

data = hello

ciphertextlen = 16

tag

operation = send_MAC

⊕rate

capacity

Page 23: Modern Session Encryption

operation = AD

data = 010100…

f f

operation = send_ENC

data = hello

ciphertextlen = 16

tag

operation = send_MAC

send_AEAD

⊕rate

capacity

Page 24: Modern Session Encryption

Strobe

• flexible framework to support a large number of protocols • large symmetric cryptography library • fits into tiny IoT devices (~300 lines of code) • relies on strong SHA-3 standard (SHAKE-compliant)

Page 25: Modern Session Encryption

strobe.sourceforge.io

strobe.sourceforge.io

Page 26: Modern Session Encryption

2. STROBE

outline

1. KECCAK

3. NOISE

Page 27: Modern Session Encryption

TLS• TLS is the de facto standard for securing communications • complex specification (TLS 1.3 is 160-page long)

• supported by other specifications (asn.1, x509, 44 mentioned RFCs …) • design carrying a lot of legacy decisions • cryptographic agility and complicated state machine • huge and scary libraries (OpenSSL is 700k LOC, 165 CVEs)

• cumbersome configuration… • often dangerously re-implemented (custom implementations)

• or re-invented (proprietary protocols)

Page 28: Modern Session Encryption

Complexity is the enemy of security

Page 29: Modern Session Encryption

www.noiseprotocol.org

Page 30: Modern Session Encryption

The Noise Protocol Framework

• no need for certificates or a PKI • many handshakes to choose from (flexible) • it’s straight forward to implement (<1k LOC, 18kb for Arduino) • there are already libraries that you can leverage • minimal (or zero) configuration • used by WhatsApp, Slack, the Bitcoin Lightning Network, … • if you have a good excuse not to use TLS, Noise is the answer

Page 31: Modern Session Encryption

• DH: X25519 or X448

• AEAD: Chacha20-Poly1305 or AES-GCM

• HASH: BLAKE2 or SHA-2

The crypto functions

Page 32: Modern Session Encryption

ephemeral key

ephemeral key

Client Server

handshake

Page 33: Modern Session Encryption

ephemeral key

ephemeral key

Client Server

handshakeDiffie-Hellman() Diffie-Hellman()

keys keys

Page 34: Modern Session Encryption

ephemeral key

ephemeral key

Client Server

handshake

encrypted data

encrypted data

post-handshake

Diffie-Hellman() Diffie-Hellman()

keys keys

Page 35: Modern Session Encryption

e

e

Client Server

handshake

encrypted data

encrypted data

post-handshake

ee ee

keys keys

Page 36: Modern Session Encryption

→ e ← e, ee

Page 37: Modern Session Encryption

• e: ephemeral key

• s: static key

• ee: DH(client ephemeral key, server ephemeral key)

• es: DH(client ephemeral key, server static key)

• se: DH(client static key, server ephemeral key)

• ss: DH(client static key, server static key)

• psk: pre-shared key

Tokens

Page 38: Modern Session Encryption

→ e ← e, ee

NN():← s … → e, es ← e, ee

NK(rs):→ e ← e, ee, s, es

NX(rs):

→ e ← e, ee → s, se

XN(s):← s → s … → e, es, ss ← e, ee, se

KK(s, rs):→ e ← e, ee, s, es → s, se

XX(s, rs):

← s … → e, es

N(rs):← s → s … → e, es, ss

K(s,rs):← s … → e, es, s, ss

X(s,rs):

← s … → e, es ← e, ee → s, se

XK(s, rs):→ s … → e ← e, ee, se

KN(s):

Handshake Patterns

Page 39: Modern Session Encryption

NX(rs): → e ← e, ee, s, es

Client Server

Page 40: Modern Session Encryption

epublic

Client Server

NX(rs): → e ← e, ee, s, es

Page 41: Modern Session Encryption

payload1

epublic

Client Server

NX(rs): → e ← e, ee, s, es

Page 42: Modern Session Encryption

republic

epublic

Client Server

payload1

NX(rs): → e ← e, ee, s, es

Page 43: Modern Session Encryption

republic

epublic

Client Server

payload1

NX(rs): → e ← e, ee, s, es

Page 44: Modern Session Encryption

republic

EK1(rs)

epublic

Client Server

payload1

NX(rs): → e ← e, ee, s, es

Page 45: Modern Session Encryption

republic

EK1(rs)

epublic

Client Server

payload1

NX(rs): → e ← e, ee, s, es

Page 46: Modern Session Encryption

republic

EK1(rs)

EK2(payload2)

epublic

Client Server

payload1

NX(rs): → e ← e, ee, s, es

Page 47: Modern Session Encryption
Page 48: Modern Session Encryption
Page 49: Modern Session Encryption

HandshakeStateSymmetricStateCipherState

epublic

payload1

republic

Ek1(rspublic)

HKDF

DH(e, re)

ckn=0 k1

e GENERATE_KEYPAIR()

Initializationck h “Noise_NX_25519_AESGCM_SHA256”HASH

h

e.public_keyHASH

re.public_keyHASH

h rs DecryptWithAd() Ek1(rspublic)

h

HASH

h

Ek1(rspublic)

HASH

h

payload1

CipherState

HKDF

k

k

n=0

n=0

CipherStateEk2(payload2)

re republicHKDF

DH(e, rs)

ckn=0 k2

DecryptWithAd() Ek2(payload2)

h

payload2

HASH

h

Ek2(payload2)

Page 50: Modern Session Encryption

2. STROBE

outline

1. KECCAK

3. NOISE

4. DISCO

Page 51: Modern Session Encryption

HandshakeStateStrobeState

epublic

payload1

republic

E(rspublic)

Initialization

E(payload2)

InitStrobe() “Noise_NX_25519_Strobe”

e GENERATE_KEYPAIR()

send_CLR()payload1

send_CLR() e.public_key

re.public_keyrecv_CLR()republic

recv_AEAD()E(payload2) payload2

AD()DH(e, rs)

rs.public_keyrecv_AEAD()E(rspublic)

StrobeState StrobeState……

AD()DH(e, re)

Page 52: Modern Session Encryption

StrobeState

send_AEAD()

send_AEAD()

send_AEAD()

send_AEAD()

send_AEAD()

send_AEAD()

send_AEAD()

StrobeState

recv_AEAD()

recv_AEAD()

recv_AEAD()

recv_AEAD()

recv_AEAD()

recv_AEAD()

recv_AEAD()

Page 53: Modern Session Encryption

HandshakeStateStrobeState

epublic

payload1

republic

E(rspublic), tag1

E(payload2), tag2

e GENERATE_KEYPAIR()Initialization“Noise_NX_25519_Strobe”⊕

e.public_key⊕payload1⊕

DH(e, re)⊕

DH(e, rs)⊕

re.public_key⊕ republic

tag1

rs.public_key

E(rspublic)⊕

rs.public_key

E(payload2)⊕

tag2

Page 54: Modern Session Encryption

www.discocrypto.com

Page 55: Modern Session Encryption

700,000 LOC

disco-c libdisco (go)

OpenSSL

4,000 LOC1,000 LOC

2,000 LOC

DiscoNet* (C#)

* implementation by Artyom Makarov

Page 56: Modern Session Encryption

DISCO

STROBE X25519

KECCAK-F

Trust Graph of Disco

Page 57: Modern Session Encryption

Trust Graph of biased SSL/TLS

TLS 1.3

HMAC X25519

SHA-256

HKDF ECDSAAES-GCM

Page 58: Modern Session Encryption

Trust Graph of SSL/TLS

TLS 1.3

HMAC

SHA-256SHA-384SHA-512

HKDF ECDSAAES-GCM

DH

ECDH

CHACHA20-POLY1305

TLS 1.2TLS 1.1

X.509

ASN.1

DER

secp256r1

secp384r1

secp521r1

ffdhe2048

X25519

X448

ffdhe3072

ffdhe4096

ffdhe6144

ffdhe8192

RSA-PSS orRSA-PKCS#1

v1.5

AES-CCM

ed25519

ed448

Page 59: Modern Session Encryption

• Disco is a draft specification extending Noise (experimental) • Noise is a stable draft (rev34) • Strobe is alpha (v1.0.2) • ⚠ Disco and the implementations are still experimental

• need more eyes, more interoperability testing, etc. • looking to formally prove handshakes with Tamarin

The state of Disco

Page 60: Modern Session Encryption

the disco is at www.discocrypto.com

I write about crypto www.cryptologie.net

follow me on twitter.com/cryptodavidw (and I work here)