pub trait KeyDerivationFunction {
type Algorithm: KdfAlgorithm;
type Salt: AsRef<[u8]> + AsMut<[u8]> + Clone;
// Required methods
fn new() -> Self;
fn derive_key(
&self,
input: &[u8],
salt: Option<&[u8]>,
info: Option<&[u8]>,
length: usize,
) -> Result<ZeroizingBytes>;
fn builder(&self) -> impl KdfOperation<'_, Self::Algorithm>
where Self: Sized;
fn generate_salt<R: RngCore + CryptoRng>(rng: &mut R) -> Result<Self::Salt>;
// Provided method
fn security_level() -> SecurityLevel { ... }
}Expand description
Common trait for all key derivation functions
Required Associated Types§
Sourcetype Algorithm: KdfAlgorithm
type Algorithm: KdfAlgorithm
The algorithm this KDF implements
Required Methods§
Sourcefn derive_key(
&self,
input: &[u8],
salt: Option<&[u8]>,
info: Option<&[u8]>,
length: usize,
) -> Result<ZeroizingBytes>
fn derive_key( &self, input: &[u8], salt: Option<&[u8]>, info: Option<&[u8]>, length: usize, ) -> Result<ZeroizingBytes>
Sourcefn builder(&self) -> impl KdfOperation<'_, Self::Algorithm>where
Self: Sized,
fn builder(&self) -> impl KdfOperation<'_, Self::Algorithm>where
Self: Sized,
Creates a builder for fluent API usage - FIXED: Elided lifetime
Provided Methods§
Sourcefn security_level() -> SecurityLevel
fn security_level() -> SecurityLevel
Returns the security level of the KDF in bits
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<H: HashFunction + Clone, const S: usize> KeyDerivationFunction for Hkdf<H, S>where
Salt<S>: HkdfCompatible,
impl<H: HashFunction + Clone, const S: usize> KeyDerivationFunction for Hkdf<H, S>where
Salt<S>: HkdfCompatible,
Source§impl<H: HashFunction + Clone, const S: usize> KeyDerivationFunction for Pbkdf2<H, S>where
Salt<S>: Pbkdf2Compatible,
impl<H: HashFunction + Clone, const S: usize> KeyDerivationFunction for Pbkdf2<H, S>where
Salt<S>: Pbkdf2Compatible,
Source§impl<H: HashFunction + Clone> KeyDerivationFunction for TypedHkdf<H>
Available on crate feature alloc only.
impl<H: HashFunction + Clone> KeyDerivationFunction for TypedHkdf<H>
Available on crate feature
alloc only.Source§impl<H: HashFunction + Clone> KeyDerivationFunction for TypedPbkdf2<H>
Available on crate feature alloc only.
impl<H: HashFunction + Clone> KeyDerivationFunction for TypedPbkdf2<H>
Available on crate feature
alloc only.