Struct dryoc::kdf::Kdf

source ·
pub struct Kdf<Key: ByteArray<CRYPTO_KDF_KEYBYTES>, Context: ByteArray<CRYPTO_KDF_CONTEXTBYTES>> { /* private fields */ }
Expand description

Key derivation implementation based on Blake2b, compatible with libsodium’s crypto_kdf_* functions.

Implementations§

source§

impl<Key: NewByteArray<CRYPTO_KDF_KEYBYTES>, Context: NewByteArray<CRYPTO_KDF_CONTEXTBYTES>> Kdf<Key, Context>

source

pub fn gen() -> Self

Randomly generates a new pair of main key and context.

source§

impl<Key: ByteArray<CRYPTO_KDF_KEYBYTES>, Context: ByteArray<CRYPTO_KDF_CONTEXTBYTES>> Kdf<Key, Context>

source

pub fn derive_subkey<Subkey: NewByteArray<CRYPTO_KDF_KEYBYTES>>( &self, subkey_id: u64 ) -> Result<Subkey, Error>

Derives a subkey for subkey_id, returning it.

source

pub fn derive_subkey_to_vec(&self, subkey_id: u64) -> Result<Vec<u8>, Error>

Derives a subkey for subkey_id, returning it as a Vec. Provided for convenience.

source

pub fn from_parts(main_key: Key, context: Context) -> Self

Constructs a new instance from key and context, consuming them both.

source

pub fn into_parts(self) -> (Key, Context)

Moves the key and context out of this instance, returning them as a tuple.

source§

impl Kdf<Key, Context>

source

pub fn gen_with_defaults() -> Self

Randomly generates a new pair of main key and context.

Trait Implementations§

source§

impl<Key: Clone + ByteArray<CRYPTO_KDF_KEYBYTES>, Context: Clone + ByteArray<CRYPTO_KDF_CONTEXTBYTES>> Clone for Kdf<Key, Context>

source§

fn clone(&self) -> Kdf<Key, Context>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Key: Debug + ByteArray<CRYPTO_KDF_KEYBYTES>, Context: Debug + ByteArray<CRYPTO_KDF_CONTEXTBYTES>> Debug for Kdf<Key, Context>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, Key, Context> Deserialize<'de> for Kdf<Key, Context>where Key: Deserialize<'de> + ByteArray<CRYPTO_KDF_KEYBYTES>, Context: Deserialize<'de> + ByteArray<CRYPTO_KDF_CONTEXTBYTES>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Key, Context> Serialize for Kdf<Key, Context>where Key: Serialize + ByteArray<CRYPTO_KDF_KEYBYTES>, Context: Serialize + ByteArray<CRYPTO_KDF_CONTEXTBYTES>,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Key, Context> Zeroize for Kdf<Key, Context>where Key: Zeroize + ByteArray<CRYPTO_KDF_KEYBYTES>, Context: Zeroize + ByteArray<CRYPTO_KDF_CONTEXTBYTES>,

source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl<Key, Context> RefUnwindSafe for Kdf<Key, Context>where Context: RefUnwindSafe, Key: RefUnwindSafe,

§

impl<Key, Context> Send for Kdf<Key, Context>where Context: Send, Key: Send,

§

impl<Key, Context> Sync for Kdf<Key, Context>where Context: Sync, Key: Sync,

§

impl<Key, Context> Unpin for Kdf<Key, Context>where Context: Unpin, Key: Unpin,

§

impl<Key, Context> UnwindSafe for Kdf<Key, Context>where Context: UnwindSafe, Key: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,