Trait KeyDerivation

Source
pub trait KeyDerivation: Send + Sync {
    // Required methods
    fn key_derivation_type(&self) -> KeyDerivationType;
    fn default_preset(&self) -> u8;
    fn min_nonce_len(&self) -> usize;
    fn derive(
        &self,
        passphrase: &SecretBytes,
        preset: u8,
        nonce: &[u8],
        key_length: usize,
    ) -> SecretStoreResult<SecretBytes>;
}
Expand description

Common interface for a key-derivation method.

An implmentation of KeyDerivation is used to derive the seal-key of a Cipher.

Each method may have multiple presets for internal parameters that have to be adjusted to common CPU power and use-case. Each preset is identified by a simple number.

Required Methods§

Source

fn key_derivation_type(&self) -> KeyDerivationType

Get the key derivation type of the implmenetation.

Source

fn default_preset(&self) -> u8

Get the default preset to use (for new keys).

Source

fn min_nonce_len(&self) -> usize

Get the minmal length of a nonce for key-derivation.

Source

fn derive( &self, passphrase: &SecretBytes, preset: u8, nonce: &[u8], key_length: usize, ) -> SecretStoreResult<SecretBytes>

Derive a seal-key from a passphrase.

  • passphrase provided by the user
  • preset key-derivation preset to use
  • nonce random nonce to use, ensured to have at least min_nonce_len bytes
  • key_length the required key-length of the seal-key. The output must have exactly this length.

Implementors§