Skip to content
uencoder

ChaCha20

ChaCha20 is a stream cipher designed by Daniel Bernstein, built on ARX (add-rotate-XOR) operations, and is commonly paired with Poly1305 as an AEAD — a high-performance alternative to AES-GCM.

Purpose

It provides fast, constant-time-secure encryption on platforms without AES hardware acceleration, avoiding AES timing side channels.

Mechanism

An improvement on Salsa20, it runs 20 rounds of quarter-round operations. The state is a 4×4 matrix (constants, key, counter, nonce). Each round applies add-rotate-XOR to columns and diagonals; the resulting keystream is XORed with the plaintext.

Use cases

  • One of the default TLS 1.3 cipher suites
  • WireGuard VPN
  • Google server encryption
  • Mobile encryption

Examples

  • Input
    key=256bit, nonce=96bit, counter
    Output
    keystream

    Combined with Poly1305 as AEAD

Common errors

Nonce reuse replays the keystream
Use a unique nonce per message (e.g., a counter)

Related terms

Related tools

References