Advanced hash function design: inside Keccak Guido Bertoni 1 Joan - - PowerPoint PPT Presentation

advanced hash function design inside keccak
SMART_READER_LITE
LIVE PREVIEW

Advanced hash function design: inside Keccak Guido Bertoni 1 Joan - - PowerPoint PPT Presentation

Advanced hash function design: inside Keccak Advanced hash function design: inside Keccak Guido Bertoni 1 Joan Daemen 1 Michal Peeters 2 Gilles Van Assche 1 Ecrypt II summer school, Albena June 2, 2011 1 / 46 1 STMicroelectronics 2 NXP


slide-1
SLIDE 1

Advanced hash function design: inside Keccak

Advanced hash function design: inside Keccak

Guido Bertoni1 Joan Daemen1 Michaël Peeters2 Gilles Van Assche1

1STMicroelectronics 2NXP Semiconductors

Ecrypt II summer school, Albena June 2, 2011

1 / 46

slide-2
SLIDE 2

Advanced hash function design: inside Keccak

Outline

1

Advancing hash function design

2

Advancing the mode

3

Advancing the inner function

4

Motivating the design of Keccak-f

5

Keccak resources

2 / 46

slide-3
SLIDE 3

Advanced hash function design: inside Keccak Advancing hash function design

Outline

1

Advancing hash function design

2

Advancing the mode

3

Advancing the inner function

4

Motivating the design of Keccak-f

5

Keccak resources

3 / 46

slide-4
SLIDE 4

Advanced hash function design: inside Keccak Advancing hash function design

What is advanced hash function design?

Design principles of MD4 and descendents:

Mode: Merkle-Damgård with Davies-Meyer

collision-resistance preservation is central coding of message length in the padding block cipher with a feedforward

Inner function: block cipher

data path for CV: generalized Feistel network ARX based nonlinearity Separate message expansion for message block

Advanced design: anything that improves upon this

4 / 46

slide-5
SLIDE 5

Advanced hash function design: inside Keccak Advancing the mode

Outline

1

Advancing hash function design

2

Advancing the mode

3

Advancing the inner function

4

Motivating the design of Keccak-f

5

Keccak resources

5 / 46

slide-6
SLIDE 6

Advanced hash function design: inside Keccak Advancing the mode

Advancing the mode

Problems of Merkle-Damgård

length extension 2nd pre-image attacks more efficient than expected

  • etc. etc. etc.

One approach: don’t separate mode and inner function

AKA streaming-based hashing Examples: Panama, Grindahl, RadioGatún, Fugue Promising but hard to obtain assurance

Anther approach: get the criteria for the mode right

Abandon property-preserving paradigm Replace by random oracle (RO) indifferentiability Proof bounds success probability of all generic attacks Requires a strong inner function resisting specific attacks

6 / 46

slide-7
SLIDE 7

Advanced hash function design: inside Keccak Advancing the mode Building a sound mode

Building a sound mode

Patching Merkle-Damgård by adding complexity

Enveloped Merkle-Damgård (EMD): treat last block differently Haifa: extend Merkle-Damgård by adding in inner function:

dedicated input for salt dedicated input for counter

does not address the compression function design problem

Tabula rasa: sponge construction

simplification message bits and chaining bits are treated the same way no feedforward, no length coding in padding uses a permutation, known how to design

7 / 46

slide-8
SLIDE 8

Advanced hash function design: inside Keccak Advancing the mode The sponge construction

The sponge construction

More general than hash function: arbitrary-length output

stream encryption, MGF, … duplex mode: authenticated encryption, reseedable PRG, …

Calls a b-bit permutation f, with b = r + c

r bits of rate c bits of capacity (security parameter)

8 / 46

slide-9
SLIDE 9

Advanced hash function design: inside Keccak Advancing the mode The sponge construction

Generic security of the sponge construction

RO-differentiating advantage ≤ N2/2c+1

N is number of calls to f Bounds success probability of all generic attacks

Bound assumes f is random permutation

it covers generic attacks …but not attacks that exploit specific properties of f

