Skip to main content

DeriveInput

Struct DeriveInput 

Source
pub struct DeriveInput(/* private fields */);
Expand description

A derivation.derive-input: a fully parameterized derivation — base secret plus every parameter, minted by the prepare functions (hkdf_sha2::prepare, pbkdf2_sha2::prepare, …) and by AgreementSecretKey::agree.

Consume it through derive_bits or hand it to a target interface’s derive_key (e.g. hmac_sha2::derive_key, aes_gcm::derive_key); both may run any number of times. While an input is live it may hold derivation state of its own (for HKDF, the PRK), so a base secret’s sensitivity extends to the inputs built on it.

Implementations§

Source§

impl DeriveInput

Source

pub fn from_raw(raw: DeriveInput) -> Self

Wrap a raw derive-input resource.

Source

pub fn as_raw(&self) -> &DeriveInput

Borrow the raw derive-input resource.

Source

pub fn into_raw(self) -> DeriveInput

Unwrap into the raw derive-input resource.

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 the package’s implementations serve sub-byte outputs). None means the source’s natural output length: an agreement’s full shared secret (32 bytes for X25519). KDF sources have none — their output length is a caller choice — so None fails Error::Other there, matching the platform’s own null-length behavior.

Fails Error::NotPermitted without the derive_bits grant.

Source

pub fn can_derive_bits(&self) -> bool

Whether derive_bits (and minting extractable keys) is permitted — the grant copied from the base secret. A refused operation fails Error::NotPermitted.

Source

pub fn can_derive_key(&self) -> bool

Whether the target interfaces’ derive_key is permitted. See can_derive_bits.

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.