polymorph_webcrypto_guest/
aes_cbc.rs1use crate::{bindings, CipherKey, CipherKeyOptions, Error};
5
6pub use crate::bindings::aes_cbc::AesVariant;
7
8pub async fn import_key_raw(
10 variant: AesVariant,
11 raw: impl Into<Vec<u8>>,
12 options: CipherKeyOptions,
13) -> Result<CipherKey, Error> {
14 Ok(CipherKey::from_raw(
15 bindings::aes_cbc::import_key_raw(variant, raw.into(), options.lower()).await?,
16 ))
17}
18
19pub async fn import_key_jwk(
23 variant: AesVariant,
24 jwk: impl Into<String>,
25 options: CipherKeyOptions,
26) -> Result<CipherKey, Error> {
27 Ok(CipherKey::from_raw(
28 bindings::aes_cbc::import_key_jwk(variant, jwk.into(), options.lower()).await?,
29 ))
30}
31
32pub async fn generate_key(
34 variant: AesVariant,
35 options: CipherKeyOptions,
36) -> Result<CipherKey, Error> {
37 Ok(CipherKey::from_raw(
38 bindings::aes_cbc::generate_key(variant, options.lower()).await?,
39 ))
40}
41
42pub async fn derive_key(
46 variant: AesVariant,
47 input: &crate::DeriveInput,
48 options: CipherKeyOptions,
49) -> Result<CipherKey, Error> {
50 Ok(CipherKey::from_raw(
51 bindings::aes_cbc::derive_key(variant, input.as_raw(), options.lower()).await?,
52 ))
53}