ChaCha20-Poly1305
ARX stream cipher with a one-time Poly1305 MAC; fast and constant-time in software
Overview
ChaCha20-Poly1305 pairs the ChaCha20 stream cipher with the Poly1305 one-time authenticator, as specified in RFC 8439. XChaCha20-Poly1305 extends the nonce to 192 bits so random nonces can be used safely.
ChaCha20 is a 20-round add-rotate-XOR stream cipher derived from Salsa20; it uses only 32-bit additions, rotations and XORs, so it runs quickly and in constant time on processors without AES hardware. For each message, the first ChaCha20 block under the key and nonce yields a one-time Poly1305 key, and the remaining keystream encrypts the plaintext. Poly1305 then authenticates the associated data and ciphertext.
The construction is used in TLS 1.3, QUIC, SSH, WireGuard and many messaging protocols. XChaCha20-Poly1305 first applies HChaCha20 to the key and the first 128 bits of a 192-bit nonce to derive a subkey, then runs the standard construction with the remaining nonce bits. NextSSL provides both variants.
History
2015–2018ChaCha20-Poly1305 published
Specified in RFC 8439
How it works
- Generate the Poly1305 one-time key from ChaCha20 block 0 under the key and nonce.
- Encrypt the plaintext by XOR with ChaCha20 keystream from block 1 onward.
- Compute Poly1305 over the padded associated data, padded ciphertext and their lengths.
- For XChaCha20, first derive a subkey with HChaCha20 from the key and the first 16 nonce bytes.
Security notes
Nonce reuse leaks plaintext XORs and the Poly1305 key, enabling forgeries. The 96-bit nonce of the IETF variant should be a counter or otherwise unique; XChaCha20's 192-bit nonce makes random nonces safe in practice.
Typical uses
Variants in NextSSL
2| Algorithm | Tier | Sizes (bytes) | Standards | API |
|---|---|---|---|---|
| XChaCha20-Poly1305 xchacha20-poly1305 |
safe | key 32 · nonce 24 · tag 16 | draft-irtf-cfrg-xchacha-03 | safe |
| ChaCha20-Poly1305 chacha20-poly1305 |
standard | key 32 · nonce 12 · tag 16 | RFC 8439 | safe |
Frequently asked questions
Which ChaCha20-Poly1305 variants does NextSSL include?
NextSSL registers 2 ChaCha20-Poly1305 variants: xchacha20-poly1305, chacha20-poly1305.