liveBook · Manning

SHA-256

As explained in Hacking Cryptography

SHA-256 is a member of the Secure Hash Algorithm 2 family that produces 256-bit cryptographic hash digests.

SHA-256 produces a 256-bit cryptographic digest, but using it as H(secret || message) for authentication exposes a dangerous construction: a known digest can enable message extension without revealing the secret. section 7.3 section 7.3.2

A Merkle–Damgård hash outputs its internal state as the digest. An attacker can therefore resume hashing from H(A), append chosen data B, and calculate H(A || B) when the original message length is known. section 7.3.2

Forging a bank transaction

A request authenticated as amount=10 can be extended with padding and a fresh amount=424242 parameter. The test waits two seconds, creates a new timestamp, computes the extended MAC, and submits the forged request.

How Hacking Cryptography covers it

How deep it goes
Explains Merkle–Damgård state exposure, padding, digest parsing, and HTTP forgery code, stopping short of redesigning authentication.
Examples
Uses a bank transaction API, signed query strings, SHA-256 padding, Go code, and an OpenSSL-backed forgery test.
What it assumes
Assumes familiarity with Go, HTTP requests, MACs, and cgo; develops SHA-256 padding and hash-state resumption explicitly.
What you can do after
Diagnose and reproduce secret-prefix MAC vulnerabilities with Go, cgo, and OpenSSL SHA-256 state manipulation.
How it connects
Connects SHA-256 to cryptographic hash functions, message authentication codes, Merkle–Damgård construction, padding, and replay attacks.

Also explained in

Compare how 4 books explain SHA-256 →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.