Realcodeart.com

SHA-256

The hash inside certificates and blocks, drawn from the standard, not from OpenSSL.

NIST FIPS 180

Get it on a mug or tee →

NIST published SHA-256 in the FIPS 180 series, the federal standard for secure hash algorithms. The 2002 revision, FIPS 180-2, is the one that added SHA-256 as part of the family called SHA-2. A hash takes a message of any practical length and produces a fixed digest. For SHA-256 the digest is 256 bits. The same message must always yield the same digest. A changed message should yield a digest that looks unrelated. You cannot go backward from the digest to the message, and you should not be able to find two messages that share a digest. Those are the promises. The standard is the construction that tries to keep them.

The construction pads the message, including the length of the original, so that the padded length is a multiple of 512 bits. It then walks the message in 512-bit blocks. Each block is expanded into a schedule of 64 words. Sixty-four rounds mix those words into eight state words, using rotations, xors, and two small logical functions the standard names. At the end of the block the new state is added back into the old state. The next block continues. When the blocks are gone, the eight words are the digest. Nothing in that summary is a source file. It is the shape of a published algorithm.

The bars are an original sketch of the compression step: load sixteen words, expand them, run the rounds, add back into the state. They were drawn for this catalog. They are not a copy of an OpenSSL file, and they are not a claim that any particular implementation has been cleared for printing. OpenSSL, LibreSSL, and the code inside a Bitcoin node are copyrighted programs that happen to perform the standard. The standard describes an algorithm. A source file is a separate work. This picture is the sketch, and the notice on the product page says exactly that. A lawyer cleared the listing of the sketch.

The users of the hash are why a person who does not read standards has still met it. Bitcoin hashes block headers with SHA-256, twice, and miners hunt for a header whose digest falls under a target. Certificates on the web are signatures over hashes, and for years SHA-256 has been the hash those signatures expect, after earlier functions wore out. Package archives publish SHA-256 sums so a downloader can see whether the bytes changed. The digest is not an encryption. It does not hide the message. It names the message, rigidly, so that a later reader can detect a substitution.

A sketch has to decide what to show. The full standard includes initial hash values, a table of round constants derived from roots of primes, and the precise padding bits. A faithful program must have all of it. A portrait does not. The portrait shows the loop that dominates the work: expand, mix, add back. The constants would be a field of numbers. The loop is a rhythm. The bars are the rhythm. Someone who wants to implement the hash should read FIPS 180, not a mug. Someone who wants to see that a hash is a compression of blocks, done the same way every time, can look at the sketch and then read this paragraph.

The piece is marked notice. That may surprise a person who thinks a government standard is automatically a public-domain picture. The algorithm's publication is not the same thing as a drawing someone made afterward, and it is certainly not the same thing as a vendor's source. The clearance covers the drawing. It does not launder an OpenSSL file into merchandise. The product page repeats the boundary in one sentence, which is the sentence that has to stay attached to the listing. The essay's job is to make the boundary feel like history rather than like a disclaimer bolted on at the end. The history is: a standard in 2002, a digest of 256 bits, a block of 512, sixty-four rounds, and a sketch that refuses to pretend it is someone else's C.

Treat the sketch as a map of the loop, not as a drop-in file. A map can omit the constant table and still be true about the direction of the work. A file cannot. The lawyer cleared the map. The product page is where that sentence has to remain, next to the buy link, for as long as the listing exists.

Mug and tee of SHA-256