core_crypto_ffi/core_crypto/e2ei/
mod.rs1use core_crypto::RecursiveError;
2#[cfg(target_family = "wasm")]
3use wasm_bindgen::prelude::*;
4
5use crate::{Ciphersuite, CoreCrypto, CoreCryptoResult};
6
7pub(crate) mod identities;
8
9#[derive(Debug, Clone)]
10#[cfg_attr(
11 target_family = "wasm",
12 wasm_bindgen(getter_with_clone),
13 derive(serde::Serialize, serde::Deserialize)
14)]
15#[cfg_attr(not(target_family = "wasm"), derive(uniffi::Record))]
16pub struct E2eiDumpedPkiEnv {
18 #[cfg_attr(target_family = "wasm", wasm_bindgen(readonly))]
19 pub root_ca: String,
21 #[cfg_attr(target_family = "wasm", wasm_bindgen(readonly))]
22 pub intermediates: Vec<String>,
24 #[cfg_attr(target_family = "wasm", wasm_bindgen(readonly))]
25 pub crls: Vec<String>,
27}
28
29impl From<core_crypto::e2e_identity::E2eiDumpedPkiEnv> for E2eiDumpedPkiEnv {
30 fn from(value: core_crypto::e2e_identity::E2eiDumpedPkiEnv) -> Self {
31 Self {
32 root_ca: value.root_ca,
33 intermediates: value.intermediates,
34 crls: value.crls,
35 }
36 }
37}
38
39#[cfg_attr(target_family = "wasm", wasm_bindgen)]
41#[cfg_attr(not(target_family = "wasm"), uniffi::export)]
42impl CoreCrypto {
43 pub async fn e2ei_dump_pki_env(&self) -> CoreCryptoResult<Option<E2eiDumpedPkiEnv>> {
44 let dumped_pki_env = self
45 .inner
46 .e2ei_dump_pki_env()
47 .await
48 .map_err(RecursiveError::mls_client("dumping pki env"))?;
49 Ok(dumped_pki_env.map(Into::into))
50 }
51
52 pub async fn e2ei_is_pki_env_setup(&self) -> bool {
54 self.inner.e2ei_is_pki_env_setup().await
55 }
56
57 pub async fn e2ei_is_enabled(&self, ciphersuite: Ciphersuite) -> CoreCryptoResult<bool> {
59 let signature_scheme =
60 core_crypto::prelude::MlsCiphersuite::from(core_crypto::prelude::CiphersuiteName::from(ciphersuite))
61 .signature_algorithm();
62 self.inner
63 .e2ei_is_enabled(signature_scheme)
64 .await
65 .map_err(RecursiveError::mls_client("checking if e2ei is enabled"))
66 .map_err(Into::into)
67 }
68}