Skip to main content

HostWithStore

Trait HostWithStore 

Source
pub trait HostWithStore<T>: HasData + Send {
    // Required methods
    fn import_key_raw(
        accessor: &Accessor<T, Self>,
        variant: AesVariant,
        raw: Vec<u8>,
        options: Resource<AeadKeyOptions>,
    ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send;
    fn import_key_jwk(
        accessor: &Accessor<T, Self>,
        variant: AesVariant,
        jwk: String,
        options: Resource<AeadKeyOptions>,
    ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send;
    fn generate_key(
        accessor: &Accessor<T, Self>,
        variant: AesVariant,
        options: Resource<AeadKeyOptions>,
    ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send;
    fn derive_key(
        accessor: &Accessor<T, Self>,
        variant: AesVariant,
        input: Resource<DeriveInput>,
        options: Resource<AeadKeyOptions>,
    ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send;
    fn unwrap_key_raw(
        accessor: &Accessor<T, Self>,
        variant: AesVariant,
        input: Resource<UnwrapInput>,
        options: Resource<AeadKeyOptions>,
    ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send;
    fn unwrap_key_jwk(
        accessor: &Accessor<T, Self>,
        variant: AesVariant,
        input: Resource<UnwrapInput>,
        options: Resource<AeadKeyOptions>,
    ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send;
}

Required Methods§

Source

fn import_key_raw( accessor: &Accessor<T, Self>, variant: AesVariant, raw: Vec<u8>, options: Resource<AeadKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send

Import raw key material as the declared AES variant.

variant is deliberately redundant with raw’s length: material of any other length fails with error.invalid-key, so malformed material (for example, key bytes accidentally left hex-encoded) cannot silently mint a key of an unintended size. An implementation not serving the variant (AES-192 is declined everywhere — see the aes-variant doc) fails with error.unsupported.

Source

fn import_key_jwk( accessor: &Accessor<T, Self>, variant: AesVariant, jwk: String, options: Resource<AeadKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send

Import an RFC 7517 JSON Web Key as an AES-GCM key of the declared variant.

jwk is the JWK as JSON text; the implementation owns the parse (see README.md, “JWK contract”). The key must be an oct key whose alg, if present, names the declared variant ("A128GCM"/"A192GCM"/"A256GCM"); the decoded material is then subject to import-key-raw’s contract.

Source

fn generate_key( accessor: &Accessor<T, Self>, variant: AesVariant, options: Resource<AeadKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send

Generate a fresh random key of the given AES variant. Fails with error.unsupported if this implementation does not serve the variant.

Source

fn derive_key( accessor: &Accessor<T, Self>, variant: AesVariant, input: Resource<DeriveInput>, options: Resource<AeadKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send

Mint a key from a parameterized derivation: the derivation runs at the variant’s key length (WebCrypto’s deriveKey chain — get key length, derive bits, import) and the result is subject to import-key-raw’s contract.

Requires can-derive-key on the input, else error.not-permitted. Requesting an extractable key requires can-derive-bits too: an exportable key is bits disclosure by other means.

Source

fn unwrap_key_raw( accessor: &Accessor<T, Self>, variant: AesVariant, input: Resource<UnwrapInput>, options: Resource<AeadKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send

Mint a key from unwrapped key material (see the wrapping interface): input’s bytes are read as raw key material, subject to import-key-raw’s contract. input is consumed.

The minted key’s usages and extractability come from options alone (the W3C Web Cryptography API’s unwrapKey model).

Source

fn unwrap_key_jwk( accessor: &Accessor<T, Self>, variant: AesVariant, input: Resource<UnwrapInput>, options: Resource<AeadKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<AeadKey>, Error>>> + Send

Mint a key from unwrapped key material read as an RFC 7517 JSON Web Key, subject to import-key-jwk’s contract plus the unwrap-path use/key_ops checks (see README.md, “JWK contract”). input is consumed; see unwrap-key-raw for the options model.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§