differential cryptanalysis with sat solvers - lukas prokop · lukas prokop 22th of sept 2016 slide...

74

Upload: others

Post on 22-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 1

MegoSAT projectDifferential cryptanalysis

with SAT solversToday: “master thesis presentation”

Lukas ProkopAdvisors: Florian Mendel, Maria Eichlseder

Institute of Applied Information Processing and Communications

Page 2: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 2

Goal

• Find hash collisions . . .

• for MD4 and SHA-256 . . .

• using SAT solvers

Page 3: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 3

Outline• Differential cryptanalysis

• SHA-256 and MD4

• Satisfiability

• SAT features

• Example hash collision (Wang et al.)

• MD4 testcases & results

• SHA-256 testcases & results

Page 4: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 4

Differential cryptanalysis

Page 5: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 5

Differential cryptanalysis

We use two slightlydifferent inputmessages

Page 6: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 6

Differential cryptanalysis

We apply thecryptographicalgorithm to bothinstances

Page 7: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 7

Differential cryptanalysis

Differences cancel out

Page 8: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 8

Differential cryptanalysis

Equality is given

Page 9: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 9

Differential cryptanalysis

A hash collision is apair (x1, x2) such that

x1 , x2 withf (x1) = f (x2).

Page 10: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 10

Differential cryptanalysis

Differentialcryptanalysis focuses

on the behavior ofdifferences when f is

progressing.

A hash collision is apair (x1, x2) such that

x1 , x2 withf (x1) = f (x2).

Equality is given

Differences cancel out

We use two slightlydifferent inputmessages

We apply thecryptographicalgorithm to bothinstances

Page 11: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 11

Differential cryptanalysisWang et al. defined signed differences.De Canniere and Rechberger [01] definedgeneralized bit conditions.

(xi, x∗i ) (0, 0) (1, 0) (0, 1) (1, 1)? 3 3 3 3- 3 3x 3 30 3u 3n 31 3#

(xi, x∗i ) (0, 0) (1, 0) (0, 1) (1, 1)3 3 35 3 37 3 3 3A 3 3B 3 3 3C 3 3D 3 3 3E 3 3 3

Page 12: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 12

Differential cryptanalysis

A: 0100B: 1x-1S: ??-1

addition A + B = S

Page 13: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 13

Differential cryptanalysis0100

1101

0001

0100

1001

1101

A: 0100

B: 1001

S: 1101

A: 0100

B: 1101

S: 0001

0100

1011

1111

0100

1111

0011

0100

1001

1111

0100

1101

1011

A: 0100B: 1x-1S: ??-1

. . .

. . .

addition A + B = S

Page 14: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 14

Differential cryptanalysis0100

1101

0001

0100

1001

1101

A: 0100

B: 1001

S: 1101

A: 0100

B: 1101

S: 0001

0100

1011

1111

0100

1111

0011

0100

1001

1111

0100

1101

1011

A: 0100B: 1x-1S: ??-1

. . .

. . .

addition A + B = S

Page 15: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 15

Differential cryptanalysis0100

1101

0001

0100

1001

1101

A: 0100

B: 1001

S: 1101

A: 0100

B: 1101

S: 0001

0100

1011

1111

0100

1111

0011

0100

1001

1111

0100

1101

1011

A: 0100B: 1x-1S: ?x-1

. . .

. . .⇐

addition A + B = S

Page 16: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 16

Differential cryptanalysis

A: 0011B: 0101S: 1000

A: ---xB: ---xS: ????

A: ---xB: ---xS: ???-

A: ---xB: ---xS: x???

Valid 4-bit addition differential characteristics:

A: 0011B: 0101S: 0000

A: ---xB: ---xS: ???x

A: ----B: ---xS: x-??

Invalid 4-bit addition differential characteristics:

0100

1101

0001

0100

1001

1101

A: 0100

B: 1001

S: 1101

A: 0100

B: 1101

S: 0001

0100

1011

1111

0100

1111

0011

0100

1001

1111

0100

1101

1011

A: 0100B: 1x-1S: ?x-1

. . .

. . .

addition A + B = S

Page 17: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 17

Differential cryptanalysis

• bit conditions (differential characteristic).

• the operation applied.

We have constraints due to

Page 18: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 18

Our f is MD4 or SHA-256

MD4:• Ronald Rivest, 1990

• RFC 1320

• broken since 1995

• 128 bits internal state size

