Trait secured_cipher::permutation::Permutation
source · pub trait Permutation {
// Required methods
fn init(&mut self, key: &[u8], iv: &[u8]);
fn process(&mut self, data: &[u8]) -> Vec<u8>;
fn clear(&mut self);
}Expand description
Permutation trait defines the common operations for permutation-based cryptographic algorithms.
This trait provides the fundamental methods required for encryption and decryption processes in ciphers like ChaCha20 and XChaCha20.
Required Methods§
sourcefn init(&mut self, key: &[u8], iv: &[u8])
fn init(&mut self, key: &[u8], iv: &[u8])
Initializes the permutation with a key and an initialization vector (IV).
This method sets up the internal state of the cipher using the provided key and IV, preparing it for either encryption or decryption.
Arguments
key- A byte slice representing the cryptographic key.iv- A byte slice representing the initialization vector.
sourcefn process(&mut self, data: &[u8]) -> Vec<u8>
fn process(&mut self, data: &[u8]) -> Vec<u8>
Processes the provided data (either encrypts or decrypts, depending on the implementation).
This method applies the cipher’s permutation logic to the provided data, returning the processed data as a new vector of bytes.
Arguments
data- A byte slice of data to be processed (encrypted or decrypted).
Returns
A vector of bytes representing the processed data.