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§
Sourcefn key_derivation_type(&self) -> KeyDerivationType
fn key_derivation_type(&self) -> KeyDerivationType
Get the key derivation type of the implmenetation.
Sourcefn default_preset(&self) -> u8
fn default_preset(&self) -> u8
Get the default preset to use (for new keys).
Sourcefn min_nonce_len(&self) -> usize
fn min_nonce_len(&self) -> usize
Get the minmal length of a nonce for key-derivation.
Sourcefn derive(
&self,
passphrase: &SecretBytes,
preset: u8,
nonce: &[u8],
key_length: usize,
) -> SecretStoreResult<SecretBytes>
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 userpreset
key-derivation preset to usenonce
random nonce to use, ensured to have at leastmin_nonce_len
byteskey_length
the required key-length of the seal-key. The output must have exactly this length.