Page 19: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 19

Our f is MD4 or SHA-256

SHA-256:• NSA, 2001

• NIST publication 180-4

• best practical pseudo-collision attack breaks38 rounds [02]

• 256 bits internal state size

Page 20: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 20

Our f is MD4 or SHA-256

Merkle-Damgård constructions:

IV

M1 M2

post hashvalue

MD4: 48 stepsSHA-256: 64 steps

update . . .update

Page 21: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 21

Our f is MD4 or SHA-256

MD4 update function

Page 22: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 22

Our f is MD4 or SHA-256

SHA-256 update function

Page 23: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 23

And nowfor something completely different

Page 24: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 24

Satisfiability• A Boolean function is a mapping h : X→ Y

with X = {0, 1}n for n ∈N≥1 and Y = {0, 1}.

• AND maps X = {0, 1}2 to 1 iff X = (1, 1).

x1 x2 f (x1, x2)1 1 11 0 00 1 00 0 0

x1 x2 f (x1, x2)1 1 11 0 00 1 00 0 0

Page 25: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 25

Satisfiability

A Boolean function f is satisfiable iff there existssome assignment m such that f (m) = 1.

f (x1, x2) = (x1 ∨ ¬x2) ∧ (¬x1)

A SAT solver is a tool to evaluate whether acertain Boolean function is satisfiable or not.

f is satisfiable because m = (0, 0) evaluates to 1.

Page 26: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 26

Satisfiabilityf (x1, x2) =(x1 ∨ ¬x2)∧(¬x1)

c Lingeling SAT Solver

c

s SATISFIABLE

v -1 -2 0

c

c 0 decisions, 0.0 decisions/sec

c 0 conflicts, 0.0 conflicts/sec

c 2 propagations, 0.0 megaprops/sec

c 0.0 seconds, 0.0 MB

p cnf 2 2

1 -2 0

-1 0

m = (0, 0)

Page 27: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 27

Satisfiability

Our strategy: We write a boolean equationsystem such that the formula is satisfiable iffall constraints of bit conditions and theoperation can be satisfied.

Page 28: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 28

Satisfiability

What is an average problemsolved by a SAT solver?

Page 29: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 29

Satisfiability

What is an average problemsolved by a SAT solver?

Approach: Get a large data set andcompute the mean.

www.satcompetition.org

Page 30: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 30

Satisfiability

SATlib 53,225 CNF files, 26 GB

Page 31: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 31

Satisfiability

nope, too small

SATlib

SAT competition 2016

53,225 CNF files, 26 GB

5,849 CNF files, 38 GB

Page 32: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 32

Satisfiability

nope, too small

SATlib

SAT competition 2016

53,225 CNF files, 26 GB

5,849 CNF files, 38 GB

SAT competition 2008–2016 + SATlib

Page 33: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 33

Satisfiability

nope, too small

SATlib

SAT competition 2016

53,225 CNF files, 26 GB

5,849 CNF files, 38 GB

SAT competition 2008–2016 + SATlib

68,069 CNF files, 188 GB

⇒ https://github.com/prokls/cnf-files-download

⇒ https://github.com/prokls/cnf-analysis-pyhttps://github.com/prokls/cnf-analysis-gohttps://github.com/prokls/cnf-analysis-tests

Page 34: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 34

Satisfiability

Normalization problem:

p cnf 2 2

1 -2 0

-1 0

c this file was submitted by ...

c for SAT race ...

p cnf 2 2

1 -2 0

-1 0

%

0

Page 35: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 35

Satisfiability

Normalization problem:

p cnf 2 2

1 -2 0

-1 0

c this file was submitted by ...

c for SAT race ...

p cnf 2 2

1 -2 0

-1 0

%

0

=

⇒ hash algorithm on normalized input⇒ https://github.com/prokls/cnf-hash-py

https://github.com/prokls/cnf-hash-gohttps://github.com/prokls/cnf-hash-tests2

Page 36: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 36

Satisfiability

Normalization problem:

p cnf 2 2

1 -2 0

-1 0

c this file was submitted by ...

c for SAT race ...

p cnf 2 2

1 -2 0

-1 0

%

0

=

⇒ hash algorithm on normalized input⇒ https://github.com/prokls/cnf-hash-py

https://github.com/prokls/cnf-hash-gohttps://github.com/prokls/cnf-hash-tests2

⇒ 62251 uniqueCNF files, 160 GB

