pub trait HostWithStore<T>: HasData + Send {
// Required methods
fn import_public_key_raw(
accessor: &Accessor<T, Self>,
raw: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send;
fn import_public_key_spki(
accessor: &Accessor<T, Self>,
spki: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send;
fn import_public_key_jwk(
accessor: &Accessor<T, Self>,
jwk: String,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send;
fn import_secret_key_jwk(
accessor: &Accessor<T, Self>,
jwk: String,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send;
fn import_secret_key_pkcs8(
accessor: &Accessor<T, Self>,
pkcs8: Vec<u8>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send;
fn generate_key(
accessor: &Accessor<T, Self>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<(Resource<SecretKey>, Resource<PublicKey>), Error>>> + Send;
fn unwrap_secret_key_jwk(
accessor: &Accessor<T, Self>,
input: Resource<UnwrapInput>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send;
fn unwrap_secret_key_pkcs8(
accessor: &Accessor<T, Self>,
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>,
raw: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
fn import_public_key_raw( accessor: &Accessor<T, Self>, raw: Vec<u8>, ) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
Import a raw 32-byte RFC 7748 u-coordinate as a public key.
Import is deliberately permissive, as the platform’s is: any
32-byte string is accepted (the high bit is masked at use, per RFC
7748), and degenerate keys — small-order points, non-canonical
encodings, points on the twist — are not rejected here. A
small-order key surfaces at agree as error.invalid-key (the
all-zero check); material of any other length fails
error.invalid-key at import.
Sourcefn import_public_key_spki(
accessor: &Accessor<T, Self>,
spki: Vec<u8>,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
fn import_public_key_spki( accessor: &Accessor<T, Self>, spki: Vec<u8>, ) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
Import a public key as an X.509 SubjectPublicKeyInfo (DER, RFC
8410 algorithm id 1.3.101.110). The embedded u-coordinate is
admitted exactly as import-public-key-raw admits it.
Sourcefn import_public_key_jwk(
accessor: &Accessor<T, Self>,
jwk: String,
) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
fn import_public_key_jwk( accessor: &Accessor<T, Self>, jwk: String, ) -> impl Future<Output = Result<Result<Resource<PublicKey>, Error>>> + Send
Import a public key as an RFC 8037 OKP public JWK (kty: "OKP",
crv: "X25519", x). jwk is the JWK as JSON text; see
mac-key.export-key-jwk for the package-wide JWK contract.
Sourcefn import_secret_key_jwk(
accessor: &Accessor<T, Self>,
jwk: String,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn import_secret_key_jwk( accessor: &Accessor<T, Self>, jwk: String, options: Resource<AgreementKeyOptions>, ) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
Import a static secret key as an RFC 8037 OKP private JWK
(kty: "OKP", crv: "X25519", with x and d both required —
RFC 8037 makes the public coordinate mandatory, so this is
inherently the public+private form).
jwk is the JWK as JSON text; the implementation owns the parse
(see mac-key.export-key-jwk for the package-wide JWK contract,
including ext validation against the options’ extractability).
d is the 32-byte scalar, clamped at use per RFC 7748.
Security:
- Implementations MAY reject a JWK whose
xis not the public key ofdwitherror.invalid-key, and MUST NOT trustxfor 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>,
pkcs8: Vec<u8>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn import_secret_key_pkcs8( accessor: &Accessor<T, Self>, 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, RFC
8410: the 32-byte scalar in a CurvePrivateKey). The scalar is
clamped at use per RFC 7748, like the JWK import’s d.
Sourcefn generate_key(
accessor: &Accessor<T, Self>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<(Resource<SecretKey>, Resource<PublicKey>), Error>>> + Send
fn generate_key( accessor: &Accessor<T, Self>, options: Resource<AgreementKeyOptions>, ) -> impl Future<Output = Result<Result<(Resource<SecretKey>, Resource<PublicKey>), Error>>> + Send
Generate a fresh X25519 key pair.
Sourcefn unwrap_secret_key_jwk(
accessor: &Accessor<T, Self>,
input: Resource<UnwrapInput>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn unwrap_secret_key_jwk( accessor: &Accessor<T, Self>, 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 OKP 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>,
input: Resource<UnwrapInput>,
options: Resource<AgreementKeyOptions>,
) -> impl Future<Output = Result<Result<Resource<SecretKey>, Error>>> + Send
fn unwrap_secret_key_pkcs8( accessor: &Accessor<T, Self>, 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.