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)]
11#[macro_use]
12pub mod test_utils;
13mod build_metadata;
16mod ephemeral;
17mod error;
18mod group_store;
19
20pub mod e2e_identity;
22pub mod mls;
24#[cfg(feature = "proteus")]
26pub mod proteus;
27pub mod transaction_context;
28
29pub use core_crypto_keystore::{ConnectionType, Database, DatabaseKey};
30#[cfg(test)]
31pub use core_crypto_macros::{dispotent, durable, idempotent};
32pub use mls_crypto_provider::{EntropySeed, MlsCryptoProvider, RawEntropySeed};
33pub use openmls::{
34 group::{MlsGroup, MlsGroupConfig},
35 prelude::{
36 Ciphersuite as CiphersuiteName, Credential, GroupEpoch, KeyPackage, KeyPackageIn, KeyPackageRef, MlsMessageIn,
37 Node, group_info::VerifiableGroupInfo,
38 },
39};
40#[cfg(feature = "proteus")]
41use {async_lock::Mutex, std::sync::Arc};
42
43pub use crate::{
44 build_metadata::{BUILD_METADATA, BuildMetadata},
45 e2e_identity::{
46 E2eiEnrollment,
47 device_status::DeviceStatus,
48 identity::{WireIdentity, X509Identity},
49 types::{E2eiAcmeChallenge, E2eiAcmeDirectory, E2eiNewAcmeAuthz, E2eiNewAcmeOrder},
50 },
51 ephemeral::{HISTORY_CLIENT_ID_PREFIX, HistorySecret},
52 error::{
53 Error, InnermostErrorMessage, KeystoreError, LeafError, MlsError, MlsErrorKind, ProteusError, ProteusErrorKind,
54 RecursiveError, Result, ToRecursiveError,
55 },
56 mls::{
57 ciphersuite::MlsCiphersuite,
58 conversation::{
59 ConversationId, MlsConversation,
60 commit::MlsCommitBundle,
61 config::{MlsConversationConfiguration, MlsCustomConfiguration, MlsWirePolicy},
62 conversation_guard::decrypt::{MlsBufferedConversationDecryptMessage, MlsConversationDecryptMessage},
63 group_info::{GroupInfoPayload, MlsGroupInfoBundle, MlsGroupInfoEncryptionType, MlsRatchetTreeType},
64 proposal::MlsProposalBundle,
65 welcome::WelcomeBundle,
66 },
67 credential::{typ::MlsCredentialType, x509::CertificateBundle},
68 proposal::{MlsProposal, MlsProposalRef},
69 session::{
70 EpochObserver, HistoryObserver, Session,
71 config::{SessionConfig, ValidatedSessionConfig},
72 id::ClientId,
73 identifier::ClientIdentifier,
74 key_package::INITIAL_KEYING_MATERIAL_COUNT,
75 user_id::UserId,
76 },
77 },
78 transaction_context::e2e_identity::conversation_state::E2eiConversationState,
79};
80
81pub enum MlsTransportResponse {
83 Success,
85 Retry,
87 Abort {
89 reason: String,
91 },
92}
93
94#[derive(Debug, derive_more::From, derive_more::Deref, serde::Serialize, serde::Deserialize)]
97pub struct MlsTransportData(pub Vec<u8>);
98
99#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
102#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
103pub trait MlsTransport: std::fmt::Debug + Send + Sync {
104 async fn send_commit_bundle(&self, commit_bundle: MlsCommitBundle) -> Result<MlsTransportResponse>;
106 async fn send_message(&self, mls_message: Vec<u8>) -> Result<MlsTransportResponse>;
108
109 async fn prepare_for_transport(&self, secret: &HistorySecret) -> Result<MlsTransportData>;
116}
117
118#[derive(Debug, Clone)]
124pub struct CoreCrypto {
125 mls: mls::session::Session,
126 #[cfg(feature = "proteus")]
127 proteus: Arc<Mutex<Option<proteus::ProteusCentral>>>,
128 #[cfg(not(feature = "proteus"))]
129 #[allow(dead_code)]
130 proteus: (),
131}
132
133impl From<mls::session::Session> for CoreCrypto {
134 fn from(mls: mls::session::Session) -> Self {
135 Self {
136 mls,
137 proteus: Default::default(),
138 }
139 }
140}
141
142impl std::ops::Deref for CoreCrypto {
143 type Target = mls::session::Session;
144
145 fn deref(&self) -> &Self::Target {
146 &self.mls
147 }
148}
149
150impl std::ops::DerefMut for CoreCrypto {
151 fn deref_mut(&mut self) -> &mut Self::Target {
152 &mut self.mls
153 }
154}
155
156impl CoreCrypto {
157 #[inline]
159 pub fn take(self) -> mls::session::Session {
160 self.mls
161 }
162}