-
Notifications
You must be signed in to change notification settings - Fork 270
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
feat(sdk-crypto): Add Identity based room key sharing strategy #3607
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a12e281
feat(sdk-crypto): Add Identity based room key sharing strategy
BillCarsonFr 5151a4f
feat(sdk-crypto): code-review cleaning for identity base sharing
BillCarsonFr 51a9441
review: Clean tests
BillCarsonFr 9294618
review: Add back comments on moved function
BillCarsonFr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,16 +273,9 @@ impl Device { | |
|
||
/// Is this device cross signed by its owner? | ||
pub fn is_cross_signed_by_owner(&self) -> bool { | ||
self.device_owner_identity.as_ref().is_some_and(|device_identity| match device_identity { | ||
// If it's one of our own devices, just check that | ||
// we signed the device. | ||
ReadOnlyUserIdentities::Own(identity) => identity.is_device_signed(&self.inner).is_ok(), | ||
// If it's a device from someone else, check | ||
// if the other user has signed this device. | ||
ReadOnlyUserIdentities::Other(device_identity) => { | ||
device_identity.is_device_signed(&self.inner).is_ok() | ||
} | ||
}) | ||
self.device_owner_identity | ||
.as_ref() | ||
.is_some_and(|owner_identity| self.inner.is_cross_signed_by_owner(owner_identity)) | ||
} | ||
|
||
/// Is the device owner verified by us? | ||
|
@@ -764,6 +757,18 @@ impl ReadOnlyDevice { | |
) | ||
} | ||
|
||
pub(crate) fn is_cross_signed_by_owner( | ||
&self, | ||
device_owner_identity: &ReadOnlyUserIdentities, | ||
) -> bool { | ||
match device_owner_identity { | ||
ReadOnlyUserIdentities::Own(identity) => identity.is_device_signed(self).is_ok(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please preserve the comments from the other body of this function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
ReadOnlyUserIdentities::Other(device_identity) => { | ||
device_identity.is_device_signed(self).is_ok() | ||
} | ||
} | ||
} | ||
|
||
/// Encrypt the given content for this device. | ||
/// | ||
/// # Arguments | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method exists for
Device
matrix-rust-sdk/crates/matrix-sdk-crypto/src/identities/device.rs
Lines 274 to 286 in 3be84a5
Please just move the body of that function over here instead of duplicating it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done