Skip to main content

KeyDeriver

Trait KeyDeriver 

Source
pub trait KeyDeriver: Send + Sync {
    // Required method
    fn derive(
        &self,
        password: &[u8],
        salt: &PHashSalt,
    ) -> Result<MasterKey, KdfError>;
}
Expand description

Stretching of a password into a master key.

The trait exists so that tests can substitute a cheap deriver for the production one without the layers above knowing which is in use. It is Send + Sync because the pipeline may hold a deriver behind a shared reference while worker threads are running.

Required Methods§

Source

fn derive( &self, password: &[u8], salt: &PHashSalt, ) -> Result<MasterKey, KdfError>

Derives a master key from password, salted with the container hash.

§Errors

Returns KdfError::EmptyPassword if password has no bytes, and KdfError::Argon2Error if the underlying implementation fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§