Fact-checked by Grok 2 weeks ago

ChaCha20-Poly1305

ChaCha20-Poly1305 is an authenticated encryption with associated data (AEAD) algorithm that combines the ChaCha20 stream cipher for confidentiality with the Poly1305 authenticator for integrity and authenticity protection, using a 256-bit key and a 96-bit nonce to process up to 2^36 - 1 bytes of plaintext and associated data. It operates by generating a keystream via ChaCha20 in counter mode, which is XORed with the plaintext to produce ciphertext, while Poly1305 computes a 128-bit tag over the ciphertext, associated data, and additional metadata using a one-time key derived from the first block of ChaCha20 output. Developed by cryptographer Daniel J. Bernstein, ChaCha20 is a variant of the Salsa20 stream cipher family, featuring 20 rounds of quarter-round functions to enhance diffusion and security while prioritizing software performance on general-purpose processors, achieving 256-bit security against known attacks. Poly1305, also designed by Bernstein, is a high-speed, one-time message authentication code that processes input in 16-byte blocks using a 256-bit key (split into a clamped multiplier "r" and additive "s" components), providing strong unforgeability with a forgery probability bounded by approximately 8⌈L/16⌉ / 2^106 for messages up to L bytes when used with a unique key. The combined mode, formalized in RFC 7539 by David McGrew and Kenneth G. Paterson in 2015, derives the Poly1305 key from ChaCha20 to ensure nonce uniqueness and avoid key separation issues, with a proven security reduction showing it meets IND-CPA and INT-CTXT notions under the assumptions that ChaCha20 is a pseudorandom function and Poly1305 is almost Δ-universal. This construction addresses limitations of AES-based ciphers, such as vulnerability to timing attacks and slower software implementations on non-AES-optimized hardware, offering superior performance in software (e.g., up to 4-8 cycles per byte on modern CPUs) without relying on specialized instructions. It has seen widespread adoption in secure protocols, including as a in (TLS) and Datagram TLS (DTLS) per RFC 7905, enabling suites like TLS_CHACHA20_POLY1305_SHA256 for mobile and embedded devices. Additional uses include the (CMS) in RFC 8103, the WireGuard VPN protocol, and implementations in libraries like OpenSSL and BoringSSL, reflecting its role as a modern alternative to AES-GCM in resource-constrained environments.

Background

ChaCha20 Stream Cipher

ChaCha20 is a high-speed designed for secure and efficient generation of pseudorandom keystreams from a 256-bit key, a 96-bit , and a 32-bit block counter. It operates by producing 64-byte blocks of keystream, which are then XORed with to yield , making it suitable for encrypting data streams of arbitrary length. The cipher's core strength lies in its simple, parallelizable structure based on addition, XOR, and rotation operations on 32-bit words, all performed modulo $2^{32}. The internal state of ChaCha20 is represented as a 4×4 matrix of 32-bit little-endian integers, totaling 16 words or 64 bytes. This state is initialized as follows:
  • Positions 0 to 3 (first row): Fixed constants "expand 32-byte k", encoded as the 32-bit values 0x61707865, 0x3320646e, 0x79622d32, and 0x6b206574 in little-endian byte order.
  • Positions 4 to 11 (second and third rows): The 256-bit , split into eight 32-bit little-endian words.
  • Position 12 (fourth row, first column): The 32-bit counter, initialized to 0 for the first block and incremented by 1 for each subsequent block.
  • Positions 13 to 15 (remaining fourth row): The 96-bit , divided into three 32-bit little-endian words.
This initialization ensures that each keystream block is uniquely determined by the key, nonce, and counter, preventing reuse vulnerabilities when the nonce is not repeated for the same key. The fundamental building block of ChaCha20 is the quarter-round function, which operates on four 32-bit words labeled a, b, c, and d, updating them in place through a sequence of additions, XORs, and left rotations. The operations are: \begin{align*} a &\leftarrow ((a + b) \mod 2^{32}); \\ d &\leftarrow ((d \oplus a) <<< 16); \\ c &\leftarrow ((c + d) \mod 2^{32}); \\ b &\leftarrow ((b \oplus c) <<< 12); \\ a &\leftarrow ((a + b) \mod 2^{32}); \\ d &\leftarrow ((d \oplus a) <<< 8); \\ c &\leftarrow ((c + d) \mod 2^{32}); \\ b &\leftarrow ((b \oplus c) <<< 7); \end{align*} where <<< denotes left rotation by the specified number of bits. Each quarter-round mixes the inputs nonlinearly, with every word updated twice to enhance across the . The core ChaCha20 function processes the initialized 4×4 through 20 rounds, grouped into 10 double rounds for balanced mixing. Each double round consists of four column quarter-rounds followed by four diagonal quarter-rounds. The column rounds apply the quarter-round to indices (0,4,8,12), (1,5,9,13), (2,6,10,14), and (3,7,11,15), operating vertically on the matrix columns. The diagonal rounds then apply it to (0,5,10,15), (1,6,11,12), (2,7,8,13), and (3,4,9,14), mixing across the matrix diagonals. After all 20 rounds, the final is computed by adding (modulo $2^{32}) each word of the processed to the corresponding word of the initial input . The resulting 16 words are serialized into a 64-byte keystream block by writing them in row-major order, with each word in little-endian byte order. To generate the full keystream for , ChaCha20 processes the in 64-byte blocks. For each block i, the in position 12 is set to i, the state is reinitialized, the core function is run to produce a 64-byte keystream segment, and this segment is XORed with the corresponding bytes to form . If the final block is partial, only the necessary bytes of the keystream are used, and the is incremented sequentially to ensure continuous, non-repeating output up to $2^{64} bytes per key-nonce pair. ChaCha20 evolved from the earlier Salsa20 , also designed by , by refining the quarter-round function with rotations of 16, 12, 8, and 7 bits instead of Salsa20's 7, 9, 13, and 18 bits, which improves bit diffusion per round while maintaining the same 20-round structure. In the ChaCha20-Poly1305 scheme, the keystream from ChaCha20 is used for both message encryption and Poly1305 key derivation.

Poly1305 Message Authentication Code