9 / 46

slide-10
SLIDE 10

Advanced hash function design: inside Keccak Advancing the mode The Hermetic sponge strategy

Design approach

Hermetic sponge strategy

instantiate a sponge function claim a security level of 2c/2

Mission Design permutation f without exploitable properties

10 / 46

slide-11
SLIDE 11

Advanced hash function design: inside Keccak Advancing the inner function

Outline

1

Advancing hash function design

2

Advancing the mode

3

Advancing the inner function

4

Motivating the design of Keccak-f

5

Keccak resources

11 / 46

slide-12
SLIDE 12

Advanced hash function design: inside Keccak Advancing the inner function Criteria

Desired properties of f

Efficiency and flexibility

fast and compact, straight and hardened …on a wide range of CPU platforms and in hardware

Classical LC/DC criteria

absence of large differential propagation probabilities absence of large input-output correlations

infeasibility of the CICO problem Immunity to

integral cryptanalysis algebraic attacks slide and symmetry-exploiting attacks …

12 / 46

slide-13
SLIDE 13

Advanced hash function design: inside Keccak Advancing the inner function Criteria

The CICO problem

Given partial input and output, determine remaining parts Important in many attacks Pre-image generation in hashing

13 / 46

slide-14
SLIDE 14

Advanced hash function design: inside Keccak Advancing the inner function Criteria

The CICO problem

Given partial input and output, determine remaining parts Important in many attacks State recovery in stream encryption

14 / 46

slide-15
SLIDE 15

Advanced hash function design: inside Keccak Advancing the inner function Criteria

Goal: prevent control over difference propagation

Differential (A, B) is composed of trails Q from A to B: #pairs(A, B) =

Q∈(A,B)

#pairs(Q) wr(Q): number of conditions Q imposes on its pairs: wr(Q) =

active S-boxes

wr(qi, qo) If wr(Q) < b : #pairs(Q) ≈ 2b−wr(Q), else few or no pairs Ambition is to assure:

∀Q : wr(Q) > b: wide trail strategy absence of systematic clustering of trails

15 / 46

slide-16
SLIDE 16

Advanced hash function design: inside Keccak Advancing the inner function Criteria

Goal: avoid large input-output correlations

Correlation (v, u) is composed of trails Q to u from v C(v, u) = ∑

Q∈(v,u)

C(Q) Correlation contribution: C(Q) = (−1)sign(Q)2−wc(Q)/2 with wc(Q) =

active S-boxes

wc(qi, qo) If wc(Q) > b, Q contributes very little Ambition is to assure:

∀Q : wc(Q) > b: wide trail strategy absence of systematic clustering of trails

16 / 46

slide-17
SLIDE 17

Advanced hash function design: inside Keccak Advancing the inner function Choices for the permutation f

Designing the permutation f

Required width b:

long term: security strength up to 256 bits capacity up to 512 bits rate: b − 512 bits width ranges from 600 to 2400 bits

Like a block cipher

sequence of identical rounds round function that is nonlinear and has good diffusion

…but not quite

no need for key schedule round constants instead of round keys inverse permutation need not be efficient

17 / 46

slide-18
SLIDE 18

Advanced hash function design: inside Keccak Advancing the inner function Choices for the permutation f

The obvious choices

addition - rotation - XOR (ARX)

appears very powerful, but … unsuited for dedicated hardware and DPA protection hard to evaluate strength all of the MD4 and SHA family is already based on ARX

Square-inspired, like Rijndael (AES)

S-box with optimum worst-case LC and DC properties mixing layer with optimum worst-case diffusion: MDS transposition layer with optimum dispersion results in strong bounds for trail weights let’s try it!

18 / 46

slide-19
SLIDE 19

Advanced hash function design: inside Keccak Advancing the inner function Inspiration from AES

AES-based approach: size parameters

AES structure must be scaled up from 128 to 600-2400 bits Three size parameters:

S-box width: n bits MDS width: m S-boxes Dimension: d

Permutation width: b = mdn AES: n = 8, m = 4, d = 2 so b = 128

