ChaCha20 stream cipher.
This module provides a backend-agnostic API for the ChaCha20 stream cipher as defined in RFC 8439.
Functions | |
| Status | Crypt (span< const std::byte > key, span< const std::byte > nonce, span< const std::byte > input, span< std::byte > output) |
Variables | |
| constexpr size_t | kKeySizeBytes = 32 |
| constexpr size_t | kNonceSizeBytes = 12 |
|
inline |
Performs ChaCha20 encryption or decryption. Since ChaCha20 is a stream cipher, encryption and decryption are the same operation. InitialCounter had been removed from the cacnonical API and is hardcoded to 0 for simplicity of a one-shot only implementation.
| [in] | key | The 256-bit secret key. |
| [in] | nonce | The 96-bit nonce. MUST be unique for each encryption with the same key. |
| [in] | input | The data to encrypt or decrypt. |
| [out] | output | The buffer to store the result. Must be at least as large as input. In-place operation is allowed (input == output). |
OkStatus() on success. or Status::InvalidArgument() if key, nonce, or buffer sizes are incorrect. Status::Internal() for any other backend-related errors.