def shorten_if
import bend-collections@1.0.0.0/spec/crypto/hmac.bend as Hmacimport Base
27# FIPS 198-1 steps 1-3: a key of exactly B bytes is K0 itself; a longer key
28# is hashed first (K0 = H(K) || zeros); a shorter one is zero-padded to B.
29def shorten_if(+key: List<&2, U32>, fits: Bool) -> List<&2, U32>:
30 match fits:
31 case True{}:
32 key
33 case False{}:
34 hash(key)