Poly1305 is a one-time (MAC) designed by , operating over the \mathbb{Z}/p\mathbb{Z} where p = 2^{130} - 5. It authenticates an arbitrary-length message using a 256-bit one-time key, split into a 128-bit component r and a 128-bit component s, with r clamped to clear the top four bits of bytes 3, 7, 11, and 15 and the bottom two bits of bytes 4, 8, and 12 in little-endian representation, ensuring r is divisible by 4 and bounded to avoid overflow issues in . In the context of ChaCha20-Poly1305, this one-time key is derived from the 256-bit symmetric key and the 96-bit nonce (padded with 32 zero bits to 128 bits) to guarantee uniqueness per message. The message bits are followed by a single '1' bit and then the minimal number of '0' bits necessary to make the total length a multiple of 128 bits. This padded bit string is then divided into q little-endian 128-bit (16-byte) blocks c_1, c_2, \dots, c_q, where each c_i is interpreted as an satisfying $0 \leq c_i < 2^{128}. The process initializes an accumulator h = 0 and iteratively computes the polynomial hash using : \begin{align*} &h \leftarrow (h \cdot r + c_1) \mod p, \\ &h \leftarrow (h \cdot r + c_2) \mod p, \\ &\vdots \\ &h \leftarrow (h \cdot r + c_q) \mod p. \end{align*} This running product-sum evaluates the \sum_{i=1}^q c_i r^{q-i} \mod p. All arithmetic is performed in \mathbb{Z}/p\mathbb{Z}, leveraging the prime p = 2^{130} - 5 for efficient after , as the sparse form allows of multiples of 5 to handle carries beyond $2^{130}. Implementations typically represent elements as four or five 64-bit words (covering up to 256 or 320 bits for intermediate products), performing schoolbook followed by carry propagation and modular ; for example, the product of two 130-bit numbers yields up to 260 bits, reduced by subtracting $5 \cdot 2^{130k} for appropriate k based on the high bits. The final 128-bit tag is computed as the least significant 128 bits of h + s, serialized in little-endian byte order: \text{tag} = (h + s) \mod 2^{128}. Since h < p < 2^{130} and s < 2^{128}, the sum h + s < 2^{131}, so extracting the low 128 bits discards any high-bit carry without further modular reduction. Poly1305 requires the key (r, s) to be used only once per message; key reuse across messages enables existential forgery attacks with probability approaching 1 after sufficiently many queries.

Design and Operation

AEAD Construction

ChaCha20-Poly1305 is an with Associated Data (AEAD) scheme that provides confidentiality for the and integrity for both the (via the ) and the associated data (AD). In this construction, the AD is but not encrypted, ensuring that any tampering with the AD or can be detected through the . The high-level architecture combines the for encryption and key derivation with the for protection. is used to generate a keystream that both encrypts the to produce the and derives the one-time key for Poly1305. Poly1305 then computes an tag over the AD, the , and their lengths to verify upon decryption. The scheme employs a 256-bit secret key and a 96-bit (12-byte) , with the tag being 128 bits long. The must be unique for each key usage to maintain . In the process, the Poly1305 key is derived as the first 256 bits (32 bytes) of the ChaCha20 keystream generated with the input key, , and an initial value of 0. The is then encrypted using the subsequent ChaCha20 keystream, starting from value 1, by XORing it with the to yield the of equal length. Finally, the Poly1305 tag is computed over the concatenated input consisting of the AD padded to a multiple of 16 bytes (with up to 15 zero bytes), the padded similarly, the 64-bit little-endian representing the AD length in bytes, and the 64-bit little-endian representing the length in bytes. Empty messages or AD are handled naturally through the padding mechanism: an empty AD or ciphertext results in zero-length padded blocks followed directly by the length fields, ensuring the input remains a valid multiple of 16 bytes for Poly1305 processing.

Encryption and Authentication Process

The ChaCha20-Poly1305 authenticated encryption with associated data (AEAD) construction processes inputs consisting of a 256-bit secret key, a 96-bit nonce, an arbitrary-length plaintext message m, and optional associated data a (also arbitrary length). The nonce must be unique for each encryption under the same key to ensure security. The process generates a ciphertext c of the same length as m, along with a 128-bit authentication tag t, such that the output is the nonce concatenated with c and t (i.e., nonce || c || t). This construction ensures both confidentiality of m and integrity/authenticity of both m and a. The encryption and authentication proceed in four main steps. First, a one-time key for Poly1305 is derived by computing the initial with the input , the 96-bit concatenated with a 32-bit counter of 0 (little-endian) to form the 128-bit , producing a 512-bit (64-byte) ChaCha20 output ; the first 128 bits (16 bytes, little-endian) form the Poly1305 parameter r, the next 128 bits form the parameter s, and the remaining 256 bits are discarded. This derived 256-bit one-time (denoted as otk = r || s) is used solely for the Poly1305 computation in this invocation and must not be reused. Second, the m is encrypted by generating a keystream via ChaCha20, starting with the same and but with an initial block of 1 (i.e., 96-bit nonce concatenated with 32-bit counter value 1, little-endian). The keystream is produced in 512-bit blocks as needed, and the is performed by XORing each byte of m with the corresponding byte of the keystream, yielding the c of identical length to m. The maximum supported length for m is $2^{32} - 1 64-byte blocks (approximately 256 ), ensuring the counter does not overflow during a single encryption. Third, the associated data a and ciphertext c are prepared for authentication by constructing a message for Poly1305. This involves concatenating a with zero-padding (if necessary) to reach a multiple of 16 bytes, followed by c with similar zero-padding. Padding is added only if the length is not already a multiple of 16; specifically, append $16 - (\ell \mod 16) zero bytes, where \ell is the length of a or c in bytes (up to 15 bytes maximum per pad). For example, if \ell = 17, append 15 zero bytes to make 32 bytes. The resulting padded string is then fed into Poly1305 along with the derived otk to compute an intermediate hash. Finally, the Poly1305 input is completed by appending the 64-bit length of a (in bytes, little-endian) followed by the 64-bit length of c (also little-endian, matching the length of m). Poly1305 then outputs the 128-bit authentication tag t based on this full input and otk. The complete AEAD output is the nonce, ciphertext c, and tag t, with the nonce typically transmitted in the clear alongside them in protocols. The maximum length for a is $2^{64} - 1 bytes. For clarity, the process can be expressed in as follows:
function chacha20_poly1305_encrypt([key](/page/Key), [nonce](/page/Nonce), m, a):
    # Step 1: Derive Poly1305 one-time key
    block0 = chacha20_block([key](/page/Key), [nonce](/page/Nonce) || 0x00000000)  # 512-bit block, counter=0
    r = block0[0:128]  # First 16 bytes, little-endian
    s = block0[128:256]  # Next 16 bytes, little-endian
    otk = r || s  # 256-bit key

    # Step 2: Encrypt [plaintext](/page/Plaintext)
    c = xor(m, chacha20_keystream([key](/page/Key), [nonce](/page/Nonce) || 0x00000001, len(m)))  # Start with counter=1

    # Step 3 & 4: Prepare Poly1305 message with padding and lengths
    pad16(x):
        if len(x) % 16 == 0:
            return empty
        else:
            return zeros(16 - (len(x) % 16))
    
    mac_input = a || pad16(a) || c || pad16(c) || len64_le(len(a)) || len64_le(len(c))
    t = poly1305_mac(mac_input, otk)  # 128-bit tag

    return [nonce](/page/Nonce) || c || t
