ChaCha20-Poly1305 is an authenticated encryption with associated data (AEAD) algorithm that combines the ChaCha20 stream cipher for confidentiality with the Poly1305 message authenticator for integrity. In cryptography it is the main standardized alternative to AES-GCM, and it protects traffic in TLS 1.3, QUIC, WireGuard and OpenSSH.
Both components were designed by Daniel J. Bernstein, and the combined construction is specified for internet protocols in RFC 8439. Its key advantage is fast, constant-time performance in pure software, which matters on devices without hardware acceleration for AES.
How ChaCha20-Poly1305 encrypts and authenticates
ChaCha20-Poly1305 takes a 256-bit key, a 96-bit nonce, the plaintext and optional associated data, and produces ciphertext plus a 128-bit authentication tag. Decryption recomputes the tag and releases plaintext only when the tags match, so tampered messages are rejected as a whole.
ChaCha20 builds a 512-bit state from constants, the key, a 32-bit block counter and the nonce, then applies 20 rounds of add-rotate-XOR (ARX) operations. The output is a 64-byte keystream block that is XORed with the plaintext. Because it uses only additions, rotations and XORs, the cipher runs in constant time and avoids the cache-timing leaks that affect table-based AES implementations.
The combined construction follows a fixed sequence of steps, shown in the table below.
| Step | Operation | Purpose |
|---|---|---|
| 1 | Run ChaCha20 with counter 0 and keep 32 bytes | Derive a one-time Poly1305 key |
| 2 | Run ChaCha20 from counter 1 and XOR with the plaintext | Produce the ciphertext |
| 3 | Pad associated data and ciphertext, append their lengths | Build an unambiguous authenticator input |
| 4 | Compute Poly1305 over that input | Produce the 16-byte tag |
Poly1305 evaluates a polynomial over the prime field modulo 2^130 – 5. It is secure only when each key authenticates exactly one message, which is why the construction derives a fresh Poly1305 key from every key and nonce pair.
Key parameters and variants
The parameters of ChaCha20-Poly1305 are fixed by the specification, and each one sets a concrete operational limit. The table below lists them with their practical consequences.
| Parameter | Value | Practical consequence |
|---|---|---|
| Key size | 256 bits | No practical brute-force risk |
| Nonce size | 96 bits | Counters are safe; random nonces need care |
| Block counter | 32 bits | About 256 GiB per message |
| Tag size | 128 bits | Forgery probability is negligible per attempt |
| Rounds | 20 | Large margin over the best known attacks |
Several variants exist, and they are not interchangeable on the wire. XChaCha20-Poly1305 extends the nonce to 192 bits, which makes randomly generated nonces safe for very large message counts. The original construction used a 64-bit nonce and a 64-bit counter, and OpenSSH uses its own packet-length encryption scheme built from the same primitives.
| Variant | Nonce length | Typical use |
|---|---|---|
| IETF ChaCha20-Poly1305 | 96 bits | TLS 1.3, QUIC, WireGuard |
| XChaCha20-Poly1305 | 192 bits | File and message encryption with random nonces |
| Original construction | 64 bits | Early libraries and legacy protocols |
| OpenSSH variant | 64-bit sequence number | SSH transport encryption |
ChaCha20-Poly1305 compared with AES-GCM
ChaCha20-Poly1305 and AES-GCM offer equivalent security goals, and the practical choice depends mostly on hardware support. On processors with AES instructions, AES-GCM is usually faster; on processors without them, ChaCha20-Poly1305 is typically several times faster and safer against side channels.
The following comparison summarizes how the two AEAD algorithms differ in practice.
| Property | ChaCha20-Poly1305 | AES-GCM |
|---|---|---|
| Underlying cipher | Stream cipher based on ARX | Block cipher in counter mode |
| Software speed without acceleration | High and constant-time | Slow or timing-sensitive |
| Speed with hardware acceleration | Good | Usually faster |
| Nonce misuse impact | Catastrophic | Catastrophic |
| FIPS 140 approval | Not approved | Approved |
For this reason, TLS servers often honor the client preference: a phone without AES instructions requests ChaCha20-Poly1305, while a modern laptop chooses AES-GCM. Compliance matters too, because environments bound to FIPS-validated modules generally cannot use ChaCha20-Poly1305.
In TLS 1.3 the algorithm appears as the cipher suite TLS_CHACHA20_POLY1305_SHA256, and QUIC uses the same AEAD for packet protection together with ChaCha20 alone for header protection. WireGuard offers no cipher negotiation at all: every peer uses ChaCha20-Poly1305, which removes downgrade attacks by design. Libraries such as libsodium, BoringSSL and the standard libraries of Go and Rust provide audited implementations, so developers should call a vetted library instead of assembling the two primitives by hand. A homemade composition easily gets padding, length encoding or key derivation wrong.
Nonce reuse and other limitations
The most serious limitation is sensitivity to nonce reuse. Encrypting two messages with the same key and nonce produces the same keystream, which reveals the XOR of the plaintexts, and it reuses the one-time Poly1305 key, which lets an attacker forge valid tags.
The table below lists the typical mistakes and how experienced implementers avoid them.
| Mistake | Consequence | Remedy |
|---|---|---|
| Random 96-bit nonces at high volume | Growing collision probability | Use counters or XChaCha20-Poly1305 |
| Releasing plaintext before tag check | Attackers exploit unverified data | Verify the tag first, then decrypt |
| Non-constant-time tag comparison | Timing leak enables forgery | Use the library comparison routine |
| Assuming key commitment | Partitioning attacks in some protocols | Add a key-committing step where needed |
ChaCha20-Poly1305 is not key-committing: a ciphertext can be crafted to decrypt validly under two different keys. This rarely matters for transport encryption but becomes relevant in multi-recipient or password-based designs. Like every symmetric scheme, it also depends on sound key exchange and key management.
In everyday language
ChaCha20-Poly1305 does two jobs at once. It scrambles a message so outsiders cannot read it. It also attaches a tamper seal that breaks if anyone changes even one letter.
Picture a locked envelope with a wax seal. The lock keeps the letter private, and the seal shows whether someone opened it. The key point is the seal: a damaged seal means the receiver throws the letter away. The method is popular because it works quickly on cheap phones and small devices.
Seen in the real world
A logistics company connects 400 delivery scanners to its warehouse servers over a WireGuard VPN. The scanners use low-cost ARM processors without AES instructions, and earlier tests with an AES-based VPN drained batteries noticeably during long shifts.
WireGuard uses ChaCha20-Poly1305 for every packet, with a 64-bit counter as the nonce, so nonces never repeat within a session. Keys rotate automatically about every two minutes. Any packet altered in transit fails the Poly1305 check and is dropped silently.
After the rollout, the IT team measured lower CPU load on the scanners and stable throughput for inventory uploads. Penetration testers who replayed and modified captured packets saw every attempt rejected, which confirmed integrity protection end to end.