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

Cycle the HMAC key on installation revoke #1427

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions xmtp_mls/src/groups/device_sync/preference_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ mod tests {
use super::*;
use crate::{
builder::ClientBuilder,
groups::scoped_client::LocalScopedGroupClient,
storage::consent_record::{ConsentState, ConsentType},
};
use crypto_utils::generate_local_wallet;
Expand Down Expand Up @@ -158,5 +159,13 @@ mod tests {
let pref_b = StoredUserPreferences::load(amal_b_conn).unwrap();

assert_eq!(pref_a.hmac_key, pref_b.hmac_key);

amal_a
.revoke_installations(vec![amal_b.installation_id().to_vec()])
.await
.unwrap();

let new_pref_a = StoredUserPreferences::load(amal_a_conn).unwrap();
assert_ne!(pref_a.hmac_key, new_pref_a.hmac_key);
}
}
8 changes: 7 additions & 1 deletion xmtp_mls/src/identity_updates.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::storage::association_state::StoredAssociationState;
use crate::storage::{
association_state::StoredAssociationState, user_preferences::StoredUserPreferences,
};
use futures::future::try_join_all;
use std::collections::{HashMap, HashSet};
use thiserror::Error;
Expand Down Expand Up @@ -350,6 +352,10 @@ where
)
}

// Cycle the HMAC key
let conn = self.store().conn()?;
StoredUserPreferences::new_hmac_key(&conn, &self.local_events)?;

Ok(builder.build())
}

Expand Down
Loading