Here, chacha20_block computes one 512-bit ChaCha20 using the provided 128-bit ( || ), chacha20_keystream generates the using the ( || initial ) and produces subsequent blocks by incrementing the , len64_le converts a 64-bit length to 8 little-endian bytes, and poly1305_mac computes the Poly1305 tag. All operations assume byte-level processing in little-endian format where specified.

Key Derivation and Nonce Usage

ChaCha20-Poly1305 employs a single 256-bit symmetric , which is used directly as the input for the ChaCha20 without further derivation or expansion. This initializes the ChaCha20 state matrix alongside a set of constant values and the components, enabling the generation of a keystream for both and derivation. The in ChaCha20-Poly1305 is a 96-bit value, structured as three 32-bit little-endian integers, which is concatenated with a 32-bit counter (little-endian) to form the 128-bit input for ChaCha20's . The counter starts at zero for the first 64-byte of and increments by one for each subsequent , allowing up to 2^32 blocks (approximately 256 ) per (, ) pair before overflow risks arise. For handling multiple messages within a single session, the counter manages block-wise processing, but the 96-bit itself must be unique for each distinct invocation under the same to prevent compromises. The Poly1305 authentication key is derived by applying the ChaCha20 function once with the 256-bit symmetric , the same 96-bit , and the set to zero; the resulting 32-byte (256-bit) output serves as the Poly1305 , with the first 16 bytes clamped (clearing four specific bits) to form the "r" parameter and the next 16 bytes used directly as the "s" parameter. This one-time derivation ensures the Poly1305 is tightly bound to the session's symmetric and setup. Nonce reuse under the same leads to identical keystreams and Poly1305 keys across messages, enabling attackers to recover the XOR of plaintexts and forge authentication tags by exploiting the repeated components. To mitigate this, the must remain unique per usage, drawn from a 2^96 possibility space via methods such as sequential or pseudorandom generation using linear feedback shift registers (LFSRs), avoiding full randomness where predictability suffices for uniqueness.

History

Development Origins

The development of ChaCha20 originated from Daniel J. Bernstein's efforts to create secure, high-performance stream ciphers as alternatives to , which suffered from known insecurities, and , which was slower in software due to its reliance on table lookups vulnerable to cache-timing attacks. In 2005, Bernstein designed the Salsa20 family of 256-bit stream ciphers, emphasizing speed across platforms without complex operations like S-boxes, achieving encryption rates faster than (e.g., 3.93 cycles per byte on compared to 9.2 for a 10-round AES variant). Salsa20 was submitted to the eSTREAM project, the ECRYPT Stream Cipher Project, and advanced to the third round without changes, establishing it as a recommended option for both general and speed-critical applications. Building on Salsa20, introduced ChaCha in 2008 as an improved variant under the Snuffle 2008 suite, with modifications to the quarter-round function enhancing diffusion per round while preserving computational efficiency. 20, the 20-round configuration, was specifically proposed for eSTREAM in 2008, offering stronger security bounds against differential and compared to reduced-round Salsa20 versions, yet remaining among the fastest 256-bit ciphers in software implementations. This evolution addressed the need for robust stream ciphers suitable for resource-constrained environments lacking . In parallel, developed Poly1305 in 2005 as a high-speed , computing 16-byte authenticators for variable-length messages using a one-time hash over the prime 2^{130} - 5 (a 130-bit prime field), with employed solely for deriving a one-time key from a . Motivated by the limitations of existing MACs—such as slow key setup and poor scalability—Poly1305 prioritized low overhead, parallelizability, and key agility, achieving speeds under 3.1 cycles per byte plus a fixed cost on processors, while providing security tightly bound to with a minimal gap for up to 2^64 messages. Its design avoided precomputation and encumbrances, making it versatile for high-volume in software. The motivation for combining ChaCha20 (or its Salsa20 predecessors) with Poly1305 into an AEAD construction stemmed from the growing requirement for integrated and in efficiency-focused applications, particularly on devices without hardware support, where traditional modes incurred high and exposure to timing side-channels via behavior. This pairing enabled constant-time operations and superior throughput in , circumventing 's pitfalls while supporting associated data without additional . Initial proposals featured Poly1305 in Bernstein's 2005 Fast Software Encryption paper and ChaCha20 in the 2008 eSTREAM submission. Prior to formal specifications, early informal integrations emerged in the 2010s, exemplified by the Networking and Cryptography library (NaCl), which from 2009 used XSalsa20—a Salsa20 extension—with Poly1305 for authenticated secret-box encryption, demonstrating the viability of such stream-cipher-MAC pairings in practical high-security libraries.

Standardization and Early Adoption

