-
Notifications
You must be signed in to change notification settings - Fork 252
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
Crypto: Return an error when sharing a room key to a verified user, who has an unverified device (optional encryption setting) #3810
Changes from all commits
7784f3e
cf046da
326e87d
f555e07
ede5e5a
cfe16c4
2e4e11c
afe4015
cdb90e5
2ed73b8
56df4b3
5f24f8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,9 +297,7 @@ impl Device { | |
self.device_owner_identity.as_ref().is_some_and(|id| match id { | ||
UserIdentityData::Own(own_identity) => own_identity.is_verified(), | ||
UserIdentityData::Other(other_identity) => { | ||
self.own_identity.as_ref().is_some_and(|oi| { | ||
oi.is_verified() && oi.is_identity_signed(other_identity).is_ok() | ||
}) | ||
self.own_identity.as_ref().is_some_and(|oi| oi.is_identity_verified(other_identity)) | ||
} | ||
}) | ||
} | ||
|
@@ -744,21 +742,19 @@ impl DeviceData { | |
) -> bool { | ||
own_identity.as_ref().zip(device_owner.as_ref()).is_some_and( | ||
|(own_identity, device_identity)| { | ||
// Our own identity needs to be marked as verified. | ||
own_identity.is_verified() | ||
&& match device_identity { | ||
// If it's one of our own devices, just check that | ||
// we signed the device. | ||
UserIdentityData::Own(_) => own_identity.is_device_signed(self).is_ok(), | ||
|
||
// If it's a device from someone else, first check | ||
// that our user has signed the other user and then | ||
// check if the other user has signed this device. | ||
UserIdentityData::Other(device_identity) => { | ||
own_identity.is_identity_signed(device_identity).is_ok() | ||
&& device_identity.is_device_signed(self).is_ok() | ||
} | ||
match device_identity { | ||
UserIdentityData::Own(_) => { | ||
own_identity.is_verified() && own_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. preexisting, and can be done in another PR: having 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. Agreed. Let's fix that in another PR. |
||
} | ||
|
||
// If it's a device from someone else, first check | ||
// that our user has verified the other user and then | ||
// check if the other user has signed this device. | ||
UserIdentityData::Other(device_identity) => { | ||
own_identity.is_identity_verified(device_identity) | ||
&& device_identity.is_device_signed(self).is_ok() | ||
} | ||
} | ||
}, | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,11 +228,9 @@ impl Deref for UserIdentity { | |
impl UserIdentity { | ||
/// Is this user identity verified. | ||
pub fn is_verified(&self) -> bool { | ||
self.own_identity.as_ref().is_some_and(|own_identity| { | ||
// The identity of another user is verified iff our own identity is verified and | ||
// if our own identity has signed the other user's identity. | ||
own_identity.is_verified() && own_identity.is_identity_signed(&self.inner).is_ok() | ||
}) | ||
self.own_identity | ||
.as_ref() | ||
.is_some_and(|own_identity| own_identity.is_identity_verified(&self.inner)) | ||
} | ||
|
||
/// Manually verify this user. | ||
|
@@ -886,8 +884,26 @@ impl OwnUserIdentityData { | |
&self.user_signing_key | ||
} | ||
|
||
/// Check if the given user identity has been verified. | ||
/// | ||
/// The identity of another user is verified iff our own identity is | ||
/// verified and if our own identity has signed the other user's | ||
/// identity. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `identity` - The identity of another user which we want to check has | ||
/// been verified. | ||
pub fn is_identity_verified(&self, identity: &OtherUserIdentityData) -> bool { | ||
self.is_verified() && self.is_identity_signed(identity).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. same here for |
||
} | ||
|
||
/// Check if the given identity has been signed by this identity. | ||
/// | ||
/// Note that, normally, you'll also want to check that the | ||
/// `OwnUserIdentityData` has been verified; for that, | ||
/// [`Self::is_identity_verified`] is more appropriate. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `identity` - The identity of another user that we want to check if 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.
This is a slightly rubbish name; ultimately I want to use it for both unverified devices (#3792) and verified users that become unverified (#3793).