CryptoKey
Opaque wrapper around a Web Crypto CryptoKey object. On wasm32 targets this holds a web_sys::CryptoKey; on other targets it is a zero-size placeholder.
You obtain a CryptoKey through import_key or generate_key, then pass it to operations like sign, encrypt, or derive_key.
CryptoKeyPair
Returned by generate_key for asymmetric algorithms.
rust
pub struct CryptoKeyPair {
pub public_key: CryptoKey,
pub private_key: CryptoKey,
}GenerateKeyResult
rust
pub enum GenerateKeyResult {
Key(CryptoKey), // Symmetric (AES, HMAC)
Pair(CryptoKeyPair), // Asymmetric (RSA, EC, Ed25519, X25519)
}KeyFormat
| Variant | Description |
|---|---|
Raw | Raw bytes |
Pkcs8 | PKCS#8 DER (private keys) |
Spki | SubjectPublicKeyInfo DER (public keys) |
Jwk | JSON Web Key |
KeyUsage
| Variant | Web Crypto string |
|---|---|
Encrypt | "encrypt" |
Decrypt | "decrypt" |
Sign | "sign" |
Verify | "verify" |
DeriveKey | "deriveKey" |
DeriveBits | "deriveBits" |
WrapKey | "wrapKey" |
UnwrapKey | "unwrapKey" |