Skip to main content

Algorithm

Trait Algorithm 

Source
pub trait Algorithm {
    type Drop: DropStrategy<Extra = Self::Extra>;
    type Extra;
}
Expand description

A trait that defines an encryption algorithm and its associated types.

This trait is implemented by algorithm types (like xor::Xor and rc4::Rc4) to specify:

  • The drop strategy to use when the encrypted data is dropped
  • The extra data type that the algorithm needs to store alongside the buffer

The Extra associated type allows algorithms to store additional data (like encryption keys for RC4) within the Encrypted struct.

Required Associated Types§

Source

type Drop: DropStrategy<Extra = Self::Extra>

The drop strategy to use when the encrypted data is dropped.

Source

type Extra

Additional data stored alongside the encrypted buffer.

For XOR this is () (no extra data needed), for RC4 this is the key array.

Implementors§

Source§

impl<const KEY: u8, D: DropStrategy<Extra = ()>> Algorithm for Xor<KEY, D>

Source§

impl<const KEY_LEN: usize, D: DropStrategy<Extra = [u8; KEY_LEN]>> Algorithm for Rc4<KEY_LEN, D>