def mask
import bend-collections-laws-crypto@1.0.0.0/src/crypto/mac.bend as Macimport 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)
- bend-collections-laws-crypto@1.0.0.0/src/crypto/mac:sign
- bend-collections-laws-crypto@1.0.0.0/proofs/crypto/mac/hmac:sign_correct
- bend-collections-laws-crypto@1.0.0.0/proofs/crypto/mac/hmac:block_mask
- bend-collections-laws-crypto@1.0.0.0/proofs/crypto/mac/hmac:block_mask_if
- bend-collections-laws-crypto@1.0.0.0/proofs/crypto/mac/hmac:mask_nil
- …