Enum pzip::KeyDerivation
source · [−]pub enum KeyDerivation {
Raw,
HkdfSha256,
Pbkdf2Sha256,
}
Expand description
The key derivation functions (KDFs) known by PZip.
Encapsulates the tags needed for each KDF along with a common derive
method.
Variants
Raw
HkdfSha256
Pbkdf2Sha256
Implementations
sourceimpl KeyDerivation
impl KeyDerivation
sourcepub fn from(num: u8) -> Result<KeyDerivation, Error>
pub fn from(num: u8) -> Result<KeyDerivation, Error>
Returns a KeyDerivation
for the specified u8
if known, otherwise
Error::UnknownKeyDerivation
.
Returns the PZipTags
to be used for new PZip files using
this key derivation.
Generally, this should return suitable random defaults for any derivation
parameters. Specifically, for HKDF, this returns a
Tag::Salt
with a number of random bytes equal to
the hash length. For PBKDF2, this returns a similar
Tag::Salt
as well as a
Tag::Iterations
specifying the number of
PBKDF2 rounds.
sourcepub fn derive(
&self,
material: &[u8],
algorithm: Algorithm,
tags: &PZipTags
) -> Result<Vec<u8>, Error>
pub fn derive(
&self,
material: &[u8],
algorithm: Algorithm,
tags: &PZipTags
) -> Result<Vec<u8>, Error>
Derives key bytes from input key material for the specified
Algorithm
, using parameters found in tags
.
The number of bytes returned depends on the length of the key expected by the algorithm.
Trait Implementations
sourceimpl Clone for KeyDerivation
impl Clone for KeyDerivation
sourcefn clone(&self) -> KeyDerivation
fn clone(&self) -> KeyDerivation
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for KeyDerivation
impl Debug for KeyDerivation
sourceimpl Hash for KeyDerivation
impl Hash for KeyDerivation
sourceimpl PartialEq<KeyDerivation> for KeyDerivation
impl PartialEq<KeyDerivation> for KeyDerivation
impl Copy for KeyDerivation
impl Eq for KeyDerivation
impl StructuralEq for KeyDerivation
impl StructuralPartialEq for KeyDerivation
Auto Trait Implementations
impl RefUnwindSafe for KeyDerivation
impl Send for KeyDerivation
impl Sync for KeyDerivation
impl Unpin for KeyDerivation
impl UnwindSafe for KeyDerivation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more