← Cryptography guide

K030 / Cipher modes and AEAD

ChaCha20-Poly1305

ChaCha20-Poly1305 AEAD · Survey date 2026-12-05

ChaCha20-Poly1305 is an authenticated encryption algorithm supporting associated data (AEAD).

CRYPTOGRAPHY LAB / K030

Cryptography Lab · ChaCha20-Poly1305

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Limited implementation

ChaCha20-Poly1305 (empty AAD, 128-bit tag)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
ChaCha20-Poly1305 is an authenticated encryption algorithm supporting associated data (AEAD). Source document ↗
Classification and reversibility
Classified as AEAD; a key holder can decrypt. Source document ↗
Key or secret requirements
The 256-bit secret key is the only secret input and must remain confidential. Source document ↗
Operating principle and structure
Combines the ChaCha20 stream cipher and Poly1305 MAC in an encrypt-then-MAC construction; verifies the tag before decryption. Source document ↗
Key size, block size and parameters
Inputs are a 256-bit key, 96-bit nonce, arbitrary-length AAD and message. Source document ↗
Security strength and recommendation
Widely used and deployed; described in the survey as required in TLS implementations, but not NIST-approved. Source document ↗
Known attacks and vulnerabilities
Nonce reuse destroys confidentiality and authentication; nonces must be unique per key. Source document ↗
Standards and certification
Standardized in IETF RFC 8439. Source document ↗
Typical uses
Used in IETF protocols such as TLS, described by the survey as a required implementation. Source document ↗
Implementations, libraries and tools
Available through the ChaCha20Poly1305 class in Python's cryptography library. Source document ↗
Decryption or decoding
Decrypt only after verifying the authentication tag with the same key, nonce and AAD. Source document ↗
Advantages
High performance on modern CPUs and suitable for large streams. Source document ↗
Limitations and cautions
Never reuse a nonce with the same key. Source document ↗
Distinguishing encryption, encoding and hashing
AEAD provides both encryption and authentication, distinct from simple encoding and hashing. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Supply plaintext and AAD to ChaCha20-Poly1305 with a 256-bit key and 96-bit nonce to obtain ciphertext and a tag. Verify using the same key, nonce, AAD and tag during decryption before obtaining plaintext. Generate and manage actual keys and nonces securely.

Procedure

Encryption: prepare plaintext and AAD, generate a secure nonce, encrypt with the key and nonce, and store or transmit ciphertext and tag. Decryption: verify with the same key, nonce, AAD and tag, returning plaintext only on success. Base64 encoding and decoding are a separate layer from encryption and decryption.

Scenario

Used in protocols such as TLS and SSH, mobile and embedded PSA Crypto, and message or file protection. Handle the nonce and tag together during transmission; the receiver processes data only after tag verification.

Pitfalls and alternatives

Avoid nonce reuse and guarantee uniqueness per key. Beware missing or altered tags, mixing nonstandard nonce-length variants, and mistaking encoding for encryption. Use a vetted RFC 8439 AEAD library and discard plaintext on tag verification failure.

Diagram source ↗

References