def michael_mac.of
bend-osdev-crypto@0.1.0.0 · check.bend:365
import bend-osdev-crypto@0.1.0.0/check.bend as Check
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import bend-osdev-crypto@0.1.0.0/crypto.bend as Cr
import bend-osdev-crypto@0.1.0.0/inst_michael.bend as MIC
import bend-osdev-hashes@0.1.0.0/hashes.bend as Hs
import bend-osdev-hashes@0.1.0.0/michael.bend as HMI
365
366
367def michael_mac.of(r: Result<&2, &2, Cr.CrError, Hs.HsW2>, +m: B.Octets) -> String:
368 match r:
369 case Fail{e}:
370 err(e)
371 case Done{+k}:
372 +t = HMI.HsMichael.mic(k, m)
373 cat(B.Octets.hex(t), cat(" ", cat(yes_no(MIC.CrMichael.verify(k, m, t)), cat(" ", yes_no(MIC.CrMichael.verify(k, m, B.Octets.append(B.Octets.of_list([U32.xor(cr.check.first(t), 1)]), B.Octets.drop(1n, t))))))))