Skip to content

Commit

Permalink
chore: finish
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonThormeyer committed Jun 21, 2024
1 parent 1702486 commit 7cc7800
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 95 deletions.
8 changes: 4 additions & 4 deletions openmls/src/group/core_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl CoreGroupBuilder {

// Prepare the PskSecret
let psk_secret = {
let psks = load_psks(provider.storage(), &resumption_psk_store, &self.psk_ids)?;
let psks = load_psks(provider.storage(), &resumption_psk_store, &self.psk_ids).await?;

PskSecret::new(provider.crypto(), ciphersuite, psks)?
};
Expand Down Expand Up @@ -858,9 +858,9 @@ impl CoreGroup {
.await
}

pub(crate) fn create_commit<Provider: OpenMlsProvider>(
pub(crate) async fn create_commit<Provider: OpenMlsProvider>(
&self,
mut params: CreateCommitParams,
mut params: CreateCommitParams<'_>,
provider: &Provider,
signer: &impl Signer,
) -> Result<CreateCommitResult, CreateCommitError<Provider::StorageError>> {
Expand Down Expand Up @@ -1012,7 +1012,7 @@ impl CoreGroup {
provider.storage(),
&self.resumption_psk_store,
&apply_proposals_values.presharedkeys,
)?;
).await?;

PskSecret::new(provider.crypto(), ciphersuite, psks)?
};
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/group/core_group/new_from_external_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl CoreGroup {
.build();

// Immediately create the commit to add ourselves to the group.
let create_commit_result = group.create_commit(params, provider, signer);
let create_commit_result = group.create_commit(params, provider, signer).await;
debug_assert!(
create_commit_result.is_ok(),
"Error creating commit {create_commit_result:?}"
Expand Down
8 changes: 5 additions & 3 deletions openmls/src/group/core_group/new_from_welcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl StagedCoreWelcome {
&key_package_bundle,
provider,
&resumption_psk_store,
)?;
).await?;

build_staged_welcome(
verifiable_group_info,
Expand Down Expand Up @@ -237,7 +237,9 @@ pub(in crate::group) async fn build_staged_welcome<Provider: OpenMlsProvider>(
}

/// Process a Welcome message up to the point where the ratchet tree is required.
pub(in crate::group) fn process_welcome<Provider: OpenMlsProvider>(
#[cfg_attr(feature = "async", maybe_async::must_be_async)]
#[cfg_attr(not(feature = "async"), maybe_async::must_be_sync)]
pub(in crate::group) async fn process_welcome<Provider: OpenMlsProvider>(
welcome: Welcome,
key_package_bundle: &KeyPackageBundle,
provider: &Provider,
Expand Down Expand Up @@ -274,7 +276,7 @@ pub(in crate::group) fn process_welcome<Provider: OpenMlsProvider>(
provider.storage(),
resumption_psk_store,
&group_secrets.psks,
)?;
).await?;

PskSecret::new(provider.crypto(), ciphersuite, psks)?
};
Expand Down
8 changes: 4 additions & 4 deletions openmls/src/group/core_group/process.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core_group::proposals::QueuedProposal;
#[cfg(feature = "async")]
use futures::{stream, StreamExt, TryStreamExt};
use futures::{stream, StreamExt};

use crate::{
framing::mls_content::FramedContentBody,
Expand Down Expand Up @@ -43,7 +43,7 @@ impl CoreGroup {
/// - ValSem242
/// - ValSem244
/// - ValSem246 (as part of ValSem010)
pub(crate) fn process_unverified_message<Provider: OpenMlsProvider>(
pub(crate) async fn process_unverified_message<Provider: OpenMlsProvider>(
&self,
provider: &Provider,
unverified_message: UnverifiedMessage,
Expand Down Expand Up @@ -88,7 +88,7 @@ impl CoreGroup {
old_epoch_keypairs,
leaf_node_keypairs,
provider,
)?;
).await?;
ProcessedMessageContent::StagedCommitMessage(Box::new(staged_commit))
}
};
Expand Down Expand Up @@ -211,7 +211,7 @@ impl CoreGroup {
proposal_store,
old_epoch_keypairs,
leaf_node_keypairs,
)
).await
}

/// Performs framing validation and, if necessary, decrypts the given message.
Expand Down
1 change: 1 addition & 0 deletions openmls/src/group/core_group/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl ProposalStore {

/// Removes a proposal from the store using its reference. It will return
/// None if it wasn't found in the store.
#[cfg(not(feature = "async"))]
pub(crate) fn remove(&mut self, proposal_ref: ProposalRef) -> Option<()> {
let index = self
.queued_proposals
Expand Down
8 changes: 4 additions & 4 deletions openmls/src/group/core_group/staged_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use openmls_traits::storage::StorageProvider as _;
#[cfg_attr(feature = "async", maybe_async::must_be_async)]
#[cfg_attr(not(feature = "async"), maybe_async::must_be_sync)]
impl CoreGroup {
fn derive_epoch_secrets(
async fn derive_epoch_secrets(
&self,
provider: &impl OpenMlsProvider,
apply_proposals_values: ApplyProposalsValues,
Expand Down Expand Up @@ -67,7 +67,7 @@ impl CoreGroup {
provider.storage(),
&self.resumption_psk_store,
&apply_proposals_values.presharedkeys,
)?;
).await?;

PskSecret::new(provider.crypto(), self.ciphersuite(), psks)?
};
Expand Down Expand Up @@ -123,7 +123,7 @@ impl CoreGroup {
/// - ValSem242
/// - ValSem244 Returns an error if the given commit was sent by the owner
/// of this group.
pub(crate) fn stage_commit(
pub(crate) async fn stage_commit(
&self,
mls_content: &AuthenticatedContent,
proposal_store: &ProposalStore,
Expand Down Expand Up @@ -263,7 +263,7 @@ impl CoreGroup {
self.group_epoch_secrets(),
commit_secret,
&serialized_provisional_group_context,
)?
).await?
.split_secrets(
serialized_provisional_group_context,
diff.tree_size(),
Expand Down
4 changes: 2 additions & 2 deletions openmls/src/group/mls_group/creation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#[cfg(feature = "async")]
use futures::{
stream::{self, StreamExt},
TryFutureExt,
};
use openmls_traits::{signatures::Signer, storage::StorageProvider as StorageProviderTrait};

Expand Down Expand Up @@ -153,6 +152,7 @@ impl MlsGroup {
}
}

#[cfg(not(feature = "async"))]
fn transpose_err_opt<T, E>(v: Result<Option<T>, E>) -> Option<Result<T, E>> {
match v {
Ok(Some(v)) => Some(Ok(v)),
Expand Down Expand Up @@ -184,7 +184,7 @@ impl ProcessedWelcome {
&key_package_bundle,
provider,
&resumption_psk_store,
)?;
).await?;

Ok(Self {
mls_group_config: mls_group_config.clone(),
Expand Down
18 changes: 10 additions & 8 deletions openmls/src/group/mls_group/membership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl MlsGroup {
/// [`Welcome`]: crate::messages::Welcome
// FIXME: #1217
#[allow(clippy::type_complexity)]
pub fn add_members<Provider: OpenMlsProvider>(
pub async fn add_members<Provider: OpenMlsProvider>(
&mut self,
provider: &Provider,
signer: &impl Signer,
Expand Down Expand Up @@ -63,7 +63,7 @@ impl MlsGroup {
.proposal_store(&self.proposal_store)
.inline_proposals(inline_proposals)
.build();
let create_commit_result = self.group.create_commit(params, provider, signer)?;
let create_commit_result = self.group.create_commit(params, provider, signer).await?;

let welcome = match create_commit_result.welcome_option {
Some(welcome) => welcome,
Expand All @@ -74,7 +74,7 @@ impl MlsGroup {

// Convert PublicMessage messages to MLSMessage and encrypt them if required by
// the configuration
let mls_messages = self.content_to_mls_message(create_commit_result.commit, provider)?;
let mls_messages = self.content_to_mls_message(create_commit_result.commit, provider).await?;

// Set the current group state to [`MlsGroupState::PendingCommit`],
// storing the current [`StagedCommit`] from the commit results
Expand All @@ -85,6 +85,7 @@ impl MlsGroup {
provider
.storage()
.write_group_state(self.group_id(), &self.group_state)
.await
.map_err(AddMembersError::StorageError)?;

Ok((
Expand Down Expand Up @@ -115,7 +116,7 @@ impl MlsGroup {
/// [`Welcome`]: crate::messages::Welcome
// FIXME: #1217
#[allow(clippy::type_complexity)]
pub fn remove_members<Provider: OpenMlsProvider>(
pub async fn remove_members<Provider: OpenMlsProvider>(
&mut self,
provider: &Provider,
signer: &impl Signer,
Expand Down Expand Up @@ -145,11 +146,11 @@ impl MlsGroup {
.proposal_store(&self.proposal_store)
.inline_proposals(inline_proposals)
.build();
let create_commit_result = self.group.create_commit(params, provider, signer)?;
let create_commit_result = self.group.create_commit(params, provider, signer).await?;

// Convert PublicMessage messages to MLSMessage and encrypt them if required by
// the configuration
let mls_message = self.content_to_mls_message(create_commit_result.commit, provider)?;
let mls_message = self.content_to_mls_message(create_commit_result.commit, provider).await?;

// Set the current group state to [`MlsGroupState::PendingCommit`],
// storing the current [`StagedCommit`] from the commit results
Expand All @@ -160,6 +161,7 @@ impl MlsGroup {
provider
.storage()
.write_group_state(self.group_id(), &self.group_state)
.await
.map_err(RemoveMembersError::StorageError)?;

Ok((
Expand All @@ -177,7 +179,7 @@ impl MlsGroup {
/// The Remove Proposal is returned as a [`MlsMessageOut`].
///
/// Returns an error if there is a pending commit.
pub fn leave_group<Provider: OpenMlsProvider>(
pub async fn leave_group<Provider: OpenMlsProvider>(
&mut self,
provider: &Provider,
signer: &impl Signer,
Expand All @@ -197,7 +199,7 @@ impl MlsGroup {
remove_proposal.clone(),
)?);

Ok(self.content_to_mls_message(remove_proposal, provider)?)
Ok(self.content_to_mls_message(remove_proposal, provider).await?)
}

/// Returns a list of [`Member`]s in the group.
Expand Down
Loading

0 comments on commit 7cc7800

Please sign in to comment.