Skip to main content

Module key_derivation

Module key_derivation 

Source
Expand description

Module for key derivation. Derives a key or password into a SecretKey and returns the DerivationParameters needed to reproduce the derivation.

§Example (Argon2 — default)

use devolutions_crypto::key_derivation::Argon2;

let password = b"a very strong password";
let argon2 = Argon2::new();
let (secret_key, params) = argon2.derive(password).expect("derivation should not fail");
// Serialize params to re-derive later:
let params_bytes: Vec<u8> = params.into();

§Example (PBKDF2)

use devolutions_crypto::key_derivation::Pbkdf2;

let password = b"a very strong password";
let pbkdf2 = Pbkdf2::new();
let (secret_key, params) = pbkdf2.derive(password).expect("derivation should not fail");

Structs§

Argon2
Derives a key using Argon2id (V2, the default).
DerivationParameters
Serializable parameters that fully describe a completed key derivation. Can be stored alongside a user record to re-derive the same key later.
Pbkdf2
Derives a key using PBKDF2-HMAC-SHA256 (V1).

Functions§

derive_key
Derives a SecretKey from password using the algorithm selected by version.