Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block resumption psks #817

Merged
merged 7 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ futures = "0.3.30"
futures-core = "0.3.30"
hex = "0.4.3"
log = "0.4"
openmls = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls_basic_credential = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls_rust_crypto = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls_traits = { git = "https://github.com/xmtp/openmls", rev = "606bf92" }
openmls = { git = "https://github.com/xmtp/openmls", rev = "5174c31" }
openmls_basic_credential = { git = "https://github.com/xmtp/openmls", rev = "5174c31" }
openmls_rust_crypto = { git = "https://github.com/xmtp/openmls", rev = "5174c31" }
openmls_traits = { git = "https://github.com/xmtp/openmls", rev = "5174c31" }
prost = "^0.12"
prost-types = "^0.12"
rand = "0.8.5"
Expand Down
12 changes: 6 additions & 6 deletions bindings_ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ pub enum GroupError {
MessageHistory(#[from] MessageHistoryError),
#[error("Installation diff error: {0}")]
InstallationDiff(#[from] InstallationDiffError),
#[error("PSKs are not support")]
NoPSKSupport,
}

impl RetryableError for GroupError {
Expand Down Expand Up @@ -326,6 +328,9 @@ impl MlsGroup {
let welcome = deserialize_welcome(&welcome_bytes)?;

let join_config = build_group_join_config();
if join_config.number_of_resumption_psks > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting I had to make this public so I could use it xmtp/openmls#30

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this into a getter instead of making it public? Then we can upstream this change. (I'd just prefer not making the fields pub directly.)

Copy link
Contributor

@franziskuskiefer franziskuskiefer Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't doing what you think it's doing I'm afraid. This only prevents you from joining a group that allow resumption PSKs. It's a property you probably want to set when creating groups to avoid generating unused resumption PSKs.

But to achieve what you want, you need to look into the group secrets. That's actually not possible yet. But it is with openmls/openmls#1586. I just added a function there to get the psks. On the result from that function you can get the processed_welcome.psks().psk(), which returns a PSK enum. There you can error out when it contains a resumption psk (or any, depending on what you want to achieve).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled in your PR to my fork and I seem to be able to get the psks now. 🙏

return Err(GroupError::NoPSKSupport);
}
let staged_welcome =
StagedWelcome::new_from_welcome(provider, &join_config, welcome.clone(), None)?;

Expand Down
7 changes: 7 additions & 0 deletions xmtp_mls/src/groups/validated_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ pub enum CommitValidationError {
InstallationDiff(#[from] InstallationDiffError),
#[error("Failed to parse group mutable permissions: {0}")]
GroupMutablePermissions(#[from] GroupMutablePermissionsError),
#[error("PSKs are not support")]
NoPSKSupport,
}

#[derive(Debug, Clone, PartialEq, Hash)]
Expand Down Expand Up @@ -226,6 +228,11 @@ impl ValidatedCommit {
&mutable_metadata,
)?;

// Block any ReInit proposals
if staged_commit.psk_proposals().any(|_| true) {
nplasterer marked this conversation as resolved.
Show resolved Hide resolved
return Err(CommitValidationError::NoPSKSupport);
}

// Get the installations actually added and removed in the commit
let ProposalChanges {
added_installations,
Expand Down
Loading