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().

Generate key derivation metadata.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.