pub enum KeyDerivationFunction {
Argon2,
Scrypt,
Pbkdf2,
Custom(String),
}Expand description
Key derivation functions for secure key generation from passwords or key material
This enum provides type-safe selection of key derivation functions (KDFs) with different security properties and performance characteristics. All functions are designed to be computationally expensive to resist brute-force attacks.
§Function Characteristics
- Argon2: Memory-hard function, winner of Password Hashing Competition
- Scrypt: Memory-hard function with tunable parameters
- PBKDF2: Standard function with configurable iterations
- Custom: User-defined functions for specialized requirements
§Security Properties
- Argon2: Resistant to GPU and ASIC attacks, configurable memory and time costs
- Scrypt: Good resistance to hardware attacks, balanced memory/time trade-offs
- PBKDF2: Widely supported, but more vulnerable to specialized hardware attacks
§Performance Considerations
| Function | Speed | Memory Usage | GPU Resistance | ASIC Resistance |
|---|---|---|---|---|
| Argon2 | Slow | High | Excellent | Excellent |
| Scrypt | Medium | Medium | Good | Good |
| PBKDF2 | Fast | Low | Poor | Poor |
§Examples
Variants§
Argon2
Argon2 - Memory-hard function resistant to GPU and ASIC attacks Winner of the Password Hashing Competition, provides excellent security
Scrypt
Scrypt - Memory-hard function with tunable parameters Good balance of security and performance
Pbkdf2
PBKDF2 - Standard key derivation function Widely supported but less resistant to specialized attacks
Custom(String)
Custom key derivation function for specialized requirements
Trait Implementations§
Source§impl Clone for KeyDerivationFunction
impl Clone for KeyDerivationFunction
Source§fn clone(&self) -> KeyDerivationFunction
fn clone(&self) -> KeyDerivationFunction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyDerivationFunction
impl Debug for KeyDerivationFunction
Source§impl Display for KeyDerivationFunction
impl Display for KeyDerivationFunction
Source§impl PartialEq for KeyDerivationFunction
impl PartialEq for KeyDerivationFunction
impl StructuralPartialEq for KeyDerivationFunction
Auto Trait Implementations§
impl Freeze for KeyDerivationFunction
impl RefUnwindSafe for KeyDerivationFunction
impl Send for KeyDerivationFunction
impl Sync for KeyDerivationFunction
impl Unpin for KeyDerivationFunction
impl UnwindSafe for KeyDerivationFunction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more