pub fn pbkdf2<const KL: usize, H: Hash>(
password: &[u8],
salt: impl Salt<NonEmpty>,
iters: Iters,
) -> Result<[u8; KL], Unspecified>Expand description
Performs PBKDF2 and returns the result as a fixed-size array.
§Arguments
password- The password to use for the key derivation.salt- The salt to use for key derivation.iters- The number of times to process the hash.
§Errors
- The length of the
passwordwas greater thani32::MAX. - The length of the
saltwas greater thani32::MAX. - The number of
iterswas greater thani32::MAX. - The
KLgeneric was greater thani32::MAX.
§FIPS Errors
If the allow-non-fips feature flag is disabled this will return an error if the KL
generic is not at least FIPS_MIN_KEY (14 bytes).
§Example
use wolf_crypto::kdf::{pbkdf2, Sha256, Iters};
let password = b"my secret password";
let salt = [42; 16];
let iters = Iters::new(600_000).unwrap();
let key = pbkdf2::<32, Sha256>(password, salt, iters).unwrap();
assert_eq!(key.len(), 32);