ctr::flavors

Trait CtrFlavor

Source
pub trait CtrFlavor<B: ArrayLength<u8>> {
    type CtrNonce: Clone;
    type Backend: Counter;

    const NAME: &'static str;

    // Required methods
    fn remaining(cn: &Self::CtrNonce) -> Option<usize>;
    fn next_block(cn: &mut Self::CtrNonce) -> GenericArray<u8, B>;
    fn current_block(cn: &Self::CtrNonce) -> GenericArray<u8, B>;
    fn from_nonce(block: &GenericArray<u8, B>) -> Self::CtrNonce;
    fn set_from_backend(cn: &mut Self::CtrNonce, v: Self::Backend);
    fn as_backend(cn: &Self::CtrNonce) -> Self::Backend;
}
Expand description

Trait implemented by different CTR flavors.

Required Associated Constants§

Source

const NAME: &'static str

Flavor name

Required Associated Types§

Source

type CtrNonce: Clone

Inner representation of nonce.

Source

type Backend: Counter

Backend numeric type

Required Methods§

Source

fn remaining(cn: &Self::CtrNonce) -> Option<usize>

Return number of remaining blocks.

If result does not fit into usize, returns None.

Source

fn next_block(cn: &mut Self::CtrNonce) -> GenericArray<u8, B>

Generate block for given nonce and current counter value.

Source

fn current_block(cn: &Self::CtrNonce) -> GenericArray<u8, B>

Generate block for given nonce and current counter value.

Source

fn from_nonce(block: &GenericArray<u8, B>) -> Self::CtrNonce

Initialize from bytes.

Source

fn set_from_backend(cn: &mut Self::CtrNonce, v: Self::Backend)

Convert from a backend value

Source

fn as_backend(cn: &Self::CtrNonce) -> Self::Backend

Convert to a backend value

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§

Source§

impl<B> CtrFlavor<B> for Ctr32BE

Source§

const NAME: &'static str = "32BE"

Source§

type CtrNonce = CtrNonce32<<B as PartialDiv<UInt<UInt<UInt<UTerm, B1>, B0>, B0>>>::Output>

Source§

type Backend = u32

Source§

impl<B> CtrFlavor<B> for Ctr32LE

Source§

const NAME: &'static str = "32LE"

Source§

type CtrNonce = CtrNonce32<<B as PartialDiv<UInt<UInt<UInt<UTerm, B1>, B0>, B0>>>::Output>

Source§

type Backend = u32

Source§

impl<B> CtrFlavor<B> for Ctr64BE

Source§

const NAME: &'static str = "64BE"

Source§

type CtrNonce = CtrNonce64<<B as PartialDiv<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>>>::Output>

Source§

type Backend = u64

Source§

impl<B> CtrFlavor<B> for Ctr64LE

Source§

const NAME: &'static str = "64LE"

Source§

type CtrNonce = CtrNonce64<<B as PartialDiv<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>>>::Output>

Source§

type Backend = u64

Source§

impl<B> CtrFlavor<B> for Ctr128BE

Source§

const NAME: &'static str = "128BE"

Source§

type CtrNonce = CtrNonce128<<B as PartialDiv<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>>::Output>

Source§

type Backend = u128

Source§

impl<B> CtrFlavor<B> for Ctr128LE

Source§

const NAME: &'static str = "128LE"

Source§

type CtrNonce = CtrNonce128<<B as PartialDiv<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>>::Output>

Source§

type Backend = u128