Glossary

What is HMAC?

HMAC (Hash-Based Message Authentication Code) is a cryptographic mechanism that combines a cryptographic hash function with a secret key to produce a fixed-size authentication code, allowing the recipient to verify both the integrity and the authenticity of a message.

Also known as: Hash-Based Message Authentication Code, HMAC-SHA256

A plain hash function like SHA-256 can verify data integrity — if the hash matches, the data has not been altered. But a hash alone cannot verify authenticity, because anyone can compute a hash. HMAC solves this by incorporating a secret key into the hashing process. Only parties who possess the key can generate or verify the correct HMAC value, providing both integrity and authentication in a single operation.

The HMAC construction, defined in RFC 2104, applies the hash function twice with the key mixed in at specific stages. This double-pass structure protects against length extension attacks and other vulnerabilities that would arise from naively concatenating a key with the message before hashing. HMAC-SHA256 (HMAC using SHA-256 as the underlying hash) is the most common variant and produces a 256-bit authentication code.

HMAC is used extensively across security protocols: JWT signatures, API authentication, webhook verification, TLS record protection, and OAuth all rely on HMAC. Its efficiency makes it practical for authenticating high-volume data like network packets or API requests, where asymmetric signature schemes would introduce unacceptable latency.

How Vaulted uses HMAC

Vaulted uses HMAC-SHA256 to generate secure tokens for secret status pages. When a secret is created, an HMAC is computed over the secret ID using a server-side key. This HMAC token is included in the status page URL, allowing the secret creator to check whether their secret has been viewed or has expired — without giving the status endpoint a way to consume views or access the encrypted content. HMAC is also used internally by PBKDF2 as its pseudorandom function when deriving keys from passphrases.