#[non_exhaustive]pub enum Kdf {
None,
Bcrypt {
salt: Vec<u8>,
rounds: u32,
},
}Expand description
Key Derivation Functions (KDF).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
Source§impl Kdf
impl Kdf
Sourcepub fn new<R: TryCryptoRng + ?Sized>(
algorithm: KdfAlg,
rng: &mut R,
) -> Result<Self>
Available on crate feature encryption only.
pub fn new<R: TryCryptoRng + ?Sized>( algorithm: KdfAlg, rng: &mut R, ) -> Result<Self>
encryption only.Initialize KDF configuration for the given algorithm.
§Errors
Returns Error::RngFailure on RNG errors.
Sourcepub fn derive(
&self,
password: impl AsRef<[u8]>,
output: &mut [u8],
) -> Result<()>
Available on crate feature encryption only.
pub fn derive( &self, password: impl AsRef<[u8]>, output: &mut [u8], ) -> Result<()>
encryption only.Derive an encryption key from the given password.
§Errors
Returns Error::Crypto if the bcrypt round count is zero or exceeds 1,048,576, or if the
underlying password hashing primitive returns an error.
Sourcepub fn derive_key_and_iv(
&self,
cipher: Cipher,
password: impl AsRef<[u8]>,
) -> Result<(Zeroizing<Vec<u8>>, Vec<u8>)>
Available on crate feature encryption only.
pub fn derive_key_and_iv( &self, cipher: Cipher, password: impl AsRef<[u8]>, ) -> Result<(Zeroizing<Vec<u8>>, Vec<u8>)>
encryption only.Derive key and IV for the given Cipher.
Returns two byte vectors containing the key and IV respectively.
§Errors
- Returns
Error::DecryptedifcipherisCipher::None. - Returns
Error::Encodingin the event of a length error. - Propagates errors returned from
Self::derive.
Trait Implementations§
Source§impl Encode for Kdf
impl Encode for Kdf
Source§fn encoded_len(&self) -> Result<usize>
fn encoded_len(&self) -> Result<usize>
Get the length of this type encoded in bytes, prior to Base64 encoding. Read more
Source§fn encoded_len_prefixed(&self) -> Result<usize, Error>
fn encoded_len_prefixed(&self) -> Result<usize, Error>
Return the length of this type after encoding when prepended with a
uint32 length prefix. Read moreimpl Eq for Kdf
impl StructuralPartialEq for Kdf
Auto Trait Implementations§
impl Forget for Kdf
impl Freeze for Kdf
impl Move for Kdf
impl RefUnwindSafe for Kdf
impl Send for Kdfwhere
RawVecInner: Send,
impl Sync for Kdfwhere
RawVecInner: Sync,
impl Unpin for Kdf
impl UnsafeUnpin for Kdf
impl UnwindSafe for Kdfwhere
RawVecInner: UnwindSafe,
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