def window_compress16

bend-collections-laws-crypto@1.0.0.0 · src/crypto/sha/core.bend:161

import bend-collections-laws-crypto@1.0.0.0/src/crypto/sha/core.bend as Core
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/sha/state.bend as S

161# Fast path for the 16-word blocks produced by block_bytes. It executes the
162# seed rounds directly and constructs only the fixed rolling window.
163def window_compress16(+a: U32, +b: U32, +c: U32, +d: U32,
164  +e: U32, +f: U32, +g: U32, +h: U32,
165  +i: U32, +j: U32, +k: U32, +l: U32,
166  +m: U32, +n: U32, +o: U32, +p: U32,
167  +extra: Nat, +ks: List<&2, U32>, +s: S.State) -> S.State:
168  match ks:
169    case k0 <> k1 <> k2 <> k3 <> k4 <> k5 <> k6 <> k7 <>
170      k8 <> k9 <> k10 <> k11 <> k12 <> k13 <> k14 <> k15 <> kt:
171      s1 = step(s, k0, a)
172      s2 = step(s1, k1, b)
173      s3 = step(s2, k2, c)
174      s4 = step(s3, k3, d)
175      s5 = step(s4, k4, e)
176      s6 = step(s5, k5, f)
177      s7 = step(s6, k6, g)
178      s8 = step(s7, k7, h)
179      s9 = step(s8, k8, i)
180      s10 = step(s9, k9, j)
181      s11 = step(s10, k10, k)
182      s12 = step(s11, k11, l)
183      s13 = step(s12, k12, m)
184      s14 = step(s13, k13, n)
185      s15 = step(s14, k14, o)
186      s16 = step(s15, k15, p)
187      feedforward(s, window_rounds(extra,
188        W{p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, a}, kt, s16))
189    case _:
190      fused_compress([a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p], extra, ks, s)

Uses (9)

Used by (5)