Skip to main content

DeriveInput

Struct DeriveInput 

Source
pub struct DeriveInput { /* private fields */ }
Expand description

A fully parameterized derivation. The output may already be computed, or the computation may still be pending.

Grants are copied from the base secret (or upstream input) at construction; parameterization neither grants nor revokes.

Security:

  • An implementation may run the derivation as soon as the input is constructed, or wait until the input is used. While the computation is pending, the input holds its own copy of the base secret, so a secret stays in memory as long as any resource derived from it. Implementations SHOULD NOT keep a base secret in memory longer than the resources that denote it, and SHOULD compute early where that shortens the window (for HKDF, the extract step at prepare retains only the PRK and drops the IKM copy).

Implementations§

Source§

impl DeriveInput

Source

pub fn can_derive_bits(&self) -> bool

Whether derive-bits (and minting extractable keys) is permitted. See derive-options.can-derive-bits.

Source§

impl DeriveInput

Source

pub fn can_derive_key(&self) -> bool

Whether the target interfaces’ derive-key is permitted. See derive-options.can-derive-key.

Source§

impl DeriveInput

Source

pub async fn derive_bits(&self, length: Option<u32>) -> Result<Vec<u8>, Error>

The derived bits.

length is in bits, WebCrypto’s denomination for this parameter, and must be a multiple of 8 — none of this package’s implementations serve sub-byte outputs (the platform zero-pads them; a consumer wanting truncation truncates). none means the source’s natural output length; sources without one — every KDF, whose output length is a caller choice — fail error.other, which is the platform’s own null-length behavior for them (HKDF and PBKDF2 throw OperationError where the agreements return the whole secret).

Fails error.not-permitted without the can-derive-bits grant. Fallible even when granted: a platform-resident source may be usable but unreadable.

Trait Implementations§

Source§

impl Debug for DeriveInput

Source§

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

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

impl From<DeriveInput> for DeriveInput

Source§

fn from(raw: DeriveInput) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

§

impl<T> Resource for T
where T: 'static,

§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.