PermutationState

Trait PermutationState 

Source
pub trait PermutationState:
    Default
    + Clone
    + for<'a> BitXorAssign<&'a Self> {
    type StateReader<'a>: Reader
       where Self: 'a;
    type CopyWriter<'a>: Writer
       where Self: 'a;
    type XorWriter<'a>: Writer
       where Self: 'a;
    type Representation;

    const SIZE: usize;

    // Required methods
    fn reader<'a>(&'a self) -> Self::StateReader<'a>;
    fn copy_writer<'a>(&'a mut self) -> Self::CopyWriter<'a>;
    fn xor_writer<'a>(&'a mut self) -> Self::XorWriter<'a>;
    fn from_state(state: Self::Representation) -> Self;
    fn get_state(&self) -> &Self::Representation;
    fn get_state_mut(&mut self) -> &mut Self::Representation;
}
Expand description

A state where a cryptographic permutation acts upon.

The API of this trait consists of two parts: the generic and the specific part. The generic part aims at users of permutation, that want to be generic over the specific permutation used in the construction (e.g. in a Sponge or Farfalle construction). The specific part aims at Permutation implementers. It allows to directly access the state representation.

§Generic API

The generic API gives abstract ways to read, write and xor bytes from/to the state. It consists of

Besides these trait items, there are also the Default, Clone and BitXorAssign trait bounds.

§Specific API

The specific API gives direct read and write access to the state representation underlying the PermutationState. It consists of

Required Associated Constants§

Source

const SIZE: usize

Number of bytes of the state.

Required Associated Types§

Source

type StateReader<'a>: Reader where Self: 'a

Reader to read bytes from the state.

Source

type CopyWriter<'a>: Writer where Self: 'a

Writer to write into the state.

Source

type XorWriter<'a>: Writer where Self: 'a

Writer to xor into the state.

Source

type Representation

Representation of the state the permutation works on.

This should generally be an array of integers, e.g. [u64; 25] for Keccak-f[1600].

Required Methods§

Source

fn reader<'a>(&'a self) -> Self::StateReader<'a>

Create a Reader to read bytes from the state.

Source

fn copy_writer<'a>(&'a mut self) -> Self::CopyWriter<'a>

Create a Writer to write into the state.

Source

fn xor_writer<'a>(&'a mut self) -> Self::XorWriter<'a>

Create a Writer to xor into the state.

Source

fn from_state(state: Self::Representation) -> Self

Initialise the permutation from the given state.

Source

fn get_state(&self) -> &Self::Representation

Read from the state buffer.

Source

fn get_state_mut(&mut self) -> &mut Self::Representation

Write into the state buffer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§