Trait ctr::flavors::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 Types§

source

type CtrNonce: Clone

Inner representation of nonce.

source

type Backend: Counter

Backend numeric type

Required Associated Constants§

source

const NAME: &'static str

Flavor name

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<B> CtrFlavor<B> for Ctr32BE

§

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

§

type Backend = u32

source§

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

source§

impl<B> CtrFlavor<B> for Ctr32LE

§

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

§

type Backend = u32

source§

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

source§

impl<B> CtrFlavor<B> for Ctr64BE

§

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

§

type Backend = u64

source§

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

source§

impl<B> CtrFlavor<B> for Ctr64LE

§

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

§

type Backend = u64

source§

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

source§

impl<B> CtrFlavor<B> for Ctr128BE

§

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

§

type Backend = u128

source§

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

source§

impl<B> CtrFlavor<B> for Ctr128LE

§

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

§

type Backend = u128

source§

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