The ChaCha20-Poly1305 authenticated encryption with associated data (AEAD) construction was formally specified in 2015 through RFC 7539, authored by Yoav Nir and Adam Langley, which defines its use within IETF protocols including IPsec and TLS. This RFC outlines the precise mechanics of combining the ChaCha20 stream cipher with the Poly1305 authenticator to provide confidentiality, integrity, and authenticity for messages, establishing a standardized mode suitable for network protocols. It was first integrated into TLS 1.2 and DTLS 1.2 via RFC 7905 in 2016, where it serves as a alongside AES-GCM. ChaCha20-Poly1305 was subsequently included in the (TLS) Protocol Version 1.3, as specified in RFC 8446 published in 2018. This inclusion enhanced TLS's cryptographic agility by offering an alternative to AES-based ciphers, particularly beneficial for environments without for . Early adoption of ChaCha20-Poly1305 occurred in Google's experimental implementations for protocols like TLS around to improve and security over UDP-based connections. Similarly, the VPN protocol, released in 2016, incorporated ChaCha20-Poly1305 as its core AEAD mechanism, leveraging RFC 7539 for symmetric encryption and authentication to achieve high-speed, secure tunneling. Further standardization efforts include its specification within the Noise Protocol Framework, which uses ChaCha20-Poly1305 as a default cipher option for building secure communication protocols based on Diffie-Hellman key agreement. In 2025, an IETF draft updated the (SSH) protocol to better integrate ChaCha20-Poly1305 as an cipher, addressing packet handling and key derivation for improved efficiency. Discussions in 2024 highlighted its non-compliance with due to the absence of NIST-approved stream ciphers, positioning it as a secure alternative for non-FIPS environments despite its exclusion from validated modules.

Variants

Extended Nonce Variants

XChaCha20-Poly1305 is an extended-nonce variant of the ChaCha20-Poly1305 scheme, designed to support a larger size of 192 bits (24 bytes) to reduce the risk of reuse in long-lived scenarios. The structure divides into a 128-bit (16-byte) for derivation and a 64-bit (8-byte) suffix serving as the input for the core process. This construction derives from the original ChaCha20 but incorporates a known as HChaCha20 to transform the input and into a subkey suitable for the standard 96-bit mechanism. HChaCha20 operates by treating the first block of the ChaCha20 state as a hash-like function: it initializes the state with the 256-bit input , the 128-bit prefix, and fixed constants, then performs 20 rounds of ChaCha quarter-round operations. The resulting 512-bit state yields the first 256 bits as the subkey and the next 128 bits as a subnonce, effectively producing a deterministic mapping without producing a full keystream. With the subkey and subnonce in hand, the encryption proceeds using the standard ChaCha20-Poly1305 process from 8439, where the 64-bit suffix is prefixed with four zero bytes to form a 96-bit nonce for the IETF . Poly1305 authentication is applied identically to the base construction, ensuring integrity over the and associated data. The primary benefit of this variant lies in its vastly expanded nonce space of $2^{192} possibilities, which allows for the safe use of randomly generated nonces even over extended periods or high-volume applications, with a collision probability remaining below 50% after up to $2^{96} messages under the same key. This mitigates the strict uniqueness requirements of the standard 96-bit nonce, making it particularly suitable for protocols where nonce management is challenging. The construction was initially specified by Frank Denis in 2015 as part of the libsodium cryptography library and the protocol version 2. It was proposed in an IETF informational draft (expired in 2020) and adopted in protocols such as for its VPN data packets, where it provides robust protection against reuse in dynamic network environments. Libsodium continues to implement it as a recommended AEAD primitive for scenarios requiring extended s. Salsa20-Poly1305 is an authenticated encryption with associated data (AEAD) construction that combines the 20-round Salsa20 stream cipher, developed by Daniel J. Bernstein in 2005, with the Poly1305 message authentication code. The design mirrors the structure of later AEAD schemes by using Salsa20 in counter mode to generate a keystream for encrypting the plaintext via XOR, while the initial keystream block serves as a one-time key for Poly1305 to authenticate the ciphertext and associated data. This pairing provides confidentiality and integrity but exhibits less diffusion per round than equivalent ChaCha-based constructions due to Salsa20's quarter-round function, which applies addition, XOR, and rotations in a sequence that updates each word only once per quarter round. A variant, XSalsa20-Poly1305, extends size to 192 bits to mitigate reuse risks in protocols with unpredictable nonce . It achieves this by first applying the 20-round Salsa20 core (dubbed HSalsa20 when used as a ) to the 256-bit and 192-bit , yielding a 256-bit subkey and a 64-bit derived ; Salsa20/20 then operates on this subkey with the derived for the main keystream and Poly1305 derivation. This was employed in the Networking and Cryptography library (NaCl) for its crypto_secretbox primitive, enabling secure symmetric encryption in early high-speed software implementations. Salsa20 and its variants differ from ChaCha20 primarily in their core rotation constants and quarter-round mechanics: Salsa20 rotates by 7, 9, 13, and 18 bits, while uses 16, 12, 8, and 7 bits with a restructured to double the updates per word per quarter round, enhancing mixing efficiency. These Salsa-based AEAD schemes saw historical adoption in libraries like NaCl but have trended toward deprecation in favor of ChaCha equivalents, as the latter offer superior and more uniform performance across hardware platforms.

Reduced-Round Variants

Reduced-round variants of ChaCha20-Poly1305 replace the full 20-round with ChaCha12 or ChaCha8, which use 12 or 8 rounds, respectively, to achieve higher performance at the cost of a reduced margin. These variants maintain the same overall structure, including the quarter-round function and matrix operations, but apply fewer iterations of the round function, where each round consists of four column quarter-rounds followed by four diagonal quarter-rounds; for example, ChaCha12 performs 12 such rounds (equivalent to 6 double rounds), compared to 20 rounds (10 double rounds) in the standard version. Security analyses indicate that while ChaCha8 has known distinguishers from differential cryptanalysis due to exploitable biases after limited rounds, no practical key recovery attacks are known. ChaCha12 provides a more robust margin and is recommended as the minimum for 256-bit key security under current differential attack models. Specifically, ChaCha12 resists known differential-linear distinguishers, offering approximately 5 rounds of margin. These variants find application in resource-constrained environments, such as embedded systems and hardware implementations, where the computational overhead of 20 rounds impacts efficiency, enabling faster without adopting full-strength . Despite their performance advantages, reduced-round ChaCha-Poly1305 constructions have not achieved in major protocols like TLS or , remaining primarily in contexts, including performance benchmarks within the eBACS/eBASC framework that evaluate their throughput on various platforms.

Applications

Use in Cryptographic Protocols

