ChaCha20-Poly1305 is an authenticated-encryption construction that combines ChaCha20, a stream cipher, with Poly1305, a message authentication code. It hides plaintext and detects tampering with ciphertext or associated data. section 4.5.3
Its main flow is:
- ChaCha20 uses a 256-bit key, a 12-byte nonce, and a counter to generate a keystream. section 4.5.3
- XORing the keystream with plaintext produces ciphertext; repeating the operation with ciphertext recovers plaintext. section 4.5.3
- Poly1305 authenticates the ciphertext and associated data, using keys derived through ChaCha20. section 4.5.3
The nonce warning
Never reuse a nonce with the same key: reuse exposes the XOR of two plaintexts and can break authentication. Widely adopted protocols include OpenSSH, TLS, and Noise. section 4.5.3 section 4.7
Figure 4.23 ChaCha20-Poly1305 works by using ChaCha20 to encrypt the plaintext and to derive the keys required by the Poly1305 MAC. Poly1305 is then used to authenticate the ciphertext as well as the associated data.
A diagram connects ChaCha20 encryption and key derivation with Poly1305 authentication of ciphertext and associated data. section 4.5.3
