XChaCha20-Poly1305
ARX stream cipher with a one-time Poly1305 MAC; fast and constant-time in software
About XChaCha20-Poly1305
XChaCha20-Poly1305 is one of 2 ChaCha20-Poly1305 variants in the NextSSL registry, an authenticated encryption (AEAD) scheme. It uses a 32-byte (256-bit) key, a 24-byte nonce and a 16-byte (128-bit) authentication tag. Its registry entry cites draft-irtf-cfrg-xchacha-03. It is also known as xchacha20poly1305. NextSSL lists it in the safe tier and exposes it through the safe API.
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
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| key | 32 | Secret key |
| nonce | 24 | Nonce / IV |
| tag | 16 | Authentication tag |
Use it
from nextssl_demo import NextSSL
ns = NextSSL() # safe API: safe and standard tiers
key, nonce = ns.random(32), ns.random(24)
ct = ns.call("aead_seal", "xchacha20-poly1305", None, key, nonce, b"header", b"secret")[0] # ct || tag
pt = ns.call("aead_open", "xchacha20-poly1305", None, key, nonce, b"header", ct)[0]
nextssl_aead_seal("xchacha20-poly1305", NULL, key, nonce, aad, pt, out); /* writes ct || tag */
nextssl_aead_open("xchacha20-poly1305", NULL, key, nonce, aad, ct, out);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_aead_in(reg::all(), Policy::Safe, "xchacha20-poly1305", &Params::new())?;
let ct = alg.seal(&key, &nonce, b"header", b"secret")?;
let pt = alg.open(&key, &nonce, b"header", &ct)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Other ChaCha20-Poly1305 variants
1Similar names
Looking for something else?More authenticated encryption
All 392Frequently asked questions
What is XChaCha20-Poly1305?
XChaCha20-Poly1305 is an AEAD in the ChaCha20-Poly1305 family. ChaCha20-Poly1305 pairs the ChaCha20 stream cipher with the Poly1305 one-time authenticator, as specified in RFC 8439. It is also known as xchacha20poly1305.
What are the XChaCha20-Poly1305 sizes?
In NextSSL, XChaCha20-Poly1305 uses: key 32 bytes, nonce 24 bytes, tag 16 bytes.
Who designed XChaCha20-Poly1305 and when?
XChaCha20-Poly1305 belongs to the ChaCha20-Poly1305 family, first published in 2015 by Daniel J. Bernstein (ChaCha20, Poly1305); construction by Adam Langley and Yoav Nir (RFC). Its origin: RFC 8439 (obsoletes RFC 7539); draft-irtf-cfrg-xchacha.
Which standards define XChaCha20-Poly1305?
XChaCha20-Poly1305 is referenced by draft-irtf-cfrg-xchacha-03.
Is XChaCha20-Poly1305 safe to use?
XChaCha20-Poly1305 is in the safe tier. Modern and recommended. The default choice for new designs. It can be called from the safe API.
What other ChaCha20-Poly1305 variants are there?
NextSSL also registers chacha20-poly1305 in the ChaCha20-Poly1305 family.