Skip to content

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

VariantDescription
RawRaw bytes
Pkcs8PKCS#8 DER (private keys)
SpkiSubjectPublicKeyInfo DER (public keys)
JwkJSON Web Key

KeyUsage

VariantWeb Crypto string
Encrypt"encrypt"
Decrypt"decrypt"
Sign"sign"
Verify"verify"
DeriveKey"deriveKey"
DeriveBits"deriveBits"
WrapKey"wrapKey"
UnwrapKey"unwrapKey"