offline_protocol_mls/lib.rs
1//! MLS (Message Layer Security) integration for the Offline Protocol SDK.
2//!
3//! This crate provides end-to-end encryption using the MLS protocol via OpenMLS.
4//! It supports both 1:1 encrypted messaging and group messaging with forward secrecy
5//! and post-compromise security.
6//!
7//! # Architecture
8//!
9//! The crate is designed with a storage-agnostic approach:
10//! - Apps implement the [`MlsStorage`] trait for platform-native secure storage
11//! - The [`MlsManager`] handles all MLS operations (key generation, encryption, decryption)
12//! - Groups are used for both 1:1 sessions (2-person groups) and multi-party chats
13//!
14//! # Example
15//!
16//! ```ignore
17//! use offline_protocol_mls::{MlsManager, MlsStorage};
18//!
19//! // Implement MlsStorage for your platform (iOS Keychain, Android Keystore, etc.)
20//! let storage = MyPlatformStorage::new();
21//!
22//! // Create the MLS manager
23//! let manager = MlsManager::new("user123", Box::new(storage))?;
24//!
25//! // Generate a key package to share with others
26//! let key_package = manager.generate_key_package()?;
27//!
28//! // Create a 1:1 session and send an encrypted message
29//! let ciphertext = manager.encrypt_for_user("bob", b"Hello, Bob!")?;
30//! ```
31
32#![deny(unsafe_code)]
33#![warn(missing_docs)]
34
35pub mod discovery;
36pub mod error;
37pub mod group;
38pub mod invite;
39pub mod manager;
40pub mod provider;
41pub mod session;
42pub mod storage;
43mod storage_adapter;
44pub mod types;
45
46// `LeafSource` rides here with `MlsError` because it is a public field type on
47// a public variant: matching on `LeafAddressMismatch { context, .. }` should not
48// need a deeper path than the error it came out of.
49pub use error::{LeafSource, MlsError, Result};
50pub use manager::{is_mls_framed, MlsManager, PushKeyPackage, MAX_PUSH_KEY_PACKAGES};
51pub use storage::{MlsStorage, StorageError};
52pub use types::{
53 EncryptedMessage, GroupId, GroupInfo, GroupMetadata, GroupRole, KeyPackageBundle,
54 MlsMessageType, ParseGroupRoleError, WelcomeMessage,
55};