Computes a tagged MAC over data using key.
The current implementation uses a fixed HMAC choice internally and
returns a tagged buffer so callers do not depend on that detail.
@eryx/crypto/hmac ModuleHigh-level keyed message authentication.
This module provides a single HMAC API for application code that wants authenticity and integrity without choosing a concrete hash function at every call site.
The returned MAC is a tagged buffer, allowing the underlying
algorithm choice to evolve later.
The current format is:
"$m$" || raw_maclocal hmac = require("@eryx/crypto/hmac")
local mac = hmac.digest(buffer.fromstring("secret"), buffer.fromstring("hello"))
assert(hmac.verify(buffer.fromstring("secret"), buffer.fromstring("hello"), mac))
Computes a tagged MAC over data using key.
The current implementation uses a fixed HMAC choice internally and
returns a tagged buffer so callers do not depend on that detail.
Secret key.
Input data.
Tagged MAC.
Verifies that mac matches data under key.
Returns true if the MAC is well-formed, uses a supported tag, and
matches the supplied key and data. Returns false for malformed or
mismatched values.
Secret key.
Input data.
Tagged MAC previously returned by digest.
true if the MAC matches.