ChaCha20-Poly1305
Encrypt with ChaCha20-Poly1305, XChaCha20-Poly1305 or their reduced-round forms.
import os
from oxcrypto.aead.chacha20poly1305 import CHACHA20_POLY1305
key = CHACHA20_POLY1305.XCHACHA20.generate()
nonce = os.urandom(24)
sealed = key.encrypt(nonce, b"message", associated_data=b"header")
plaintext = key.decrypt(nonce, sealed, associated_data=b"header")Variants: CHACHA20, CHACHA12, CHACHA8, XCHACHA20, XCHACHA12, XCHACHA8.
ChaCha variants use a 12-byte nonce. XChaCha variants use a 24-byte nonce, which is large enough to pick at random. All keys are 32 bytes.
| Standard | RFC 8439 (Informational, IRTF CFRG) for ChaCha20-Poly1305. XChaCha20-Poly1305 follows draft-irtf-cfrg-xchacha (expired draft). The 8- and 12-round forms are not standardized. |
| Crate | chacha20poly1305 0.11.0 |
| Maturity | Stable release. No published audit of 0.11; NCC Group published an audit of chacha20poly1305 0.7 in 2020. |
| MSRV | Builds with Rust 1.88. |
| Zeroization | chacha20poly1305, chacha20 and poly1305 with zeroize are written to wipe the stored key, the ChaCha state and the one-time Poly1305 key and state. oxcrypto has not verified this independently. |
| Experimental | Reduced-round variants (CHACHA8, CHACHA12, XCHACHA8, XCHACHA12) |
| Test vectors | Wycheproof chacha20_poly1305_test.json and xchacha20_poly1305_test.json; reduced-round variants are round-trip tested only |