Back to Articles

· 3 min read · views

Ship It Only After the Checksum Agrees

A release-desk procedure for digests vs HMAC — when SHA-256 is enough, when you need a key, and how to verify a build without trusting the download page's vibes.

Ship It Only After the Checksum Agrees

Procedure · REL-HASH-01

Owner: whoever pressed “publish”
Goal: prove the bytes you ship are the bytes you built

Skip the essay. Follow the steps. Annotate exceptions in the PR.


Step 0 — Name the threat

Ask only one question:

Am I detecting accidental corruption, or also someone swapping the artifact?

Threat Tool Why
Bit rot, bad mirror, partial download Digest (SHA-256+) Same input → same hex; no secret required
Attacker who can replace file and the published checksum on the same site Digest alone is weak They rewrite both
Attacker who can replace the file but not your signing/HMAC channel HMAC or signature Needs the key / pubkey

If the checksum lives next to the malware on the same compromised bucket, you verified nothing but consistency of the lie.


Step 1 — Produce the digest at build time

On the builder (not on a laptop “later”):

sha256sum dist/app-1.4.2.tar.gz | tee dist/app-1.4.2.tar.gz.sha256

Record algorithm + filename + hex in release notes. Prefer SHA-256 as the default public checksum. Keep SHA-1 for legacy verify only; do not mint new trust on it.


Step 2 — Verify on the consumer side

Download artifact + published digest. Compare with a tool that does not “almost match.”

Local option: Hash / Checksum Lab — drop the file or paste text, pick SHA-256, paste expected hex into compare. Timing-safe match/mismatch beats eyeballing the first eight characters.


Step 3 — When to switch to HMAC

Use HMAC-SHA-256 (or stronger) when:

  • two services share a secret and need integrity + authenticity of a payload
  • you are protecting API webhooks, signed cookies-of-sorts, or internal manifests
  • the verifier must reject bytes altered by anyone without the key

Do not use HMAC as a public download checksum — readers cannot verify without the secret, and publishing the secret destroys the point.

Digest  = public fingerprint of bytes
HMAC    = fingerprint bound to a key
Sign    = fingerprint bound to an asymmetric identity (often better for releases)

For public software releases, prefer minisign / Sigstore / GPG over “HMAC in a README.”


Step 4 — Gate the release

Checklist before announcing:

  • Digest generated on CI from the exact artifact path
  • Algorithm named (SHA-256), not implied
  • Verify step reproduced on a clean machine
  • Compare is exact match (tool or sha256sum -c)
  • If high assurance: signature published; digest is secondary
  • Secrets for HMAC never landed in the public notes

Failure modes worth a sticky note

  • Trailing newline differences → different hash (hash the file, not a retyped string)
  • “SHA-256 of the ZIP” vs “of the inner binary” — label which
  • Uppercase/lowercase hex — normalize before compare
  • Trusting HTTPS hosting alone — TLS delivers whatever the bucket currently contains

Sign-off line

Integrity is a procedure, not a feeling. If the checksum disagrees, you do not “mostly ship.” You stop.