Struct tindercrypt::metadata::KeyDerivationMetadata [−][src]
pub struct KeyDerivationMetadata { pub hash_fn: HashFunction, pub iterations: usize, pub salt: [u8; 32], }
Expand description
The metadata that can be used for the key derivation process.
Currently, these metadata map 1-1 to the metadata necessary for the PBKDF2 algorithm.
Examples
use tindercrypt::metadata::{HashFunction, KeyDerivationMetadata}; // Generate a struct instance for the key derivation metadata. The default // is to choose an HMAC function based on SHA-256, 100,000 iterations of // PBKDF2 and a unique salt. let key_meta1 = KeyDerivationMetadata::generate(); assert_eq!(key_meta1.hash_fn, HashFunction::SHA256); assert_eq!(key_meta1.iterations, 100000); // Generate a second struct instance. The salt should be unique. let key_meta2 = KeyDerivationMetadata::generate(); assert_eq!(key_meta1.hash_fn, HashFunction::SHA256); assert_eq!(key_meta1.iterations, 100000); assert_ne!(key_meta1.salt, key_meta2.salt);
Fields
hash_fn: HashFunction
The hash function that is used as the basis for the computational work.
iterations: usize
The number of iterations for the key derivation algorithm.
salt: [u8; 32]
A unique value that is used to create different keys from the same passphrase.
Implementations
Create the key derivation metadata from user-provided values.
This method should be used only when the user wants to explicitly set
a specific value. Else, it’s better to use ::generate()
.
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for KeyDerivationMetadata
impl Send for KeyDerivationMetadata
impl Sync for KeyDerivationMetadata
impl Unpin for KeyDerivationMetadata
impl UnwindSafe for KeyDerivationMetadata
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V