19 / 46

slide-20
SLIDE 20

Advanced hash function design: inside Keccak Advancing the inner function Inspiration from AES

Scaling up AES structure

Increase S-box width n?

software: # elements in lookup tables: 2n hardware: strong increase in # gates decreasing S-box width would be a better idea …

Increase MDS matrix size m?

SW with T-tables: size of elements is nm HW and compact SW: strong increase in # operations/gates

Increase the dimension d?

slows down diffusion strong increase in number of rounds

All in all, scaling up appears very expensive

20 / 46

slide-21
SLIDE 21

Advanced hash function design: inside Keccak Advancing the inner function Inspiration from AES

A greedy aspect in AES-inspired design

Choice of nonlinear layer

for given width n, choose S-boxes with optimum worst-case nonlinearity irrespective of implementation cost

Choice of mixing layer

for given size m, choose mixing transformation with optimum worst-case diffusion irrespective of implementation cost

Focus on worst-case LC/DC propagation over few rounds Tends to result in expensive round function

21 / 46

slide-22
SLIDE 22

Advanced hash function design: inside Keccak Advancing the inner function An alternative to imitating AES

Go for a less greedy approach

A modest nonlinear layer

no requirement for high worst-case nonlinearity log(DP(a, b)) ≈ O(HW(a)) log(C2(v, u)) ≈ O(HW(u))

A modest mixing layer

no requirement for high worst-case diffusion average diffusion preferably high

A matching transposition layer should prevent

chaining of low-weight structures into narrow trails clustering of trails

Ambition: cheaper round function, more rounds but globally more efficient

22 / 46

slide-23
SLIDE 23

Advanced hash function design: inside Keccak Motivating the design of Keccak-f

Outline

1

Advancing hash function design

2

Advancing the mode

3

Advancing the inner function

4

Motivating the design of Keccak-f

5

Keccak resources

23 / 46

slide-24
SLIDE 24

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Keccak

Keccak

Instantiation of a sponge function

variable-length input and output 10∗1 padding

Keccak uses a permutation Keccak-f

7 permutations: b ∈ {25, 50, 100, 200, 400, 800, 1600}

Security-speed trade-offs using the same permutation All values c and r with c + r = b supported Examples

SHA-3: r = 1024 and c = 576 for 2c/2 = 2288 security lightweight: r = 40 and c = 160 for 2c/2 = 280 security

24 / 46

slide-25
SLIDE 25

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The state and its parts

The state: an array of 5 × 5 × 2ℓ bits

x y z state

5 × 5 lanes, each containing 2ℓ bits (1, 2, 4, 8, 16, 32 or 64) (5 × 5)-bit slices, 2ℓ of them 7 widths b

25 / 46

slide-26
SLIDE 26

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The state and its parts

The state: an array of 5 × 5 × 2ℓ bits

x y z slice

5 × 5 lanes, each containing 2ℓ bits (1, 2, 4, 8, 16, 32 or 64) (5 × 5)-bit slices, 2ℓ of them 7 widths b

25 / 46

slide-27
SLIDE 27

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The state and its parts

The state: an array of 5 × 5 × 2ℓ bits

x y z lane

5 × 5 lanes, each containing 2ℓ bits (1, 2, 4, 8, 16, 32 or 64) (5 × 5)-bit slices, 2ℓ of them 7 widths b

25 / 46

slide-28
SLIDE 28

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The state and its parts

The state: an array of 5 × 5 × 2ℓ bits

x y z row

5 × 5 lanes, each containing 2ℓ bits (1, 2, 4, 8, 16, 32 or 64) (5 × 5)-bit slices, 2ℓ of them 7 widths b

25 / 46

slide-29
SLIDE 29

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The state and its parts

The state: an array of 5 × 5 × 2ℓ bits

x y z column

5 × 5 lanes, each containing 2ℓ bits (1, 2, 4, 8, 16, 32 or 64) (5 × 5)-bit slices, 2ℓ of them 7 widths b

25 / 46

