def hs_hmac

bend-osdev-crypto@0.1.0.0 · check.bend:357

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/hmac.bend as Hm

357# HMAC over a hash of the hashes package, in one call and in two pieces,
358# and verify of the tag
359def hs_hmac(~H: Data, ~bsize: Nat, ~init: H, ~update: H -> B.Octets -> H, ~final: H -> B.Octets, ~digest: B.Octets -> B.Octets, +k: B.Octets, +a: B.Octets, +b: B.Octets) -> String:
360  +kk = Hm.CrHmac.key(~bsize, ~digest, k)
361  +t = Hm.CrHmac.mac(~digest, kk, B.Octets.append(a, b))
362  +t2 = Hm.CrHmac.finish(~H, ~init, ~update, ~final, Hm.CrHmac.update(~H, ~update, Hm.CrHmac.update(~H, ~update, Hm.CrHmac.start(~H, ~init, ~update, kk), a), b))
363  cat(B.Octets.hex(t), cat(" ", cat(B.Octets.hex(t2), cat(" ", yes_no(Hm.CrHmac.verify(~digest, kk, B.Octets.append(a, b), t))))))

Uses (13)

Used by (1)