Trait engine::vault::BoxProvider

source ·
pub trait BoxProvider: 'static + Sized + Ord + PartialOrd {
    type Error: Debug;

    // Required methods
    fn box_key_len() -> usize;
    fn box_overhead() -> usize;
    fn box_seal(
        key: &Key<Self>,
        ad: &[u8],
        data: &[u8]
    ) -> Result<Vec<u8>, Self::Error>;
    fn box_open(
        key: &Key<Self>,
        ad: &[u8],
        data: &[u8]
    ) -> Result<Vec<u8>, Self::Error>;
    fn random_buf(buf: &mut [u8]) -> Result<(), Self::Error>;

    // Provided method
    fn random_vec(len: usize) -> Result<Zeroizing<Vec<u8>>, Self::Error> { ... }
}
Expand description

A provider interface between the vault and a crypto box. See libsodium’s secretbox for an example.

Required Associated Types§

Required Methods§

source

fn box_key_len() -> usize

defines the key length for the BoxProvider.

source

fn box_overhead() -> usize

defines the size of the Nonce combined with the Ad for the BoxProvider.

source

fn box_seal( key: &Key<Self>, ad: &[u8], data: &[u8] ) -> Result<Vec<u8>, Self::Error>

seals some data into the crypto box using the Key and the associated data.

source

fn box_open( key: &Key<Self>, ad: &[u8], data: &[u8] ) -> Result<Vec<u8>, Self::Error>

opens a crypto box to get data using the Key and the associated data.

source

fn random_buf(buf: &mut [u8]) -> Result<(), Self::Error>

fills a buffer [&mut [u8]] with secure random bytes.

Provided Methods§

source

fn random_vec(len: usize) -> Result<Zeroizing<Vec<u8>>, Self::Error>

creates a vector with secure random bytes based off of an inputted usize length.

Object Safety§

This trait is not object safe.

Implementors§