slide-30
SLIDE 30

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The state and its parts

The state: an array of 5 × 5 × 2ℓ bits

x y z plane

5 × 5 lanes, each containing 2ℓ bits (1, 2, 4, 8, 16, 32 or 64) (5 × 5)-bit slices, 2ℓ of them 7 widths b

25 / 46

slide-31
SLIDE 31

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The state and its parts

The state: an array of 5 × 5 × 2ℓ bits

x y z sheet

5 × 5 lanes, each containing 2ℓ bits (1, 2, 4, 8, 16, 32 or 64) (5 × 5)-bit slices, 2ℓ of them 7 widths b

25 / 46

slide-32
SLIDE 32

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The nonlinear mapping χ

χ, the nonlinear mapping in Keccak-f

Operates independently and in parallel on 5-bit rows Small number of operations per bit Algebraic degree 2, inverse has degree 3 LC/DC propagation properties easy to describe and analyze

26 / 46

slide-33
SLIDE 33

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The nonlinear mapping χ

Comparing χ with AES S-box

Particular criterion: X-axis: Hamming Weight HW(a) Y-axis: given HW(a), minimum weight log2(1/DC(a, b))

20 40 60 80 100 20 40 60 80 100 120

Chi 5-bit AES S-box AES-like 4-bit

27 / 46

slide-34
SLIDE 34

Advanced hash function design: inside Keccak Motivating the design of Keccak-f θ′, a mixing layer

θ′, a mixing layer

Compute parity cx,z of each column Add to each cell parity of neighboring columns: bx,y,z = ax,y,z ⊕ cx−1,z ⊕ cx+1,z

+ =

column parity θʹ effect combine

28 / 46

slide-35
SLIDE 35

Advanced hash function design: inside Keccak Motivating the design of Keccak-f θ′, a mixing layer

Diffusion of θ′

θʹ θ′ is linear:

B = θ′(A) vTa = uTb with v = θ′T(u)

Good diffusion?

input bit propagates to eleven output bits

  • utput bit depends on eleven input bits

29 / 46

slide-36
SLIDE 36

Advanced hash function design: inside Keccak Motivating the design of Keccak-f θ′, a mixing layer

Inverse of θ′

θʹ Similar to θ′ itself

bit at output propagates to eleven bits at input input bit depends on eleven output bits

30 / 46

slide-37
SLIDE 37

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Inter-slice dispersion with ρ

ρ for inter-slice dispersion

Motivation:

χ makes bits within rows interact θ linearly mixes between rows in a slice we need diffusion between the slices …

ρ: cyclic shifts of lanes with offsets: for 0 ≤ i < 25 : i(i + 1)/2 mod 2ℓ Offsets cycle through all values below 2ℓ

31 / 46

slide-38
SLIDE 38

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Inter-slice dispersion with ρ

ρ In Keccak-f

Lanes are translated (cyclically) by different amounts Moves bits of a slice to different slices Translation-invariant in the direction of the z-axis

32 / 46

slide-39
SLIDE 39

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Inter-slice dispersion with ρ

An initial attempt at Keccak-f

Round function: R = ρ ∘ θ′ ∘ χ Repeat R until all trails have sufficient weight But …

all-0 state is a fixed point of R all-1 state too

In general:

let α be a fixed point of θ′ ∘ χ then the state value with all slices = α is a fixed point

Problem: symmetry

33 / 46

slide-40
SLIDE 40

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Asymmetry with ι

ι to break symmetry

XOR of round-dependent constant to lane in origin Without ι, the round mapping would be symmetric

invariant to translation in the z-direction advantage in analysis: Matryoshka structure

Without ι, all rounds would be the same

susceptibility to slide attacks defective cycle structure

34 / 46

slide-41
SLIDE 41

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Asymmetry with ι

Another attempt at Keccak-f

Round function: R = ι ∘ ρ ∘ θ′ ∘ χ Problem: low-weight periodic trails by chaining:

θʹ ρ χ: may propagate unchanged θ′: propagates unchanged, because all column parities are 0 ρ: in general moves active bits to different slices … …but not always