ChaCha20-Poly1305 is integrated as one of the standard with associated data (AEAD) cipher suites in (TLS) version 1.3, specifically under the identifier TLS_CHACHA20_POLY1305_SHA256, which combines ChaCha20 for , Poly1305 for , and SHA-256 for key derivation and certificate verification. This is particularly preferred in mobile environments, where devices often lack dedicated for -based alternatives, allowing ChaCha20-Poly1305 to deliver superior performance without relying on AES instructions. In , a modern VPN protocol, ChaCha20-Poly1305 serves as the default AEAD construction for encrypting data packets within tunnels, utilizing a 96-bit composed of a fixed and a 64-bit counter to ensure security across sessions. The protocol leverages an extended nonce variant, XChaCha20-Poly1305, specifically for cookie reply packets to mitigate denial-of-service attacks, enhancing overall nonce management while maintaining the core ChaCha20-Poly1305 mechanism for primary traffic. For (SSH), an (IETF) draft published in 2025 specifies the [email protected] , defining its use as an AEAD to provide both and integrity protection in SSH connections. This standardization addresses vulnerabilities like the attack, which exploits sequence number manipulation in certain SSH implementations, by incorporating stricter handling and integrity checks tailored to ChaCha20-Poly1305. In Internet Protocol Security (IPsec), ChaCha20-Poly1305 is supported for use in Encapsulating Security Payload (ESP) mode as defined in RFC 7634, enabling it as a combined AEAD algorithm for protecting IP packets with both confidentiality and authenticity. This integration allows IPsec implementations to employ ChaCha20-Poly1305 in place of AES-based modes, particularly beneficial in environments without AES hardware support. Beyond these, ChaCha20-Poly1305 is employed in HTTP/3 over QUIC, where it operates as a TLS 1.3 cipher suite to secure the UDP-based transport layer, ensuring low-latency encryption for web traffic. Regarding (FIPS), ChaCha20-Poly1305 remains non-compliant with requirements, as NIST has not approved stream ciphers like ChaCha20, limiting its use to approved block ciphers such as ; however, it has received validation in specific non-FIPS contexts through implementations in modules certified under broader cryptographic guidelines. Adoption of ChaCha20-Poly1305 has grown significantly within TLS 1.3 deployments, becoming one of the primary AEAD options and estimated to comprise around 20% of web traffic secured by the protocol as of 2025, driven by its efficiency on diverse hardware including mobile and embedded systems.

Software Implementations and Libraries

Libsodium serves as a primary reference implementation for ChaCha20-Poly1305, providing a constant-time authenticated encryption mode compliant with RFC 7539, along with the XChaCha20-Poly1305 variant for extended nonce support. This library is widely used for its portability across platforms and ease of integration in applications requiring secure symmetric cryptography. OpenSSL has included native support for ChaCha20-Poly1305 since version 1.1.0, released in 2016, enabling its use in TLS and other protocols through the EVP interface, with optimizations for where available. BoringSSL, Google's fork of , offers an optimized implementation tailored for server environments and is deployed in products like , emphasizing performance and security hardening. In C++, the Crypto++ library provides a comprehensive ChaCha20-Poly1305 implementation following the IETF standard, supporting both standalone and AEAD modes for developers building cryptographic tools. For Java, Bouncy Castle integrates ChaCha20-Poly1305 as an AEAD cipher, available since version 1.60, facilitating its use in enterprise applications and TLS stacks. Python's library exposes ChaCha20-Poly1305 through its high-level primitives, ensuring secure and idiomatic usage in scripts and frameworks. Hardware acceleration for ChaCha20-Poly1305 remains primarily software-based on and processors, leveraging vector instructions for efficiency. On ARMv8 architectures, ChaCha20-Poly1305 is implemented via optimized software using SIMD instructions, without dedicated . Recent developments include enhanced integration of ChaCha20-Poly1305 in version 9.5 and later, released in 2024, improving SSH protocol efficiency and compatibility for secure remote access.

Performance

Efficiency on Modern Hardware

ChaCha20-Poly1305 exhibits high computational efficiency on modern processors, achieving approximately 1.18 cycles per byte for the ChaCha20 component using AVX2 optimizations on Intel Skylake architectures, with the full AEAD construction reaching around 1.7 cycles per byte when combined with Poly1305. These metrics reflect 2025 benchmarks on CPUs such as and , where SIMD processes multiple blocks simultaneously, yielding throughputs exceeding 1 GB/s for larger inputs without relying on specialized hardware instructions. The scheme maintains minimal memory footprint, requiring only a 64-byte state for the ChaCha20 quarter-round operations, making it particularly suitable for resource-constrained IoT devices with limited RAM. This compact design avoids large lookup tables, reducing cache pressure and enabling efficient deployment on embedded systems. Although the core ChaCha20 quarter-round function is inherently serial due to its 20-round structure, the keystream generation operates on independent 64-byte blocks, allowing parallel computation across multiple blocks via SIMD instructions like AVX2 on x86 or NEON on ARM. Such optimizations close the gap to theoretical lower bounds, with Poly1305 achieving 0.51 cycles per byte on modern hardware. On mobile platforms like devices with processors, ChaCha20-Poly1305 demonstrates superior power efficiency compared to AES-based schemes lacking , as its ARX operations eliminate branchy table lookups that increase energy draw. Recent 2025 tests on ARM-based systems, such as AWS Graviton4, report throughputs of 280-895 MB/s for small inputs (100 bytes to 1 KB) during encryption, with higher rates for larger payloads. ChaCha20-Poly1305's symmetric design requires no key size increases to counter , preserving performance in quantum-resistant protocols. On , 2025 benchmarks indicate it outperforms AES-GCM by 50-60%, enhancing suitability for battery-powered and edge devices.

Comparisons with Other AEAD Schemes

