#authenticated-encryption #aead #chacha20 #stream-cipher #poly1305 #xchacha20-poly1305

no-std chacha20poly1305

Pure Rust implementation of the ChaCha20Poly1305 Authenticated Encryption with Additional Data Cipher (RFC 8439) with optional architecture-specific hardware acceleration. Also contains implementations of the XChaCha20Poly1305 extended nonce variant of ChaCha20Poly1305, and the reduced-round ChaCha8Poly1305 and ChaCha12Poly1305 lightweight variants.

29 releases

0.11.0-pre.2 Oct 7, 2024
0.11.0-pre.1 Jul 27, 2024
0.10.1 Aug 10, 2022
0.10.0-pre.2 Jul 20, 2022
0.0.0 Oct 6, 2016

#372 in Cryptography

Download history 192008/week @ 2024-08-04 204938/week @ 2024-08-11 192826/week @ 2024-08-18 218870/week @ 2024-08-25 218741/week @ 2024-09-01 194965/week @ 2024-09-08 185092/week @ 2024-09-15 202787/week @ 2024-09-22 209841/week @ 2024-09-29 210129/week @ 2024-10-06 219440/week @ 2024-10-13 226076/week @ 2024-10-20 197943/week @ 2024-10-27 207209/week @ 2024-11-03 225469/week @ 2024-11-10 229959/week @ 2024-11-17

870,973 downloads per month
Used in 1,052 crates (261 directly)

Apache-2.0 OR MIT

69KB
202 lines

RustCrypto: ChaCha20Poly1305

crate Docs Apache2/MIT licensed Rust Version Project Chat Build Status

Pure Rust implementation of ChaCha20Poly1305 (RFC 8439): an Authenticated Encryption with Associated Data (AEAD) cipher amenable to fast, constant-time implementations in software, based on the ChaCha20 stream cipher and Poly1305 universal hash function.

This crate also contains an implementation of XChaCha20Poly1305: a variant of ChaCha20Poly1305 with an extended 192-bit (24-byte) nonce.

Documentation

About

ChaCha20Poly1305 is notable for being simple and fast when implemented in pure software. The underlying ChaCha20 stream cipher uses a simple combination of add, rotate, and XOR instructions (a.k.a. "ARX"), and the Poly1305 hash function is likewise extremely simple.

While it hasn't received approval from certain standards bodies (i.e. NIST) the algorithm is widely used and deployed. Notably it's mandatory to implement in the Transport Layer Security (TLS) protocol. The underlying ChaCha20 cipher is also widely used as a cryptographically secure random number generator, including internal use by the Rust standard library.

Security Notes

This crate has received one security audit by NCC Group, with no significant findings. We would like to thank MobileCoin for funding the audit.

All implementations contained in the crate are designed to execute in constant time, either by relying on hardware intrinsics (i.e. AVX2 on x86/x86_64), or using a portable implementation which is only constant time on processors which implement constant-time multiplication.

It is not suitable for use on processors with a variable-time multiplication operation (e.g. short circuit on multiply-by-zero / multiply-by-one, such as certain 32-bit PowerPC CPUs and some non-ARM microcontrollers).

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.7–1MB
~19K SLoC