35 / 46

slide-42
SLIDE 42

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Asymmetry with ι

The cause of this problem

Weak worst-case diffusion in θ′

two-bit difference/mask within column remains as is (column-parity) kernel: subset of states with all cx,z = 0 state values in kernel are invariant under θ′

Weak worst-case dispersion of ρ

ρ should move bits in a column to 5 different columns this is impossible for lane size 4 and smaller

Affects security of Keccak-f[b] with b ∈ {25, 50, 100} Why bother?

36 / 46

slide-43
SLIDE 43

Advanced hash function design: inside Keccak Motivating the design of Keccak-f The Matryoshka property

The Matryoshka property

θʹ ρ θʹ ρ

Structure Q for w = 2ℓ implies symmetric Q′ for w = 2ℓ+n Patterns in Q′ are z-periodic versions of patterns in Q Weight of trail Q′ is 2n times that of trail Q

37 / 46

slide-44
SLIDE 44

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Intra-slice transposition with π

π for disturbing horizontal/vertical alignment

ax,y ← ax′,y′ with (x y ) = (0 1 2 3 ) (x′ y′ )

38 / 46

slide-45
SLIDE 45

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Intra-slice transposition with π

Yet another attempt at Keccak-f

Round function: R = ι ∘ π ∘ ρ ∘ θ′ ∘ χ Solves problem encountered before:

θ ρ π

π moves bits in same column to different columns! One more change though: tweaking θ′

39 / 46

slide-46
SLIDE 46

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Improving θ

Tweaking θ′ to θ θ

Add to ax,y,z column parities cx−1,z and cx+1,z−1 Diffusion from single-bit input similar to that of θ′ but …

40 / 46

slide-47
SLIDE 47

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Improving θ

Inverse of θ θ

Diffusion from single-bit output to input very high Output leading to low-weight input implies specific parity Increases resistance against LC/DC and algebraic attacks

41 / 46

slide-48
SLIDE 48

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Keccak-f summary

Keccak-f summary

Round function: R = ι ∘ χ ∘ π ∘ ρ ∘ θ Number of rounds: 12 + 2ℓ

Keccak-f[25] has 12 rounds Keccak-f[1600] has 24 rounds

Efficiency

high level of parallellism flexibility: bit-interleaving software: competitive on wide range of CPU dedicated hardware: very competitive

42 / 46

slide-49
SLIDE 49

Advanced hash function design: inside Keccak Motivating the design of Keccak-f Keccak-f summary

Keccak-f propagation properties summary

χ: propagation weight ≈ Hamming weight θ: high diffusion except for low-weight in-kernel patterns π and ρ: drag those patterns out of the kernel

…for trails over 4 rounds or more not for 3 rounds: kernel vortices

Additional benefit: weak alignment

no significant trail clustering no truncated trails exploitable in rebound attacks

Algebraic attacks: low degree of round function

marginal theoretical distinguishers: zero-sum no impact on security claim

43 / 46

slide-50
SLIDE 50

Advanced hash function design: inside Keccak Keccak resources

Outline

1

Advancing hash function design

2

Advancing the mode

3

Advancing the inner function

4

Motivating the design of Keccak-f

5

Keccak resources

44 / 46

slide-51
SLIDE 51

Advanced hash function design: inside Keccak Keccak resources

Keccak resources

Keccak documentation, a.o.:

Keccak reference Keccak implementation overview Cryptographic sponge functions

KeccakTools: set of documented C++ classes supporting:

individual steps θ, ρ, π, χ and ι and their inverses ι−1 = ι, χ−1, π−1, ρ−1 and θ−1 equations in GF(2) of rounds or steps trail propagation for DC and LC ,including base + offset

All freely available on http://keccak.noekeon.org

45 / 46

slide-52
SLIDE 52

Advanced hash function design: inside Keccak Keccak resources

Questions?

Thanks for your attention!

Q?

More information on http://keccak.noekeon.org/ http://sponge.noekeon.org/

46 / 46