wire / wire-format / sha256-block

SHA-256 (block structure)

SHA-256 processes input in 512-bit (64-byte) blocks. Each block: parse into 16 32-bit words, extend to 64 words via sigma functions, then 64 rounds of compression using 8 working variables (a-h), round constants K[0..63], and the Ch/Maj/Sigma functions. Output: 256-bit (32-byte) digest.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: SHA-256 (block structure)

wire format

spec: FIPS 180-4 (SHA-256)

SHA-256 processes input in 512-bit (64-byte) blocks. Each block: parse into 16 32-bit words, extend to 64 words via sigma functions, then 64 rounds of compression using 8 working variables (a-h), round constants K[0..63], and the Ch/Maj/Sigma functions. Output: 256-bit (32-byte) digest.

fieldsizemeaning
Message block64 bytes (512 bits)Input chunk, padded to a multiple of 64 bytes (append 0x80, zeros, and 64-bit big-endian length).
W[0..15]16 x 4 bytesThe 16 32-bit words of the message block (big-endian).
W[16..63]48 x 4 bytesExtended words: W[t] = σ1(W[t-2]) + W[t-7] + σ0(W[t-15]) + W[t-16].
Working variables8 x 4 bytesa, b, c, d, e, f, g, h (initial hash values H0..H7).
Round function64 roundsT1 = h + Σ1(e) + Ch(e,f,g) + K[t] + W[t]; T2 = Σ0(a) + Maj(a,b,c); h=g; g=f; f=e; e=d+T1; d=c; c=b; b=a; a=T1+T2.
Output32 bytes (256 bits)Final hash = H0..H7 (each 4 bytes, big-endian) after all blocks.
K constants64 x 4 bytesFirst 32 bits of the fractional parts of the cube roots of the first 64 primes.

example:

61 62 63 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18

SHA-256 padding for 'abc' (3 bytes): 0x80, zeros, then 64-bit length 0x18 (24 bits)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/sha256-block or /wire-format/sha256-block.json