// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // Copyright by contributors to this project. // SPDX-License-Identifier: (Apache-2.0 OR MIT)
#[derive(Clone, Debug, PartialEq, MlsSize, MlsEncode, MlsDecode)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] /// A proposal that adds a member to a [`Group`](crate::group::Group). pubstruct AddProposal { pub(crate) key_package: KeyPackage,
}
impl AddProposal { /// The [`KeyPackage`] used by this proposal to add /// a [`Member`](mls_rs_core::group::Member) to the group. pubfn key_package(&self) -> &KeyPackage {
&self.key_package
}
/// The [`SigningIdentity`] of the [`Member`](mls_rs_core::group::Member) /// that will be added by this proposal. pubfn signing_identity(&self) -> &SigningIdentity { self.key_package.signing_identity()
}
/// Client [`Capabilities`] of the [`Member`](mls_rs_core::group::Member) /// that will be added by this proposal. pubfn capabilities(&self) -> Capabilities { self.key_package.leaf_node.ungreased_capabilities()
}
/// Key package extensions that are assoiciated with the /// [`Member`](mls_rs_core::group::Member) that will be added by this proposal. pubfn key_package_extensions(&self) -> ExtensionList { self.key_package.ungreased_extensions()
}
/// Leaf node extensions that will be entered into the group state for the /// [`Member`](mls_rs_core::group::Member) that will be added. pubfn leaf_node_extensions(&self) -> ExtensionList { self.key_package.leaf_node.ungreased_extensions()
}
}
#[cfg(feature = "by_ref_proposal")] #[derive(Clone, Debug, PartialEq, MlsSize, MlsEncode, MlsDecode)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] /// A proposal that will update an existing [`Member`](mls_rs_core::group::Member) of a /// [`Group`](crate::group::Group). pubstruct UpdateProposal { pub(crate) leaf_node: LeafNode,
}
#[cfg(feature = "by_ref_proposal")] impl UpdateProposal { /// The new [`SigningIdentity`] of the [`Member`](mls_rs_core::group::Member) /// that is being updated by this proposal. pubfn signing_identity(&self) -> &SigningIdentity {
&self.leaf_node.signing_identity
}
/// New Client [`Capabilities`] of the [`Member`](mls_rs_core::group::Member) /// that will be updated by this proposal. pubfn capabilities(&self) -> Capabilities { self.leaf_node.ungreased_capabilities()
}
/// New Leaf node extensions that will be entered into the group state for the /// [`Member`](mls_rs_core::group::Member) that is being updated by this proposal. pubfn leaf_node_extensions(&self) -> ExtensionList { self.leaf_node.ungreased_extensions()
}
}
#[derive(Clone, Debug, PartialEq, Eq, MlsSize, MlsEncode, MlsDecode)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] /// A proposal to remove an existing [`Member`](mls_rs_core::group::Member) of a /// [`Group`](crate::group::Group). pubstruct RemoveProposal { pub(crate) to_remove: LeafIndex,
}
impl RemoveProposal { /// The index of the [`Member`](mls_rs_core::group::Member) that will be removed by /// this proposal. pubfn to_remove(&self) -> u32 {
*self.to_remove
}
}
#[cfg(feature = "psk")] #[derive(Clone, Debug, PartialEq, Eq, MlsSize, MlsEncode, MlsDecode)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] /// A proposal to add a pre-shared key to a group. pubstruct PreSharedKeyProposal { pub(crate) psk: PreSharedKeyID,
}
#[cfg(feature = "psk")] impl PreSharedKeyProposal { /// The external pre-shared key id of this proposal. /// /// MLS requires the pre-shared key type for PreSharedKeyProposal to be of /// type `External`. /// /// Returns `None` in the condition that the underlying psk is not external. pubfn external_psk_id(&self) -> Option<&ExternalPskId> { matchself.psk.key_id {
JustPreSharedKeyID::External(ref ext) => Some(ext),
JustPreSharedKeyID::Resumption(_) => None,
}
}
}
#[derive(Clone, PartialEq, MlsSize, MlsEncode, MlsDecode)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] /// A proposal to reinitialize a group using new parameters. pubstruct ReInitProposal { #[mls_codec(with = "mls_rs_codec::byte_vec")] #[cfg_attr(feature = "serde", serde(with = "mls_rs_core::vec_serde"))] pub(crate) group_id: Vec<u8>, pub(crate) version: ProtocolVersion, pub(crate) cipher_suite: CipherSuite, pub(crate) extensions: ExtensionList,
}
impl ReInitProposal { /// The unique id of the new group post reinitialization. pubfn group_id(&self) -> &[u8] {
&self.group_id
}
/// The new protocol version to use post reinitialization. pubfn new_version(&self) -> ProtocolVersion { self.version
}
/// The new ciphersuite to use post reinitialization. pubfn new_cipher_suite(&self) -> CipherSuite { self.cipher_suite
}
/// Group context extensions to set in the new group post reinitialization. pubfn new_group_context_extensions(&self) -> &ExtensionList {
&self.extensions
}
}
#[derive(Clone, PartialEq, Eq, MlsSize, MlsEncode, MlsDecode, Debug)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg(all(
feature = "by_ref_proposal",
feature = "custom_proposal",
feature = "self_remove_proposal"
))] /// A proposal to remove the current [`Member`](mls_rs_core::group::Member) of a /// [`Group`](crate::group::Group). pubstruct SelfRemoveProposal {}
#[cfg(feature = "custom_proposal")] #[derive(Clone, PartialEq, Eq)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] /// A user defined custom proposal. /// /// User defined proposals are passed through the protocol as an opaque value. pubstruct CustomProposal {
proposal_type: ProposalType, #[cfg_attr(feature = "serde", serde(with = "mls_rs_core::vec_serde"))]
data: Vec<u8>,
}
#[cfg(feature = "custom_proposal")] impl CustomProposal { /// Create a custom proposal. /// /// # Warning /// /// Avoid using the [`ProposalType`] values that have constants already /// defined by this crate. Using existing constants in a custom proposal /// has unspecified behavior. pubfn new(proposal_type: ProposalType, data: Vec<u8>) -> Self { Self {
proposal_type,
data,
}
}
/// The proposal type used for this custom proposal. pubfn proposal_type(&self) -> ProposalType { self.proposal_type
}
/// The opaque data communicated by this custom proposal. pubfn data(&self) -> &[u8] {
&self.data
}
}
#[cfg(feature = "custom_proposal")] /// Encode/Decode for the `data` field of CustomProposal. This allows specialization over /// the decoding based on the ProposalType, if users want to use an encoding other than the /// default bytes vector (in particular, if users want the CustomProposal wrapper to be hidden /// in the encoding, so the underlying custom proposal can be decoded directly). pubtrait CustomDecoder: Sized { fn encode_from_bytes(
data: &Vec<u8>,
writer: &mut Vec<u8>,
_proposal_type: &ProposalType,
) -> Result<(), mls_rs_codec::Error> {
mls_rs_codec::byte_vec::mls_encode(data, writer)
} fn decode_from_bytes(
reader: &mut &[u8],
_proposal_type: &ProposalType,
) -> Result<Vec<u8>, mls_rs_codec::Error> {
mls_rs_codec::byte_vec::mls_decode(reader)
} fn encoded_byte_len(data: &Vec<u8>, _proposal_type: &ProposalType) -> usize {
mls_rs_codec::byte_vec::mls_encoded_len(data)
}
}
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.