def mask

bend-collections-laws-crypto@1.0.0.0 · src/crypto/mac.bend:42

import bend-collections-laws-crypto@1.0.0.0/src/crypto/mac.bend as Mac
import Base

42# The n-byte block (key zero-padded to n bytes) XOR the pad byte, in one
43# pass: past the end of the key a byte is 0 XOR pad = pad.
44def mask(key: List<&2, U32>, n: Nat, +pad: U32) -> List<&2, U32>:
45  match key n:
46    case Nil{} 0n:
47      Nil{}
48    case Nil{} 1n+p:
49      pad <> mask(Nil{}, p, pad)
50    case k <> rest 0n:
51      Nil{}
52    case k <> rest 1n+p:
53      U32.xor(k, pad) <> mask(rest, p, pad)

Uses (4)

Used by (6)