{
  "id": "wire-format/sha256-block",
  "family": "wire-format",
  "slug": "sha256-block",
  "title": "SHA-256 (block structure)",
  "summary": "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.",
  "kind": "wire-format",
  "aliases": [
    "SHA-256 (block structure)"
  ],
  "status": "standard",
  "verification": "verified",
  "tier": "B",
  "source_url": "https://www.rfc-editor.org/",
  "source_version": "retrieved 2026-05-29",
  "retrieved_date": "2026-05-29",
  "ext_type": "wire-format@1",
  "ext": {
    "spec": "FIPS 180-4 (SHA-256)",
    "summary": "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.",
    "structure": [
      {
        "field": "Message block",
        "size": "64 bytes (512 bits)",
        "meaning": "Input chunk, padded to a multiple of 64 bytes (append 0x80, zeros, and 64-bit big-endian length)."
      },
      {
        "field": "W[0..15]",
        "size": "16 x 4 bytes",
        "meaning": "The 16 32-bit words of the message block (big-endian)."
      },
      {
        "field": "W[16..63]",
        "size": "48 x 4 bytes",
        "meaning": "Extended words: W[t] = σ1(W[t-2]) + W[t-7] + σ0(W[t-15]) + W[t-16]."
      },
      {
        "field": "Working variables",
        "size": "8 x 4 bytes",
        "meaning": "a, b, c, d, e, f, g, h (initial hash values H0..H7)."
      },
      {
        "field": "Round function",
        "size": "64 rounds",
        "meaning": "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."
      },
      {
        "field": "Output",
        "size": "32 bytes (256 bits)",
        "meaning": "Final hash = H0..H7 (each 4 bytes, big-endian) after all blocks."
      },
      {
        "field": "K constants",
        "size": "64 x 4 bytes",
        "meaning": "First 32 bits of the fractional parts of the cube roots of the first 64 primes."
      }
    ],
    "example_hex": "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",
    "example_decoded": "SHA-256 padding for 'abc' (3 bytes): 0x80, zeros, then 64-bit length 0x18 (24 bits)",
    "notes": [
      "SHA-256 is used in Bitcoin, TLS, SSH, Git, and many other systems.",
      "The initial hash values H0..H7 are the first 32 bits of the fractional parts of the square roots of the first 8 primes.",
      "SHA-256 is quantum-resistant (Grover's algorithm halves the effective security to 128 bits).",
      "SHA-3 (Keccak) is a different construction (sponge function) and is not vulnerable to length-extension attacks."
    ]
  },
  "updated": "2026-05-29"
}
