What is HMAC?

Validating API Trust

HMAC is a specific mechanism for calculating a message authentication code utilizing a generic cryptographic hash function (like SHA-256) in combination with a secret cryptographic key.

Web APIs extensively use HMAC to sign tokens. The server hashes a payload using its private server-side key. When the token returns, the server repeats the action to perfectly verify the data wasn't spoofed natively by the client.

JSON Web Tokens (JWT)

The most common implementation of HMAC is JWTs used for session persistence. A JWT consists of a readable header, a readable payload, and an HMAC cryptographic signature locking them together. The client trusts the token because the server verifies the signature using a key only the server possesses.

Everyday Example

Imagine a bouncer stamping a massive, complex UV-ink stamp on your hand when you enter a club. You can leave the club and return the next day showing your stamp. The club doesn't need to look up a giant list of names. If you try to forge the stamp with a marker, the bouncer instantly knows it's fake because you don't possess the magical UV ink.

The Deep Mathematics

An HMAC provides stringent message authentication. Traditional hashing like H(key || message) is drastically vulnerable to 'length extension attacks'. HMAC mitigates this via inner and outer padding limits: H(K ⊕ opad || H(K ⊕ ipad || message)). The deterministic mathematical signature verifies seamlessly without requiring stateful memory allocation on the verifier node.

Discover how giovium protects your data

giovium leverages these very cryptographic principles to keep your passwords, files, and secrets completely safe. Try it for free on any platform.

Download giovium