pub trait HostCipherKeyWithStore<T>: HasData + Send {
// Required methods
fn drop(
accessor: &Accessor<T, Self>,
rep: Resource<CipherKey>,
) -> impl Future<Output = Result<()>> + Send
where Self: Sized;
fn encrypt(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
plaintext: StreamReader<u8>,
) -> impl Future<Output = Result<Result<StreamReader<u8>, Error>>> + Send;
fn decrypt(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
ciphertext: StreamReader<u8>,
) -> impl Future<Output = Result<Result<StreamReader<u8>, Error>>> + Send;
fn wrap(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
input: Resource<WrapInput>,
) -> impl Future<Output = Result<Result<Vec<u8>, Error>>> + Send;
fn unwrap(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
wrapped: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<UnwrapInput>, Error>>> + Send;
fn export_key_raw(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
) -> impl Future<Output = Result<Result<Vec<u8>, Error>>> + Send;
fn export_key_jwk(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
) -> impl Future<Output = Result<Result<String, Error>>> + Send;
fn to_wrap_input_raw(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
) -> impl Future<Output = Result<Result<Resource<WrapInput>, Error>>> + Send;
fn to_wrap_input_jwk(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
) -> impl Future<Output = Result<Result<Resource<WrapInput>, Error>>> + Send;
}Required Methods§
fn drop(
accessor: &Accessor<T, Self>,
rep: Resource<CipherKey>,
) -> impl Future<Output = Result<()>> + Sendwhere
Self: Sized,
Sourcefn encrypt(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
plaintext: StreamReader<u8>,
) -> impl Future<Output = Result<Result<StreamReader<u8>, Error>>> + Send
fn encrypt( accessor: &Accessor<T, Self>, self_: Resource<CipherKey>, iv: Vec<u8>, counter_length: Option<u8>, plaintext: StreamReader<u8>, ) -> impl Future<Output = Result<Result<StreamReader<u8>, Error>>> + Send
Encrypt plaintext under iv. The returned stream carries
exactly the ciphertext (the crypto.subtle.encrypt wire
format; for padded modes that includes the final padding
block).
iv must be the algorithm’s block-sized IV (the iv-size
getter), else error.invalid-nonce. counter-length is the
counter width in bits for counter-mode algorithms (AES-CTR:
required, 1 to 128); algorithms without a counter reject a
supplied value, and counter-mode algorithms reject none —
both error.invalid-nonce. Callers of non-counter algorithms
pass none and never match on algorithm-name.
Security:
- The caller owns the IV discipline (see the interface doc and the minting interface). Getting it wrong loses confidentiality, not just integrity.
Sourcefn decrypt(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
ciphertext: StreamReader<u8>,
) -> impl Future<Output = Result<Result<StreamReader<u8>, Error>>> + Send
fn decrypt( accessor: &Accessor<T, Self>, self_: Resource<CipherKey>, iv: Vec<u8>, counter_length: Option<u8>, ciphertext: StreamReader<u8>, ) -> impl Future<Output = Result<Result<StreamReader<u8>, Error>>> + Send
Decrypt ciphertext under iv. See encrypt for the iv
and counter-length contracts.
Security:
- The plaintext is unauthenticated: treat it as attacker-influenced data even when decryption succeeds.
- Malformed input fails
error.other, deliberately uniform across conditions (see the interface doc).
Sourcefn wrap(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
input: Resource<WrapInput>,
) -> impl Future<Output = Result<Result<Vec<u8>, Error>>> + Send
fn wrap( accessor: &Accessor<T, Self>, self_: Resource<CipherKey>, iv: Vec<u8>, counter_length: Option<u8>, input: Resource<WrapInput>, ) -> impl Future<Output = Result<Result<Vec<u8>, Error>>> + Send
Encrypt serialized key material under iv, exactly as
encrypt encrypts a message: for raw-format material the
result is byte-identical to encrypting the exported bytes
(the W3C Web Cryptography API’s wrapKey under an
encryption algorithm). See encrypt for the iv and
counter-length contracts; see the wrapping interface for
the model.
Security:
- Nothing here authenticates, and the caller owns the IV
discipline, as on
encrypt. Prefer anaeadorkw-keywrapping key; use this one only where an existing format fixes the mode. wrapandencryptdraw on the same key’s IV space: the algorithm’s uniqueness obligations (per-key uniqueness of CTR counter blocks above all) span both operations.
input is consumed. Requires can-wrap, else
error.not-permitted.
Sourcefn unwrap(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
iv: Vec<u8>,
counter_length: Option<u8>,
wrapped: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<UnwrapInput>, Error>>> + Send
fn unwrap( accessor: &Accessor<T, Self>, self_: Resource<CipherKey>, iv: Vec<u8>, counter_length: Option<u8>, wrapped: Vec<u8>, ) -> impl Future<Output = Result<Result<Resource<UnwrapInput>, Error>>> + Send
Decrypt wrapped key material, as produced by wrap (or by
encrypt over the same serialization) under iv. See
encrypt for the iv and counter-length contracts. The
result awaits an unwrap mint (see unwrap-input); the
material never reaches the caller.
Security:
- The result is unauthenticated: a success is no evidence
the wrapped material is untampered, and the typed mint’s
parse is not authentication. Malformed input fails
error.other, deliberately uniform across conditions (see the interface doc) — here, or at the consuming mint when decryption is deferred (seeunwrap-input).
Requires can-unwrap, else error.not-permitted.
Sourcefn export_key_raw(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
) -> impl Future<Output = Result<Result<Vec<u8>, Error>>> + Send
fn export_key_raw( accessor: &Accessor<T, Self>, self_: Resource<CipherKey>, ) -> impl Future<Output = Result<Result<Vec<u8>, Error>>> + Send
The raw key material. Fails with error.not-extractable unless
the key was created with extractable true.
Sourcefn export_key_jwk(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
) -> impl Future<Output = Result<Result<String, Error>>> + Send
fn export_key_jwk( accessor: &Accessor<T, Self>, self_: Resource<CipherKey>, ) -> impl Future<Output = Result<Result<String, Error>>> + Send
The key as an RFC 7517 JSON Web Key, behind the same
extractability gate as export-key-raw. See README.md,
“JWK contract”.
Sourcefn to_wrap_input_raw(
accessor: &Accessor<T, Self>,
self_: Resource<CipherKey>,
) -> impl Future<Output = Result<Result<Resource<WrapInput>, Error>>> + Send
fn to_wrap_input_raw( accessor: &Accessor<T, Self>, self_: Resource<CipherKey>, ) -> impl Future<Output = Result<Result<Resource<WrapInput>, Error>>> + Send
This key’s raw material as a wrap-input, for wrapping
under another key (see the wrapping interface). Behind the
same extractability gate as export-key-raw; the material
itself never reaches the caller.
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.