ChaCha20-Poly1305 serves as a prominent alternative to AES-GCM in with associated data (AEAD) schemes, particularly valued for its software efficiency on hardware without specialized AES instructions. On platforms lacking AES-NI acceleration, such as older CPUs or embedded systems like the ZedBoard, ChaCha20-Poly1305 delivers approximately 1.5 times higher throughput than AES-GCM due to its ARX-based design optimized for constant-time software execution. In environments with AES-NI, however, AES-GCM surpasses ChaCha20-Poly1305, achieving 2-3 times greater speeds thanks to hardware-accelerated block operations. Furthermore, ChaCha20-Poly1305 exhibits stronger resistance to cache-timing attacks, as its operations avoid table lookups inherent in , reducing side-channel vulnerabilities in software implementations. Relative to AES-CCM, another block-cipher-based AEAD, ChaCha20-Poly1305 offers a simpler nonce management with its fixed 96-bit (12-byte) , eliminating the variable-length requirements (7-13 bytes) of AES-CCM that can complicate design. As a construction, it also bypasses the block padding needed in AES-CCM, where messages must align to 128-bit blocks, streamlining implementation in resource-constrained software environments. Representative throughput benchmarks on modern i9 processors illustrate these differences, based on OpenSSL evaluations for 16 KB blocks:
SchemeEncrypt/Decrypt Throughput (MB/s)Hardware Dependency
ChaCha20-Poly1305900–1,000Software-only
AES-GCM3,000–5,000AES-NI accelerated
These figures reflect multi-threaded performance on recent generations like the i9-11900K and i9-14900K, with AES-GCM benefiting significantly from vectorized instructions. In practice, ChaCha20-Poly1305 finds favor in and applications where is absent or matters, enabling robust without specialized silicon. AES-GCM, by contrast, dominates in data-center and contexts optimized for high-volume throughput via hardware support. A notable limitation of ChaCha20-Poly1305 is its fixed 128-bit authentication tag, lacking the configurable shorter options (e.g., 96–128 bits in AES-GCM or 4–16 bytes in AES-CCM) that allow reduced overhead in bandwidth-sensitive scenarios.

Security

Theoretical Security Analysis

ChaCha20-Poly1305 achieves IND-CCA2 security in the standard model, assuming that the ChaCha20 block function behaves as a pseudorandom function (PRF) and that Poly1305 functions as an ε-almost-Δ-universal hash, for nonce-respecting adversaries. This security encompasses both privacy (IND-CPA) and authenticity (INT-CTXT), with the adversary's advantage bounded by the PRF distinguishing advantage of ChaCha20 plus a term proportional to the number of queries times the Poly1305 universality parameter ε. The formal reduction proof, as detailed in the analysis accompanying the scheme's standardization, demonstrates that breaking the AEAD construction implies breaking one of the underlying primitives. A limitation arises from the bound due to the 32-bit in ChaCha20, which allows up to 2^{32} blocks per ; however, across multiple messages under the same , the scheme remains secure for approximately 2^{64} total blocks before the PRF security degrades via collisions in the keystream positions. For Poly1305, the forgery probability per tag, assuming a unique one-time derived via ChaCha20 for each , is bounded by ε ≈ 8 \lceil L/16 \rceil \times 2^{-106}, where L is the in bytes, providing roughly 106 bits of for typical sizes. The ChaCha20 core offers 256-bit against distinguishing attacks from a truly random , protecting against recovery up to that level under the PRF . As of 2025, no theoretical attacks have been discovered that violate these provable bounds for the full-round ChaCha20-Poly1305 construction. Recent analyses as of 2025 confirm no practical breaks for the full 20-round construction. While not a post-quantum —susceptible to halving the symmetric security to 128 bits—it is engineered for resistance to timing attacks through constant-time operations in reference implementations.

Practical Attacks and Mitigations

Reusing a nonce with the same key in ChaCha20-Poly1305 reveals the XOR of the corresponding plaintexts, as the keystream and Poly1305 authentication key become identical, thereby compromising both confidentiality and authenticity. This vulnerability enables plaintext recovery and tag forgery attacks, severely undermining the scheme's security guarantees. To mitigate nonce reuse, protocols must ensure unique nonces for each encryption under a given key, such as through counter-based generation or randomization mechanisms like those in TLS 1.3. Additionally, the XChaCha20 variant extends the nonce to 192 bits using a key derivation from the first 128 bits, providing practical nonce-misuse resistance and reducing collision risks in high-volume scenarios. The Terrapin attack, disclosed in 2023, exploits a prefix truncation vulnerability in the SSH protocol when using ChaCha20-Poly1305, allowing a man-in-the-middle adversary to delete messages during key exchange and degrade cryptographic protections, such as forcing weaker authentication algorithms. This breaks the integrity of the SSH channel without compromising confidentiality directly. As of 2025, mitigations include the Strict Key Exchange (strict-kex) protocol extension in SSH drafts, which enforces rigid message ordering and parsing to prevent truncation, along with disabling vulnerable ciphers like ChaCha20-Poly1305 in configurations where updates are unavailable. ChaCha20-Poly1305 implementations are susceptible to side-channel attacks, particularly electromagnetic (EM) and on devices, where adversaries can extract the full using with as few as 200 traces by targeting or manipulations. These attacks exploit variable-time operations in the ARX-based quarter rounds, potentially recovering the Poly1305 and enabling decryption or forgery. Countermeasures involve constant-time implementations, such as those using only additions, XORs, and fixed rotations without conditional branches, as recommended in the scheme's specification and realized in libraries like libsodium. Shuffling operations can further reduce leakage, though at a performance cost of up to 20 times slower execution. As of 2025, ChaCha20-Poly1305 lacks full certification, appearing only in non-approved modes (e.g., certificate-only) in validated modules, due to its status as a non-NIST-standardized . NIST recommends approved alternatives like AES-GCM for FIPS-compliant environments, though no cryptographic breaks have been found in ChaCha20-Poly1305 itself. No major implementation flaws leading to certification denial have been reported beyond general side-channel risks. In multi-user settings, ChaCha20-Poly1305 requires key separation across users to avoid collisions; a 2023 establishes security up to approximately 2^32 users under a d-repeating adversary model (where d bounds nonce repetitions per user), with forgery and key-recovery advantages remaining negligible below key-size limits. This bound supports practical deployments like TLS servers handling millions of connections without rekeying excessively. No full-round breaks exist for ChaCha20-Poly1305; the best known differential attacks target reduced rounds (e.g., 7 rounds of ChaCha) with complexities around 2^{190} operations and 2^{102} (as of 2025), far exceeding feasible computation and leaving the 20-round design secure. Recent 2025 analyses have further improved attacks on reduced-round ChaCha (e.g., 7 rounds) to around 2^{190} , but these remain impractical for the full 20 rounds.

