{
  "id": "wire-format/chacha20-block",
  "family": "wire-format",
  "slug": "chacha20-block",
  "title": "ChaCha20 stream cipher block",
  "summary": "ChaCha20 is a stream cipher (RFC 8439) that generates a 64-byte keystream block from a 256-bit key, 96-bit nonce, and 32-bit counter. The state is a 4x4 matrix of 32-bit words: 4 constants ('expa', 'nd 3', '2-by', 'te k'), 8 key words, 1 counter word, 3 nonce words. 20 rounds (10 double-rounds) of quarter-round operations produce the keystream.",
  "kind": "wire-format",
  "aliases": [
    "ChaCha20 stream cipher block"
  ],
  "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": "RFC 8439",
    "summary": "ChaCha20 is a stream cipher (RFC 8439) that generates a 64-byte keystream block from a 256-bit key, 96-bit nonce, and 32-bit counter. The state is a 4x4 matrix of 32-bit words: 4 constants ('expa', 'nd 3', '2-by', 'te k'), 8 key words, 1 counter word, 3 nonce words. 20 rounds (10 double-rounds) of quarter-round operations produce the keystream.",
    "structure": [
      {
        "field": "Constants",
        "size": "4 x 4 bytes",
        "meaning": "'expa' (0x61707865), 'nd 3' (0x3320646E), '2-by' (0x79622D32), 'te k' (0x6B206574)."
      },
      {
        "field": "Key",
        "size": "8 x 4 bytes",
        "meaning": "256-bit key as 8 little-endian 32-bit words."
      },
      {
        "field": "Counter",
        "size": "1 x 4 bytes",
        "meaning": "32-bit block counter (little-endian), starts at 1 for the first block."
      },
      {
        "field": "Nonce",
        "size": "3 x 4 bytes",
        "meaning": "96-bit nonce as 3 little-endian 32-bit words."
      },
      {
        "field": "Quarter round",
        "size": "in-place",
        "meaning": "QR(a,b,c,d): a+=b; d^=a; d<<<=16; c+=d; b^=c; b<<<=12; a+=b; d^=a; d<<<=8; c+=d; b^=c; b<<<=7."
      },
      {
        "field": "Output",
        "size": "64 bytes",
        "meaning": "XOR the final state with the initial state to produce the keystream block."
      }
    ],
    "example_hex": "65 78 70 61 6e 64 20 33 32 2d 62 79 74 65 20 6b 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",
    "example_decoded": "ChaCha20 state: constants + zero key + counter 0 + zero nonce",
    "notes": [
      "ChaCha20 is used in TLS 1.3 (ChaCha20-Poly1305), WireGuard, and SSH.",
      "20 rounds = 10 double-rounds (column rounds + diagonal rounds).",
      "ChaCha20 is not patented and is fast in software (no hardware acceleration needed).",
      "Poly1305 is the companion MAC, forming ChaCha20-Poly1305 AEAD."
    ]
  },
  "updated": "2026-05-29"
}
