Trait PseudoRandomFunction

Source
pub trait PseudoRandomFunction<'a> {
    type KeyHandle;
    type PrfOutputSize: ArrayLength<u8> + ToInt<usize>;
    type Error;

    // Required methods
    fn init(
        &mut self,
        key: &'a dyn PseudoRandomFunctionKey<KeyHandle = Self::KeyHandle>,
    ) -> Result<(), Self::Error>;
    fn update(&mut self, msg: &[u8]) -> Result<(), Self::Error>;
    fn finish(&mut self, out: &mut [u8]) -> Result<usize, Self::Error>;
}
Expand description

Defines how the KBKDF crate will interact with PRFs This allows the user of this crate to provide their own implementation of a PRF, however, only SP800-108 specified PRFs are allowed in the approved mode of operation. Given that, this crate cannot test for that and assumes that the user is using an approved PRF.

Required Associated Types§

Source

type KeyHandle

The type kf key handle the PRF is expecting

Source

type PrfOutputSize: ArrayLength<u8> + ToInt<usize>

The PRF output size

Source

type Error

The error type returned

Required Methods§

Source

fn init( &mut self, key: &'a dyn PseudoRandomFunctionKey<KeyHandle = Self::KeyHandle>, ) -> Result<(), Self::Error>

Initializes the pseudo random function

§Arguments
  • key - The key (K1)
§Returns

Either nothing or an [Error]

§Panics

This function is allowed to panic if init is called while already initialized

Source

fn update(&mut self, msg: &[u8]) -> Result<(), Self::Error>

Updates the PRF function

§Arguments
  • msg - The next message to input into the PRF
§Returns

Either nothing or an [Error]

§Panics

This function is allowed to panic if update is called before init

Source

fn finish(&mut self, out: &mut [u8]) -> Result<usize, Self::Error>

Finishes the PRF and returns the value in a buffer

§Arguments
  • out - The result of the PRF
§Returns

Either nothing or an [Error]

§Panics

This function is allowed to panic if finish is called before init

Implementors§