References

  1. [1]
    RFC 7539 - ChaCha20 and Poly1305 for IETF Protocols
    This document defines the ChaCha20 stream cipher as well as the use of the Poly1305 authenticator, both as stand-alone algorithms and as a combined mode.
  2. [2]
    None
    **Summary of ChaCha20 from http://cr.yp.to/chacha/chacha-20080128.pdf**
  3. [3]
    None
    **Summary of Poly1305-AES from http://cr.yp.to/mac/poly1305-20050329.pdf**
  4. [4]
    None
    ### Extracted Abstract: Combined ChaCha20-Poly1305 Mode
  5. [5]
    RFC 7905 - ChaCha20-Poly1305 Cipher Suites for Transport Layer ...
    RFC 7905 describes using ChaCha20 stream cipher and Poly1305 authenticator in TLS and DTLS protocols, updating RFCs 5246 and 6347.
  6. [6]
    RFC 8103 - Using ChaCha20-Poly1305 Authenticated Encryption in ...
    This document describes the conventions for using ChaCha20-Poly1305 Authenticated Encryption in the Cryptographic Message Syntax (CMS).
  7. [7]
    JEP 329: ChaCha20 and Poly1305 Cryptographic Algorithms
    Mar 29, 2016 · Implement the ChaCha20 and ChaCha20-Poly1305 ciphers as specified in RFC 7539. ChaCha20 is a relatively new stream cipher that can replace the older, insecure ...
  8. [8]
    RFC 8439: ChaCha20 and Poly1305 for IETF Protocols
    ### Summary of ChaCha20 Block Function Specification (RFC 8439)
  9. [9]
    [PDF] ChaCha, a variant of Salsa20
    Jan 28, 2008 · The Salsa20/20 stream cipher expands a 256-bit key into 264 randomly accessible streams, each containing 264 randomly accessible 64-byte blocks.
  10. [10]
  11. [11]
  12. [12]
  13. [13]
  14. [14]
    [PDF] The Poly1305-AES message-authentication code
    Mar 29, 2005 · Abstract. Poly1305-AES is a state-of-the-art message-authentication code suitable for a wide variety of applications. Poly1305-AES computes.
  15. [15]
  16. [16]
  17. [17]
  18. [18]
    [PDF] The Salsa20 family of stream ciphers
    Dec 25, 2007 · Abstract. Salsa20 is a family of 256-bit stream ciphers designed in 2005 and submitted to eSTREAM, the ECRYPT Stream Cipher Project.
  19. [19]
    The ChaCha family of stream ciphers
    The ChaCha family of stream ciphers, also known as Snuffle 2008, is a variant of the Salsa20 family of stream ciphers. The following paper introduces ChaCha and ...
  20. [20]
  21. [21]
    [PDF] Cryptography in NaCl
    Mar 10, 2009 · “NaCl” (pronounced “salt”) is the CACE Networking and Cryptography library, a new easy-to-use high-speed high-security public-domain ...
  22. [22]
    RFC 7539: ChaCha20 and Poly1305 for IETF Protocols
    This document defines the ChaCha20 stream cipher as well as the use of the Poly1305 authenticator, both as stand-alone algorithms and as a combined mode.
  23. [23]
    RFC 8446 - The Transport Layer Security (TLS) Protocol Version 1.3
    This document specifies version 1.3 of the Transport Layer Security (TLS) protocol. TLS allows client/server applications to communicate over the Internet.
  24. [24]
    draft-agl-tls-chacha20poly1305-00 - IETF Datatracker
    Network Working Group A. Langley Internet-Draft Google Inc Expires: March 5, 2014 Sept 2013 ChaCha20 and Poly1305 based Cipher Suites for TLS ...Missing: QUIC adoption
  25. [25]
    Protocol & Cryptography - WireGuard
    The following protocols and primitives are used: ChaCha20 for symmetric encryption, authenticated with Poly1305, using RFC7539's AEAD construction · Curve25519 ...Key Exchange and Data Packets · First Message: Initiator to...Missing: 2016 | Show results with:2016
  26. [26]
    The Noise Protocol Framework
    Jul 11, 2018 · Noise is a framework for crypto protocols based on Diffie-Hellman key agreement. Noise can describe protocols that consist of a single message as well as ...Rationale for compound... · Zero-RTT and Noise protocols · Noise Pipes · Rekey
  27. [27]
    draft-ietf-sshm-chacha20-poly1305-02 - Secure Shell (SSH ...
    Jul 23, 2025 · ... Draft SSH chacha20-poly1305 July 2025 2. ... Expires 24 January 2026 [Page 4] Internet-Draft SSH chacha20-poly1305 July 2025 32-bit integer little ...
  28. [28]
    Why are CHACHA20 TLS ciphers not compliant with the NIST ...
    Dec 13, 2024 · ChaCha20 is a stream cipher, and there currently isn't any NIST-approved stream cipher at all. The only option is the block cipher AES.Missing: non- | Show results with:non-
  29. [29]
    draft-irtf-cfrg-xchacha-03 - IETF Datatracker
    Motivation for XChaCha20-Poly1305 The nonce used by the original ChaCha20-Poly1305 is too short to safely use with random strings for long-lived keys.
  30. [30]
    None
    No readable text found in the HTML.<|control11|><|separator|>
  31. [31]
    DNSCrypt - how expired certificates became a thing of the past
    May 4, 2019 · The DNSCrypt protocol version 2 was specified in 2015. Besides introducing a new cipher suite (XChaCha20-Poly1305), and solving the DNS ...
  32. [32]
    [PDF] Extending the Salsa20 nonce
    Feb 4, 2011 · Bernstein ? ... Here E is a cipher mapping 128-bit blocks to 128-bit blocks; for example, E could be AES,. Page 3. Extending the Salsa20 nonce.
  33. [33]
    [PDF] ChaCha, a variant of Salsa20
    Jan 20, 2008 · Less obvious is that the ChaCha quarter-round diffuses changes through bits more quickly than the. Salsa20 quarter-round. One can see this by ...
  34. [34]
    [PDF] Differential Cryptanalysis of Salsa and ChaCha
    This paper proposes a hybrid model for differential cryptanalysis of Salsa and ChaCha, using a hybrid model and concludes 12 rounds are sufficient for 256-bit ...
  35. [35]
    [PDF] A Hardware Perspective on the ChaCha Ciphers
    Taking advantage of the flexibility inherent in the ChaCha cipher, we also demonstrate how our implementation scales to even higher throughputs or lower ...
  36. [36]
    List of stream ciphers measured
    Which stream ciphers are measured? ; chacha8, ChaCha8 (256-bit key), Daniel J. Bernstein ; chacha12, ChaCha12 (256-bit key), Daniel J. Bernstein ; chacha20 ...
  37. [37]
    Do the ChaCha: better mobile performance with cryptography
    Feb 23, 2015 · The new cipher suites are fast. As Adam Langley described, ChaCha20-Poly1305 is three times faster than AES-128-GCM on mobile devices. Spending ...Missing: motivation | Show results with:motivation<|separator|>
  38. [38]
    Signal Messenger: Speak Freely
    ### Summary: Does Signal Protocol Use ChaCha20-Poly1305?
  39. [39]
    [PDF] arXiv:2503.20093v3 [cs.CR] 14 Apr 2025
    Apr 14, 2025 · Takeaway 3: Although secure ciphers like ChaCha20-. Poly1305 are seeing growing adoption, they remain under- represented in public datasets.
  40. [40]
    ChaCha20-Poly1305 - Libsodium documentation - GitBook
    Sep 12, 2023 · The XChaCha20 variant, introduced in libsodium 1.0.12. It can safely encrypt a practically unlimited number of messages of any sizes, and random ...
  41. [41]
    EVP_chacha20 - OpenSSL Documentation
    Authenticated encryption with ChaCha20-Poly1305. Like EVP_chacha20(), the key is 256 bits and the IV is 96 bits. This supports additional authenticated data ...
  42. [42]
  43. [43]
    Authenticated encryption — Cryptography 47.0.0.dev1 documentation
    The ChaCha20Poly1305 construction is defined in RFC 7539 section 2.8. It is a stream cipher combined with a MAC that offers strong integrity guarantees.
  44. [44]
    Release Notes - OpenSSH
    OpenSSH 9.9p2 was released on 2025-02-18. It is available from the mirrors listed at https://www.openssh.com/. OpenSSH is a 100% complete SSH protocol 2.0 ...
  45. [45]
    [PDF] Optimized Implementation of Poly1163 and ChaCha20 ... - ETH Zürich
    Jul 3, 2025 · We report the median cycle count from these iterations to reduce the impact of transient performance fluctuations. Since our input buffers ...
  46. [46]
    Tuning TLS: AES-256 Now Beats ChaCha20 on Every Modern CPU
    ### Summary of Benchmarks: ChaCha20-Poly1305 vs AES-256-GCM in 2025
  47. [47]
    [PDF] Securing the Internet of Battlefield Things with ChaCha20- Poly1305 ...
    Jan 2, 2024 · In addition, ChaCha20 is designed to be highly efficient, making it suitable for use in resource-constrained environments such as IoT devices ...
  48. [48]
    Most Efficient OpenVPN Ciphers Without Compromising Security
    Jul 23, 2025 · ChaCha20‑Poly1305 is fastest on ARM/embedded CPUs (50–60% faster vs. AES‑GCM). AES‑GCM performs best with hardware-acceleration (AES-NI) ...Missing: CTR | Show results with:CTR
  49. [49]
    XChaCha20-Poly1305 vs AES: Modern Encryption Comparison
    Jun 1, 2025 · XChaCha20-Poly1305 is designed to be constant-time by default, while AES implementations vary in their side-channel resistance. // Example: ...
  50. [50]
    AES & ChaCha — A Case for Simplicity in Cryptography | Phase Blog
    Apr 13, 2025 · A technical deep dive into how the ChaCha20 cipher is taking on AES as the gold standard for symmetric encryption, and a lesson about the power of simplicity ...Missing: motivation RC4
  51. [51]
  52. [52]
    [PDF] Security Analysis of ChaCha20-Poly1305 AEAD - CRYPTREC
    This report presents a security evaluation of the ChaCha20-Poly1305 Authenti- cated Encryption with Associated Data (AEAD). The combination of ChaCha and Poly ...
  53. [53]
    [PDF] Improved Cryptanalytic Results against ChaCha
    Abstract. In this paper, we analyze the subtle issues of complexity estimates related to state-of-the-art cryptanalytic efforts on ChaCha.
  54. [54]
    draft-arciszewski-xchacha-03 - IETF Datatracker
    The eXtended-nonce ChaCha cipher construction (XChaCha) allows for ChaCha-based ciphersuites to accept a 192-bit nonce with similar guarantees to the original ...
  55. [55]
  56. [56]
    draft-ietf-sshm-strict-kex-00 - SSH Strict KEX extension
    Jul 21, 2025 · Internet Engineering Task Force D. Miller Internet-Draft OpenSSH Intended status: Standards Track 21 July 2025 Expires: 22 January 2026 SSH ...Missing: mitigation | Show results with:mitigation
  57. [57]
    [PDF] Physical Side-Channel Analysis of ChaCha20-Poly1305
    In this paper, we analyze the stream cipher ChaCha20 [3], [7] and show how the secret key can be completely extracted using EM-based side-channel attacks.
  58. [58]
    [PDF] FIPS 140-3 Non-Proprietary Security Policy
    Jun 23, 2025 · Camellia, SEED, ChaCha20(-Poly1305). AES GCM (external IV). CO. Decryption. Decrypt a ciphertext. RC2, RC4, DES, Triple-DES, CDMF,. Camellia, ...
  59. [59]
    [PDF] The Security of ChaCha20-Poly1305 in the Multi-user Setting
    In fact, TLS 1.3 includes a nonce-randomization mechanism to mitigate against such multi-user attacks, and the rekeying frequencies for GCM in TLS, DTLS ...
  60. [60]
    Improved Key Recovery Attacks on Reduced-Round Salsa20 and ...
    Aug 7, 2025 · Based on these findings, we present improved key recovery attacks on reduced-round Salsa20 and ChaCha. Both time and data complexities of our ...