[−][src]Function rc_crypto::pbkdf2::derive
pub fn derive(
passphrase: &[u8],
salt: &[u8],
iterations: u32,
hash_algorithm: HashAlgorithm,
out: &mut [u8]
) -> Result<()>
Extend passwords using pbkdf2, based on the following rfc it runs the NSS implementation
Arguments
passphrase
- The password to stretchsalt
- A salt to use in the generation processiterations
- The number of iterations the hashing algorithm will run on each section of the keyhash_algorithm
- The hash algorithm to useout
- The slice the algorithm will populate
Examples
use rc_crypto::pbkdf2; let password = b"password"; let salt = b"salt"; let mut out = vec![0u8; 32]; let iterations = 2; // Real code should have a MUCH higher number of iterations (Think 1000+) pbkdf2::derive(password, salt, iterations, pbkdf2::HashAlgorithm::SHA256, &mut out).unwrap(); // Oh oh should handle the error! assert_eq!(hex::encode(out), "ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43");
Errors
Could possibly return an error if the HMAC algorithm fails, or if the NSS algorithm returns an error