Page 37: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 37

SAT features

nbvars No. of variables acc. to CNF header

true trivialis the CNF satisfied if all variables are set totrue?

connected variable components countnumber of components where variables arein the same component if they occur in aclause together

Page 38: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 38

SAT features

Page 39: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 39

SAT features

Results:• There is no distinctive property of our

testcases.

• But data indicates that values are stronglyintermingled (high diffusion)

• Problem size (number of clauses &variables) is rather large; no indicator ofhardness of problem

Page 40: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 40

Example hash collision

Recall . . .• how bit conditions

propagated

• how MD4 andSHA-256 worked

Page 41: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 41

Example hash collision

Wang, Lai, Feng, Chen, Yu

“Cryptanalysis of the HashFunctions MD4 andRIPEMD”

EUROCRYPT 2005

Page 42: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 42

Example hash collision

Page 43: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 43

Example hash collision

inputmessage

Page 44: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 44

Example hash collision

initial vectorsinput

message

Page 45: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 45

Example hash collision

initial vectors

output words

inputmessage

Page 46: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 46

Example hash collision

initial vectors

output words

intermediatevalues

inputmessage

Page 47: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 47

Example hash collision

underspecified

Page 48: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 48

Attack!

Attacking MD4 & SHA-256

Page 49: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 49

MD4 testcases & resultsTestcase A [03]All differences set. Justdetermine actual bits inboth instances.

Page 50: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 50

MD4 testcases & resultsTestcase A [03]All differences set. Justdetermine actual bits inboth instances.

solver version runtimeMiniSat 2.2.0 3CryptoMiniSat 4.5.3 26

5 29Lingeling ats1 23Plingeling ats1 88Treengeling ats1 64Glucose 4.0 8Glucose Syrup 4.0 14

always seconds

Page 51: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 51

MD4 testcases & results

Interesting fact:In 2006, Mironov andZhang [04] evaluated suchtestcases within 10 minutes.

Page 52: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 52

MD4 testcases & resultsTestcase B [03]Words in rounds 0–11completely undetermined.

Page 53: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 53

MD4 testcases & resultsTestcase B [03]Words in rounds 0–11completely undetermined.

∼ 20 minutes

Page 54: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 54

MD4 testcases & resultsTestcase C [03]Words in rounds 0–20completely undetermined.Collision still given inround 32.

Page 55: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 55

MD4 testcases & resultsTestcase C [03]Words in rounds 0–20completely undetermined.Collision still given inround 32.

∼ 18 minutes

Page 56: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 56

MD4 testcases & resultsTestcase C [03]Words in rounds 0–20completely undetermined.Collision still given inround 32.

∼ 18 minutes

Nice, but we want to attackSHA-256, which is muchmore difficult.

Page 57: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 57

Tweaking SAT encoding

Definition. Given two CNFs A and B, theyare called equisatisfiable iff A is satisfiable iff B.

CNF simplification is done to transform theCNF into a representation which improvesthe performance of the SAT solver.

cmsat

minisat

satelitelingeling

Page 58: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 58

Tweaking SAT encoding

Simplification reduces the problem size.

simplification variables percent of none clauses percent of nonenone 48,704 100 % 253,984 100 %

cmsat 24,503 50 % 111,931 44 %lingeling 48,704 100 % 106,626 42 %

minisat 20,895 43 % 118,236 47 %satelite 27,495 56 % 153,262 60 %

for Testcase C

Page 59: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 59

Tweaking SAT encoding

Simplification as preprocessing step does notsignificantly improve the runtime of SATsolvers.

solver version none cmsat lingeling minisat sateliteMiniSat 2.2.0 4,519 7,649 1,337 1,476 1,293

CryptoMiniSat 5 1,064 973 1,201 4,470 3,920Lingeling ats1 1,492 906 356 860 1,297

Treengeling ats1 1,281 13,401 20,903 13,790 10,840Plingeling ats1 2,310 1,232 955 1,384 2,030

for Testcase C

Page 60: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 60

Tweaking SAT encoding

Definition. Differential description

Boolean function IF returns the secondargument, if the first is true, otherwise thethird argument.

Differential behavior:(0, 1, 1) =⇒ 1 (0, 0, 0) =⇒ 0

(¬a ∧ b ∧ c) =⇒ r ⇐⇒ a ∨ ¬b ∨ ¬c ∨ r(¬a ∧ ¬b ∧ ¬c) =⇒ ¬r ⇐⇒ a ∨ b ∨ c ∨ ¬r

