Crate chacha20_poly1305_aead [−] [src]
A pure Rust implementation of the ChaCha20-Poly1305 AEAD from RFC 7539.
An Authenticated Encryption with Associated Data (AEAD) mode encrypts data and generates an authentication tag, or decrypts data and verifies an authentication tag, as a single operation. The tag can also validate additional authenticated data (AAD) which is not included in the cyphertext, for instance a plaintext header.
The ChaCha20-Poly1305 AEAD uses a 256-bit (32-byte) key, and a 96-bit (12-byte) nonce. For each key, a given nonce should be used only once, otherwise the encryption and authentication can be broken. One way to prevent reuse is for the nonce to contain a sequence number.
The amount of data that can be encrypted in a single call is 232 - 1 blocks of 64 bytes, slightly less than 256 GiB.
Enums
DecryptError |
Error returned from the |
Functions
decrypt |
Verifies the authentication tag and decrypts a byte slice. |
encrypt |
Encrypts a byte slice and returns the authentication tag. |
encrypt_read |
Encrypts bytes from a reader and returns the authentication tag. |
selftest |
Runs the self-test for ChaCha20, Poly1305, and the AEAD. |