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<Vec<u8>>;
fn builder(&self) -> impl KdfOperation<'_, Self::Algorithm>
where Self: Sized;
fn generate_salt<R: RngCore + CryptoRng>(rng: &mut R) -> 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<Vec<u8>>
fn derive_key( &self, input: &[u8], salt: Option<&[u8]>, info: Option<&[u8]>, length: usize, ) -> Result<Vec<u8>>
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", so this trait is not object safe.