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
prepareretains only the PRK and drops the IKM copy).
Implementations§
Source§impl DeriveInput
impl DeriveInput
Sourcepub fn can_derive_bits(&self) -> bool
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
impl DeriveInput
Sourcepub fn can_derive_key(&self) -> bool
pub fn can_derive_key(&self) -> bool
Whether the target interfaces’ derive-key is permitted. See
derive-options.can-derive-key.
Source§impl DeriveInput
impl DeriveInput
Sourcepub async fn derive_bits(&self, length: Option<u32>) -> Result<Vec<u8>, Error>
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.