Module secured_cipher::permutation::core
source · Expand description
Core module containing essential cryptographic functionalities. ChaCha20 Cryptographic Algorithm Implementation
This module provides an implementation of the ChaCha20 stream cipher, as specified in RFC 7539 by the Internet Engineering Task Force (IETF). The implementation includes constants, state management, encryption/decryption functions, and utilities for data transformation relevant to the ChaCha20 algorithm.
The constants and logic, as well as the test vectors used in this module, are based on and verifiable against the specifications detailed in the IETF paper: “ChaCha20 and Poly1305 for IETF Protocols” (RFC 7539). This can be accessed at https://datatracker.ietf.org/doc/html/rfc7539.
The module is designed to be compliant with the RFC 7539 standard, ensuring reliability and correctness of the cryptographic operations as per the established IETF guidelines.
Constants
- Size of the ChaCha20 nonce in bytes. The nonce is a 64-bit (8 bytes) value used to make each block unique.
- Constants for the ChaCha20 algorithm. These four 32-bit words represent the ASCII encoding of “expand 32-byte k”, used in the state initialization of the ChaCha20 block.
- Size of the key in bytes. The key is a 256-bit (32 bytes) value used for encryption and decryption.
- Number of ChaCha20 rounds. This constant defines how many rounds of the main ChaCha20 algorithm will be executed. The standard number of rounds is 20.
- Number of 32-bit words in the ChaCha state. The ChaCha20 state consists of 16 words, each of which is 32 bits long.
- Size of the XChaCha20 nonce in bytes. The nonce is a 128-bit (16 bytes) value used to make each block unique.
Functions
- Runs the ChaCha20 permutation on the provided state.
- Performs the quarter round operation on the state.
- Runs the ChaCha20 rounds on the provided state. This function modifies the state in place.
- XORs two 512-bit state arrays. This function modifies the first array in place.
Type Aliases
- The array of words representing a ChaCha20 block.