Skip to content

Commit

Permalink
bad merge conflicts from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed May 16, 2024
1 parent dcaef4c commit c2abb1d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 86 deletions.
5 changes: 2 additions & 3 deletions openmls/src/group/core_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,13 +1135,12 @@ impl CoreGroup {
}

/// Create a new group context extension proposal
pub(crate) fn create_group_context_ext_proposal<Provider: OpenMlsProvider>(
pub(crate) fn create_group_context_ext_proposal(
&self,
framing_parameters: FramingParameters,
extensions: Extensions,
signer: &impl Signer,
) -> Result<AuthenticatedContent, CreateGroupContextExtProposalError<Provider::StorageError>>
{
) -> Result<AuthenticatedContent, CreateGroupContextExtProposalError> {
// Ensure that the group supports all the extensions that are wanted.
let required_extension = extensions
.iter()
Expand Down
7 changes: 5 additions & 2 deletions openmls/src/group/core_group/test_proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ fn test_group_context_extension_proposal_fails(
}

#[openmls_test::openmls_test]
fn test_group_context_extension_proposal(ciphersuite: Ciphersuite, provider: &Provider) {
fn test_group_context_extension_proposal(
ciphersuite: Ciphersuite,
provider: &impl crate::storage::OpenMlsProvider,
) {
// Basic group setup.
let group_aad = b"Alice's test group";
let framing_parameters = FramingParameters::new(group_aad, WireFormat::PublicMessage);
Expand Down Expand Up @@ -583,7 +586,7 @@ fn test_group_context_extension_proposal(ciphersuite: Ciphersuite, provider: &Pr
&[CredentialType::Basic],
));
let gce_proposal = alice_group
.create_group_context_ext_proposal::<Provider>(
.create_group_context_ext_proposal(
framing_parameters,
Extensions::single(required_application_id),
&alice_signer,
Expand Down
17 changes: 1 addition & 16 deletions openmls/src/group/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pub(crate) enum CoreGroupParseMessageError {

/// Create group context ext proposal error
#[derive(Error, Debug, PartialEq, Clone)]
pub enum CreateGroupContextExtProposalError<StorageError> {
pub enum CreateGroupContextExtProposalError {
/// See [`LibraryError`] for more details.
#[error(transparent)]
LibraryError(#[from] LibraryError),
Expand All @@ -513,12 +513,6 @@ pub enum CreateGroupContextExtProposalError<StorageError> {
/// See [`LeafNodeValidationError`] for more details.
#[error(transparent)]
LeafNodeValidation(#[from] LeafNodeValidationError),
/// See [`MlsGroupStateError`] for more details.
#[error(transparent)]
MlsGroupStateError(#[from] MlsGroupStateError<StorageError>),
/// See [`CreateCommitError`] for more details.
#[error(transparent)]
CreateCommitError(#[from] CreateCommitError<StorageError>),
}

/// Error merging a commit.
Expand All @@ -543,15 +537,6 @@ pub enum GroupContextExtensionsProposalValidationError {
#[error(transparent)]
LibraryError(#[from] LibraryError),

/// The new extension types in required capabilties contails extensions that are not supported by all group members.
#[error(
"The new required capabilties contain extension types that are not supported by all group members."
)]
ExtensionNotSupportedByAllMembers,
/// Proposal changes the immutable metadata extension, which is not allowed.
#[error("Proposal changes the immutable metadata extension, which is not allowed.")]
ChangedImmutableMetadata,

/// The new extension types in required capabilties contails extensions that are not supported by all group members.
#[error(
"The new required capabilties contain extension types that are not supported by all group members."
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/group/mls_group/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub enum ProposalError<StorageError> {
ValidationError(#[from] ValidationError),
/// See [`CreateGroupContextExtProposalError`] for more details.
#[error(transparent)]
CreateGroupContextExtProposalError(#[from] CreateGroupContextExtProposalError<StorageError>),
CreateGroupContextExtProposalError(#[from] CreateGroupContextExtProposalError),
/// Error writing proposal to storage.
#[error("error writing proposal to storage")]
StorageError(StorageError),
Expand Down
17 changes: 0 additions & 17 deletions openmls/src/group/mls_group/membership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,23 +214,6 @@ impl MlsGroup {
.leaf(leaf_index)
.map(|leaf| leaf.credential())
}

/// Returns the [`Member`] corresponding to the given
/// leaf index. Returns `None` if the member can not be found in this group.
pub fn member_at(&self, leaf_index: LeafNodeIndex) -> Option<Member> {
self.group
.public_group()
// This will return an error if the member can't be found.
.leaf(leaf_index)
.map(|leaf_node| {
Member::new(
leaf_index,
leaf_node.encryption_key().as_slice().to_vec(),
leaf_node.signature_key().as_slice().to_vec(),
leaf_node.credential().clone(),
)
})
}
}

/// Helper `enum` that classifies the kind of remove operation. This can be used to
Expand Down
50 changes: 3 additions & 47 deletions openmls/src/group/mls_group/proposal.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use openmls_traits::{signatures::Signer, storage::StorageProvider, types::Ciphersuite};

use super::{
core_group::create_commit_params::CreateCommitParams,
errors::{ProposalError, ProposeAddMemberError, ProposeRemoveMemberError},
CreateGroupContextExtProposalError, CustomProposal, GroupContextExtensionProposal, MlsGroup,
MlsGroupState, PendingCommitState, Proposal,
CustomProposal, MlsGroup,
};
use crate::{
binary_tree::LeafNodeIndex,
Expand All @@ -14,7 +12,7 @@ use crate::{
framing::MlsMessageOut,
group::{errors::CreateAddProposalError, GroupId, QueuedProposal},
key_packages::KeyPackage,
messages::{group_info::GroupInfo, proposals::ProposalOrRefType},
messages::proposals::ProposalOrRefType,
prelude::LibraryError,
schedule::PreSharedKeyId,
storage::OpenMlsProvider,
Expand Down Expand Up @@ -363,7 +361,7 @@ impl MlsGroup {
) -> Result<(MlsMessageOut, ProposalRef), ProposalError<Provider::StorageError>> {
self.is_operational()?;

let proposal = self.group.create_group_context_ext_proposal::<Provider>(
let proposal = self.group.create_group_context_ext_proposal(
self.framing_parameters(),
extensions,
signer,
Expand All @@ -386,46 +384,4 @@ impl MlsGroup {

Ok((mls_message, proposal_ref))
}

/// Updates group context extensions
///
/// Returns an error when the group does not support all the required capabilities
/// in the new `extensions`.
#[allow(clippy::type_complexity)]
pub fn update_group_context_extensions<Provider: OpenMlsProvider>(
&mut self,
provider: &Provider,
extensions: Extensions,
signer: &impl Signer,
) -> Result<
(MlsMessageOut, Option<MlsMessageOut>, Option<GroupInfo>),
CreateGroupContextExtProposalError<Provider::StorageError>,
> {
self.is_operational()?;

// Create group context extension proposals
let inline_proposals = vec![Proposal::GroupContextExtensions(
GroupContextExtensionProposal { extensions },
)];

let params = CreateCommitParams::builder()
.framing_parameters(self.framing_parameters())
.proposal_store(&self.proposal_store)
.inline_proposals(inline_proposals)
.build();
let create_commit_result = self.group.create_commit(params, provider, signer)?;

let mls_messages = self.content_to_mls_message(create_commit_result.commit, provider)?;
self.group_state = MlsGroupState::PendingCommit(Box::new(PendingCommitState::Member(
create_commit_result.staged_commit,
)));

Ok((
mls_messages,
create_commit_result
.welcome_option
.map(|w| MlsMessageOut::from_welcome(w, self.group.version())),
create_commit_result.group_info,
))
}
}

0 comments on commit c2abb1d

Please sign in to comment.