1#![doc = include_str!(env!("STRIPPED_README_PATH"))]
7#![cfg_attr(not(test), deny(missing_docs))]
8#![allow(clippy::single_component_path_imports)]
9
10#[cfg(test)]
11pub use core_crypto_macros::{dispotent, durable, idempotent};
12#[cfg(feature = "proteus")]
13use {async_lock::Mutex, std::sync::Arc};
14
15pub use self::error::*;
16
17#[cfg(test)]
18#[macro_use]
19pub mod test_utils;
20mod error;
23
24pub mod mls;
26
27pub mod e2e_identity;
29
30#[cfg(feature = "proteus")]
32pub mod proteus;
33
34mod ephemeral;
35mod group_store;
36pub mod transaction_context;
37
38mod build_metadata;
39use crate::prelude::MlsCommitBundle;
40pub use build_metadata::{BUILD_METADATA, BuildMetadata};
41
42use crate::ephemeral::HistorySecret;
43pub use core_crypto_keystore::DatabaseKey;
44
45pub mod prelude {
47 pub use openmls::{
48 group::{MlsGroup, MlsGroupConfig},
49 prelude::{
50 Ciphersuite as CiphersuiteName, Credential, GroupEpoch, KeyPackage, KeyPackageIn, KeyPackageRef,
51 MlsMessageIn, Node, group_info::VerifiableGroupInfo,
52 },
53 };
54
55 pub use mls_crypto_provider::{EntropySeed, MlsCryptoProvider, RawEntropySeed};
56
57 pub use crate::{
58 CoreCrypto, MlsTransport,
59 e2e_identity::{
60 E2eiEnrollment,
61 device_status::DeviceStatus,
62 identity::{WireIdentity, X509Identity},
63 types::{E2eiAcmeChallenge, E2eiAcmeDirectory, E2eiNewAcmeAuthz, E2eiNewAcmeOrder},
64 },
65 ephemeral::{HISTORY_CLIENT_ID_PREFIX, HistorySecret},
66 error::{Error, KeystoreError, LeafError, MlsError, ProteusError, RecursiveError},
67 mls::{
68 ciphersuite::MlsCiphersuite,
69 conversation::{
70 ConversationId, MlsConversation,
71 commit::MlsCommitBundle,
72 config::{MlsConversationConfiguration, MlsCustomConfiguration, MlsWirePolicy},
73 conversation_guard::decrypt::{MlsBufferedConversationDecryptMessage, MlsConversationDecryptMessage},
74 group_info::{GroupInfoPayload, MlsGroupInfoBundle, MlsGroupInfoEncryptionType, MlsRatchetTreeType},
75 proposal::MlsProposalBundle,
76 welcome::WelcomeBundle,
77 },
78 credential::{typ::MlsCredentialType, x509::CertificateBundle},
79 proposal::{MlsProposal, MlsProposalRef},
80 session::{
81 Session,
82 config::{SessionConfig, ValidatedSessionConfig},
83 id::ClientId,
84 identifier::ClientIdentifier,
85 key_package::INITIAL_KEYING_MATERIAL_COUNT,
86 *,
87 },
88 },
89 transaction_context::e2e_identity::conversation_state::E2eiConversationState,
90 };
91}
92
93pub enum MlsTransportResponse {
95 Success,
97 Retry,
99 Abort {
101 reason: String,
103 },
104}
105
106#[derive(Debug, derive_more::From, derive_more::Deref, serde::Serialize, serde::Deserialize)]
109pub struct MlsTransportData(pub Vec<u8>);
110
111#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
114#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
115pub trait MlsTransport: std::fmt::Debug + Send + Sync {
116 async fn send_commit_bundle(&self, commit_bundle: MlsCommitBundle) -> Result<MlsTransportResponse>;
118 async fn send_message(&self, mls_message: Vec<u8>) -> Result<MlsTransportResponse>;
120
121 async fn prepare_for_transport(&self, secret: &HistorySecret) -> Result<MlsTransportData>;
128}
129
130#[derive(Debug, Clone)]
136pub struct CoreCrypto {
137 mls: mls::session::Session,
138 #[cfg(feature = "proteus")]
139 proteus: Arc<Mutex<Option<proteus::ProteusCentral>>>,
140 #[cfg(not(feature = "proteus"))]
141 #[allow(dead_code)]
142 proteus: (),
143}
144
145impl From<mls::session::Session> for CoreCrypto {
146 fn from(mls: mls::session::Session) -> Self {
147 Self {
148 mls,
149 proteus: Default::default(),
150 }
151 }
152}
153
154impl std::ops::Deref for CoreCrypto {
155 type Target = mls::session::Session;
156
157 fn deref(&self) -> &Self::Target {
158 &self.mls
159 }
160}
161
162impl std::ops::DerefMut for CoreCrypto {
163 fn deref_mut(&mut self) -> &mut Self::Target {
164 &mut self.mls
165 }
166}
167
168impl CoreCrypto {
169 #[inline]
171 pub fn take(self) -> mls::session::Session {
172 self.mls
173 }
174}