def cr.kb.fb

bend-osdev-crypto@0.1.0.0 · kbkdf.bend:66

import bend-osdev-crypto@0.1.0.0/kbkdf.bend as Kbkdf
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B

66# n more bytes in feedback mode: the rest of the current block cur, then
67# PRF(K_IN, K(i) || [i + 1]_2 || fixed), with prev = K(i)
68def cr.kb.fb(~K: Data, ~compute: K -> B.Octets -> B.Octets, n: Nat, cur: List<&2, U32>, +k: K, +rlen: Nat, +fixed: B.Octets, +prev: B.Octets, +i: U32) -> List<&2, U32>:
69  match n:
70    case 0n:
71      Nil{}
72    case 1n+p:
73      match cur:
74        case Con{h, t}:
75          Con{h, cr.kb.fb(~K, ~compute, p, t, k, rlen, fixed, prev, i)}
76        case Nil{}:
77          +blk = compute(k, B.Octets.append(prev, B.Octets.append(CrKbkdf.counter(rlen, U32.add(i, 1)), fixed)))
78          +bl = B.Octets.to_list(blk)
79          Con{cr.kb.head(bl), cr.kb.fb(~K, ~compute, p, cr.kb.tail(bl), k, rlen, fixed, blk, U32.add(i, 1))}

Uses (10)

Used by (5)