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
Self::SIZE(constant)Self::StateReader(type)Self::CopyWriter(type)Self::XorWriter(type)Self::reader(method)Self::copy_writer(method)Self::xor_writer(method)
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
Self::Representation(type)Self::from_state(constructor function)Self::get_state(method)Self::get_state_mut(method)
Required Associated Constants§
Required Associated Types§
Sourcetype StateReader<'a>: Reader
where
Self: 'a
type StateReader<'a>: Reader where Self: 'a
Reader to read bytes from the state.
Sourcetype CopyWriter<'a>: Writer
where
Self: 'a
type CopyWriter<'a>: Writer where Self: 'a
Writer to write into the state.
Sourcetype Representation
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§
Sourcefn reader<'a>(&'a self) -> Self::StateReader<'a>
fn reader<'a>(&'a self) -> Self::StateReader<'a>
Create a Reader to read bytes from the state.
Sourcefn copy_writer<'a>(&'a mut self) -> Self::CopyWriter<'a>
fn copy_writer<'a>(&'a mut self) -> Self::CopyWriter<'a>
Create a Writer to write into the state.
Sourcefn xor_writer<'a>(&'a mut self) -> Self::XorWriter<'a>
fn xor_writer<'a>(&'a mut self) -> Self::XorWriter<'a>
Create a Writer to xor into the state.
Sourcefn from_state(state: Self::Representation) -> Self
fn from_state(state: Self::Representation) -> Self
Initialise the permutation from the given state.
Sourcefn get_state(&self) -> &Self::Representation
fn get_state(&self) -> &Self::Representation
Read from the state buffer.
Sourcefn get_state_mut(&mut self) -> &mut Self::Representation
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.