Page 61: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 61

Tweaking SAT encoding

Idea. Assigning false first

Few differences are more likely to cancel out.=⇒ Guess all difference variables false first.

Basic idea of differential cryptanalysis:Assign all difference variables first.

Page 62: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 62

Tweaking SAT encoding

Definition. Preference variables

Assume x∗ is assigned (Boolean false) first.Assume ∆x is assigned first. Worked well in aprevious, non-SAT tool.

Let ∆x be the difference variable of pair (x, x′).We introduce a new Boolean variable x∗ calledpreference variable. We add clause

x∗ = (∆x ∧ x)

Page 63: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 63

SHA-256 testcases

Testcase 18 [05]

Page 64: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 64

SHA-256 testcases

Testcase 21 [05]

Page 65: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 65

SHA-256 testcases

Testcase 23 [05]

Page 66: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 66

SHA-256 testcases

Testcase 24 [05]

Page 67: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 67

SHA-256 results

A differential description encoding improvesthe runtime compared to a missingdifferential description.

CryptoMiniSat 5 lingeling-ats1testcase w/o dd w/ dd w/o dd w/ ddMD4, C 1,064 231 798 53SHA-256, 18 37 37 31 160SHA-256, 21 > 7,855 28,621 5,513SHA-256, 23 > 26,212 76,196 1,450SHA-256, 24 > 37,194 78,017 1,235

Page 68: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 68

SHA-256 results

Lingeling option --phase=-1 improves itsruntime for our testcases.

Option --phase=-1 of lingeling is describedas “default phase” set to −1 (negative), 0(default, Jeroslow-Wang strategy [06]) or 1(positive).

testcase 18 21 23 24phase 0 -1 0 -1 0 -1 0 -1

runtime 31 22 28,621 19,717 76,196 71,677 85,774 70,259

Page 69: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 69

SHA-256 results

Evaluating difference variables false firstimproves the runtime.

testcase C 18 21 23 24basic approach (ats1) 798 31 28,621 76,196 85,774diff-first-false (ats1o1) 652 29 27,599 59,312 66,052

Page 70: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 70

SHA-256 results

Adding preference variables dramaticallyworsens performance.

testcase A B C 18 21 23 24CNF with diff-desc 11 133 155 49 2,282 1,314 2,632

pref variables added 8 50 62 > > > >

Page 71: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 71

SHA-256 results

Adding preference variables dramaticallyworsens performance.

testcase A B C 18 21 23 24CNF with diff-desc 11 133 155 49 2,282 1,314 2,632

pref variables added 8 50 62 > > > >

Page 72: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 72

Conclusion

We found full-round hash collisions in MD4.

We found a hash collisionin 24 rounds-reduced SHA-256.

• 1 very successful tweak (diff-desc)• 2 promising tweaks• 1 insignificant tweak (CNF simplification)• 1 worsening tweak (preference variables)

Page 73: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 73

References01 Christophe De Canniere and Christian Rechberger.

“Finding SHA-1 Characteristics: General Results and Applications”

02 Florian Mendel, Tomislav Nad, Martin Schlaffer.“Improving Local Collisions: New Attacks on Reduced SHA-256”

03 Noboru Kunihiro, Kazuo Ohta, Yu Sasaki and Lei Wang.“New message difference for MD4” (MD4 testcases)

04 Ilya Mironov and Lintao Zhang.“Applications of SAT solvers to cryptanalysis of hash functions”

05 Alex Biryukov and Ivica Nikolic.“Collisions for step-reduced SHA-256” (SHA-256 testcases)

06 Robert G. Jeroslow and Jinchang Wang.“Solving Propositional Satisfiability Problems”

Silly walk image Leo Antunes Knight image Springfield Punx

Page 74: Differential cryptanalysis with SAT solvers - Lukas Prokop · Lukas Prokop 22th of Sept 2016 slide number 1 MegoSAT project Di erential cryptanalysis with SAT solvers Today: “master

Graz University of TechnologyInstitute of Applied Information Processing and Communications

slide numberLukas Prokop 22th of Sept 2016 74

どうもありがとうございました

http://lukas-prokop.at/proj/megosat

All resources available online at:

Acknowledgements: Florian Mendel,Maria Eichlseder, Armin Biere, RoderickBloem, Mate Soos, Martina, my parentsand many others . . .