SubtleCrypto
Wrapper for the crypto.subtle interface. Each method is gated behind a feature flag.
Constructor
rust
let subtle = SubtleCrypto::new()?;Methods
Digest (digest feature)
| Method | Signature |
|---|---|
digest | async fn digest(&self, hash: Hash, data: &[u8]) -> Result<CryptoOutput> |
Sign / Verify (sign feature)
| Method | Signature |
|---|---|
sign | async fn sign(&self, algorithm: &Algorithm, key: &CryptoKey, data: &[u8]) -> Result<CryptoOutput> |
verify | async fn verify(&self, algorithm: &Algorithm, key: &CryptoKey, signature: &[u8], data: &[u8]) -> Result<bool> |
Encrypt / Decrypt (encrypt feature)
| Method | Signature |
|---|---|
encrypt | async fn encrypt(&self, algorithm: &Algorithm, key: &CryptoKey, data: &[u8]) -> Result<CryptoOutput> |
decrypt | async fn decrypt(&self, algorithm: &Algorithm, key: &CryptoKey, data: &[u8]) -> Result<CryptoOutput> |
Key Management (key feature)
| Method | Signature |
|---|---|
import_key | async fn import_key(&self, format: KeyFormat, key_data: &[u8], algorithm: &Algorithm, extractable: bool, usages: &[KeyUsage]) -> Result<CryptoKey> |
export_key | async fn export_key(&self, format: KeyFormat, key: &CryptoKey) -> Result<CryptoOutput> |
generate_key | async fn generate_key(&self, params: &GenerateKeyParams, extractable: bool, usages: &[KeyUsage]) -> Result<GenerateKeyResult> |
Key Derivation (derive feature)
| Method | Signature |
|---|---|
derive_key | async fn derive_key(&self, algorithm: &Algorithm, base_key: &CryptoKey, derived_key_type: &GenerateKeyParams, extractable: bool, usages: &[KeyUsage]) -> Result<CryptoKey> |
derive_bits | async fn derive_bits(&self, algorithm: &Algorithm, base_key: &CryptoKey, length: u32) -> Result<CryptoOutput> |
Key Wrapping (wrap feature)
| Method | Signature |
|---|---|
wrap_key | async fn wrap_key(&self, format: KeyFormat, key: &CryptoKey, wrapping_key: &CryptoKey, algorithm: &Algorithm) -> Result<CryptoOutput> |
unwrap_key | async fn unwrap_key(&self, format: KeyFormat, wrapped_key: &[u8], unwrapping_key: &CryptoKey, unwrap_algorithm: &Algorithm, unwrapped_key_algorithm: &Algorithm, extractable: bool, usages: &[KeyUsage]) -> Result<CryptoKey> |