// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // Copyright by contributors to this project. // SPDX-License-Identifier: (Apache-2.0 OR MIT)
use alloc::boxed::Box; use core::convert::Infallible; use mls_rs_core::{
error::IntoAnyError, extension::ExtensionList, group::Member, identity::SigningIdentity,
};
/// The source of the commit: either a current member or a new member joining /// via external commit. #[derive(Clone, Debug, PartialEq, Eq)] pubenum CommitSource {
ExistingMember(Member),
NewMember(SigningIdentity),
}
/// A set of user controlled rules that customize the behavior of MLS. #[cfg_attr(not(mls_build_async), maybe_async::must_be_sync)] #[cfg_attr(mls_build_async, maybe_async::must_be_async)] pubtrait MlsRules: Send + Sync { type Error: IntoAnyError;
/// This is called when preparing or receiving a commit to pre-process the set of committed /// proposals. /// /// Both proposals received during the current epoch and at the time of commit /// will be presented for validation and filtering. Filter and validate will /// present a raw list of proposals. Standard MLS rules are applied internally /// on the result of these rules. /// /// Each member of a group MUST apply the same proposal rules in order to /// maintain a working group. /// /// Typically, any invalid proposal should result in an error. The exception are invalid /// by-reference proposals processed when _preparing_ a commit, which should be filtered /// out instead. This is to avoid the deadlock situation when no commit can be generated /// after receiving an invalid set of proposal messages. /// /// `ProposalBundle` can be arbitrarily modified. For example, a Remove proposal that /// removes a moderator can result in adding a GroupContextExtensions proposal that updates /// the moderator list in the group context. The resulting `ProposalBundle` is validated /// by the library. asyncfn filter_proposals(
&self,
direction: CommitDirection,
source: CommitSource,
current_roster: &Roster,
extension_list: &ExtensionList,
proposals: ProposalBundle,
) -> Result<ProposalBundle, Self::Error>;
/// This is called when preparing a commit to determine various options: whether to enforce an update /// path in case it is not mandated by MLS, whether to include the ratchet tree in the welcome /// message (if the commit adds members) and whether to generate a single welcome message, or one /// welcome message for each added member. /// /// The `new_roster` and `new_extension_list` describe the group state after the commit. fn commit_options(
&self,
new_roster: &Roster,
new_extension_list: &ExtensionList,
proposals: &ProposalBundle,
) -> Result<CommitOptions, Self::Error>;
/// This is called when sending any packet. For proposals and commits, this determines whether to /// encrypt them. For any encrypted packet, this determines the padding mode used. /// /// Note that for commits, the `current_roster` and `current_extension_list` describe the group state /// before the commit, unlike in [commit_options](MlsRules::commit_options). fn encryption_options(
&self,
current_roster: &Roster,
current_extension_list: &ExtensionList,
) -> Result<EncryptionOptions, Self::Error>;
}
impl DefaultMlsRules { /// Create new MLS rules with default settings: do not enforce path and do /// put the ratchet tree in the extension. pubfn new() -> Self {
Default::default()
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.