Skip to main content

opentalk_roomserver_types_e2ee/
lib.rs

1// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5use bytes::Bytes;
6use opentalk_types_common::modules::{ModuleId, module_id};
7
8mod command;
9mod error;
10mod event;
11
12pub use command::E2eeCommand;
13pub use error::E2eeError;
14pub use event::E2eeEvent;
15
16pub const E2EE_MODULE_ID: ModuleId = module_id!("e2ee");
17
18/// Welcome and ratchet tree sent to the invitee
19#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
20pub struct WelcomeMessage {
21    pub welcome: Bytes,
22    pub ratchet_tree: Bytes,
23}
24
25impl WelcomeMessage {
26    pub fn is_valid(&self) -> bool {
27        !self.welcome.is_empty() && !self.ratchet_tree.is_empty()
28    }
29}
30
31/// Arbitrary encrypted message. This can be any kind of MLS or application message
32#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
33pub struct MlsMessages {
34    pub payload: Vec<Bytes>,
35}
36
37impl MlsMessages {
38    pub fn is_valid(&self) -> bool {
39        !self.payload.is_empty()
40    }
41}