pub trait HostWithStore<T>: HasData + Send {
// Required methods
fn import_public_key_raw(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
raw: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send;
fn import_public_key_spki(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
spki: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send;
fn import_public_key_jwk(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
jwk: String,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send;
fn import_secret_key_jwk(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
jwk: String,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send;
fn import_secret_key_pkcs8(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
pkcs8: Vec<u8>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send;
fn generate_key(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<(Resource<SecretKey>, Resource<PublicKey>), Error>>> + Send;
fn unwrap_secret_key_jwk(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
input: Resource<UnwrapInput>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send;
fn unwrap_secret_key_pkcs8(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
input: Resource<UnwrapInput>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send;
}Required Methods§
Sourcefn import_public_key_raw(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
raw: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
fn import_public_key_raw( accessor: &Accessor<T, Self>, variant: EcdhVariant, raw: Vec<u8>, ) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
Import a public key as an uncompressed SEC1 point (04 ‖ x ‖ y;
65 bytes for P-256, 97 bytes for P-384 — WebCrypto’s raw
format). Anything else — including compressed points and points
not on the declared variant’s curve — fails with
error.invalid-key. public-key.export-key-raw returns this
same form.
Sourcefn import_public_key_spki(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
spki: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
fn import_public_key_spki( accessor: &Accessor<T, Self>, variant: EcdhVariant, spki: Vec<u8>, ) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
Import a public key as an X.509 SubjectPublicKeyInfo (DER). The
curve must be named by OID and must match the declared variant’s,
or the import fails with error.invalid-key: an encoding that
carries explicit ECParameters instead of the named-curve OID is
rejected even when the parameters describe the variant’s curve. A
point not on the curve is always rejected. An uncompressed point
is always accepted; whether a compressed encoding is accepted is
implementation-defined, as it is across WebCrypto engines — do not
rely on either behavior.
Sourcefn import_public_key_jwk(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
jwk: String,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
fn import_public_key_jwk( accessor: &Accessor<T, Self>, variant: EcdhVariant, jwk: String, ) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
Import a public key as an EC public JWK (kty: "EC", with crv,
x, and y). jwk is the JWK as JSON text; see
mac-key.export-key-jwk for the package-wide JWK contract
(alg is ignored entirely, WebCrypto’s rule for the ECDH
family). The JWK’s crv must match the declared variant’s curve
(error.invalid-key otherwise), and the encoded point is
admitted exactly as import-public-key-raw admits it.
Sourcefn import_secret_key_jwk(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
jwk: String,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn import_secret_key_jwk( accessor: &Accessor<T, Self>, variant: EcdhVariant, jwk: String, options: Resource<AgreementKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
Import a static secret key as an EC private JWK (kty: "EC",
with crv, d, and the public coordinates x/y, which RFC
7518 makes mandatory — this is inherently the public+private
form). jwk is the JWK as JSON text; see mac-key.export-key-jwk
for the package-wide JWK contract, including ext validation
against the options’ extractability. d is the curve’s scalar
and must lie in [1, n-1] (error.invalid-key otherwise).
Security:
- Implementations MAY reject a JWK whose
x/yis not the public point ofdwitherror.invalid-key, and MUST NOT trustx/yfor any operation: the imported key’s identity isd’s. (The W3C Web Cryptography API’s import steps do not mandate the consistency check, and engines differ, so a platform-backed host cannot promise it.)
Sourcefn import_secret_key_pkcs8(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
pkcs8: Vec<u8>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn import_secret_key_pkcs8( accessor: &Accessor<T, Self>, variant: EcdhVariant, pkcs8: Vec<u8>, options: Resource<AgreementKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
Import a static secret key as a PKCS#8 PrivateKeyInfo (DER, the
RFC 5915 ECPrivateKey body). The encoded curve must match the
declared variant’s (error.invalid-key), and the scalar must lie
in [1, n-1]; an embedded public key, when present, is validated
against the scalar and never trusted on its own.
Sourcefn generate_key(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<(Resource<SecretKey>, Resource<PublicKey>), Error>>> + Send
fn generate_key( accessor: &Accessor<T, Self>, variant: EcdhVariant, options: Resource<AgreementKeyOptions>, ) -> impl Future<Output = Result<Result<(Resource<SecretKey>, Resource<PublicKey>), Error>>> + Send
Generate a fresh key pair on the declared variant’s curve.
Sourcefn unwrap_secret_key_jwk(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
input: Resource<UnwrapInput>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn unwrap_secret_key_jwk( accessor: &Accessor<T, Self>, variant: EcdhVariant, input: Resource<UnwrapInput>, options: Resource<AgreementKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
Mint a static secret key from unwrapped key material (see the
wrapping interface): input’s bytes are read as an EC private
JWK, subject to import-secret-key-jwk’s contract plus the
unwrap-path use/key_ops checks (see README.md, “JWK
contract”). input is consumed.
The minted key’s grants and extractability come from options
alone (the W3C Web Cryptography API’s unwrapKey model).
Sourcefn unwrap_secret_key_pkcs8(
accessor: &Accessor<T, Self>,
variant: EcdhVariant,
input: Resource<UnwrapInput>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn unwrap_secret_key_pkcs8( accessor: &Accessor<T, Self>, variant: EcdhVariant, input: Resource<UnwrapInput>, options: Resource<AgreementKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
Mint a static secret key from unwrapped key material read as a
PKCS#8 PrivateKeyInfo, subject to import-secret-key-pkcs8’s
contract. input is consumed; see unwrap-secret-key-jwk 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.