Trait 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.

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§