wire / wire-format / sha256-block
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.
aka: SHA-256 (block structure)
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.
| field | size | meaning |
|---|---|---|
| Message block | 64 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 bytes | The 16 32-bit words of the message block (big-endian). |
| W[16..63] | 48 x 4 bytes | Extended words: W[t] = σ1(W[t-2]) + W[t-7] + σ0(W[t-15]) + W[t-16]. |
| Working variables | 8 x 4 bytes | a, b, c, d, e, f, g, h (initial hash values H0..H7). |
| Round function | 64 rounds | T1 = 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. |
| Output | 32 bytes (256 bits) | Final hash = H0..H7 (each 4 bytes, big-endian) after all blocks. |
| K constants | 64 x 4 bytes | First 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)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/sha256-block
or /wire-format/sha256-block.json