Contents
StandardNIST

FIPS 198-1 (HMAC)

The Keyed-Hash Message Authentication Code (HMAC)

HMAC (FIPS 198-1) lets two parties who share a secret key detect a changed message and reject a tag made by anyone who lacks that key.

What it is

FIPS 198-1 specifies HMAC, a keyed-hash message authentication code. The sender and the receiver share a secret key. The sender mixes that key into the message with two fixed pad patterns, runs the hash twice, and appends the tag. The receiver repeats the calculation and accepts the message only when the tags match. A match tells you the bytes were not changed and that the sender knows the key.

HMAC is a pattern you fill in with a hash, such as SHA-256 or SHA-384. HMAC gives integrity and origin authentication for parties who share the key. It leaves the message readable. Every key holder can produce a valid tag, so the tag cannot show an outsider which holder sent it.

Who it applies to

Cybersecurity engineers choose HMAC or another authenticator, such as a block-cipher MAC or a signature, and record that choice in the cybersecurity concept. Basic-software engineers map the construction onto key slots and onto MAC-generate and MAC-verify jobs in the crypto stack. Application code calls those jobs and rejects the payload when the tag does not match.

Hardware engineers implement the two hash passes in an HSM or secure element so the key stays out of application RAM. Network engineers meet HMAC as the record authenticator in non-AEAD TLS 1.2 cipher suites and inside HKDF, which TLS 1.3 uses to derive keys. Update engineers meet it when a manifest is authenticated with a shared key.

What it covers

The standard defines the key block and the two hash passes. A key longer than the hash block is hashed, then padded with zeros out to one block. A shorter key is padded with zeros. The block is exclusive-ored with an inner pad (the byte 0x36 repeated) and with an outer pad (the byte 0x5c repeated). The outer hash output is the MAC, shortened from the left when the protocol uses a short tag.

Choice What you decide
Secret key Who may create or check tags. Generate it with an approved random source and store it in a key store.
Hash An approved SHA-2 or SHA-3 hash. FIPS 198-1 keys the hash; the hash standards define it.
Tag length Full hash output, or a prefix long enough for how exposed the message is.
Accept rule Recompute the tag and accept the payload only on a match.

Key length, which hashes are fit for new work, and the effect of truncation are set with SP 800-107 and the hash standards.

How it fits with other documents

RFC 2104 describes the same pad-and-double-hash construction for Internet protocols. FIPS 198-1 is the federal form of that construction and points to approved hashes: SHA-2 in the FIPS 180 series and SHA-3 in FIPS 202.

SP 800-38B defines AES-CMAC, a block-cipher MAC that many secure-onboard-communication profiles use in place of HMAC. FIPS 186 signatures use a sender-only private key when an outsider must see who sent the data. AUTOSAR Classic and Adaptive crypto stacks offer HMAC as a MAC primitive next to those other mechanisms. TLS 1.2 uses HMAC on records in its non-AEAD cipher suites, and TLS 1.3 uses HMAC inside HKDF. ISO/SAE 21434 requires the cybersecurity concept to justify the authenticator.

In practice

Use SHA-256 or a longer SHA-2 or SHA-3 hash for new designs. Limit HMAC-SHA-1 to peers that still require it. Keep the key in an HSM or other secure key store that can run the hash. A key embedded in an ECU image is readable by anyone who has the image. Use separate keys for the MAC and for encryption.

Compare tags in constant time so timing does not leak how many leading bytes matched. On rollover, accept the old key only during the documented overlap, then delete it. A failed MAC is an authentication failure: drop the payload and log it. Where the channel also needs confidentiality, use an authenticated-encryption mode, or an encrypt-then-MAC order the concept defines key by key.

What it means for your discipline

  • CybersecurityCore

    You own the HMAC rules in the cybersecurity concept: which hash, how long the tag is, how keys are generated, stored, and retired, and what a failed tag means. Reviews check constant-time compares and that the key cannot be read out of an ECU image.

  • Base softwareCore

    You configure MAC-generate and MAC-verify jobs, the hash, the tag length, and the key slot in the crypto stack. The application should see a job and a key id, not the pad bytes or the raw key.

  • E/E architecturePartial

    You place HMAC only on channels whose endpoints can share and protect a secret, and you name that trust boundary in the E/E architecture. Daily work is choosing it against a block-cipher MAC or a signature when you draw the security view.

  • HPC & application softwarePartial

    You call the crypto stack to build or check the tag and you reject the payload on mismatch. Daily defects are truncated tags copied at the wrong width and keys taken from the wrong slot.

  • Hardware & siliconPartial

    You run the two hash passes inside the HSM or secure element and you keep the key off the application bus. The engine has to implement the named hash; a CMAC-only accelerator does not provide HMAC.

  • Networks & communicationPartial

    You see HMAC in non-AEAD TLS 1.2 cipher suites and inside the HKDF step of TLS 1.3. For CAN and Ethernet secure onboard communication, check whether the design selected HMAC or a block-cipher MAC before you size the authenticator field.

  • Software update & OTAPartial

    A shared-key tag on a manifest shows the package came from a party who holds that key. You provision and rotate the key with the update campaign, and you move to a signature when each vehicle must prove origin to someone outside that key group.

No direct stake: Functional safety · Diagnostics & lifecycle