Skip to main content

derive_key

Function derive_key 

Source
pub async fn derive_key(
    variant: Sha2Variant,
    input: &DeriveInput,
    length: Option<u32>,
    options: MacKeyOptions,
) -> Result<MacKey, Error>
Expand description

Mint a key from a parameterized derivation: the derivation runs at length bits and the result is subject to import-key-raw’s contract.

length follows generate-key’s contract exactly (WebCrypto’s deriveKey computes the derived length by the same get key length step generateKey uses).

Requires can-derive-key on the input, else error.not-permitted; requesting an extractable key additionally requires can-derive-bits (see aes-gcm.derive-key).