diff --git a/matrix_sdk_crypto/src/error.rs b/matrix_sdk_crypto/src/error.rs index d18ab476..cc679c0c 100644 --- a/matrix_sdk_crypto/src/error.rs +++ b/matrix_sdk_crypto/src/error.rs @@ -126,6 +126,9 @@ pub enum SignatureError { #[error("the signing key is missing from the object that signed the message")] MissingSigningKey, + #[error("the user id of the signing differs from the subkey user id")] + UserIdMissmatch, + #[error("the provided JSON value isn't an object")] NotAnObject, diff --git a/matrix_sdk_crypto/src/user_identity.rs b/matrix_sdk_crypto/src/user_identity.rs index c06e75d4..138cbd17 100644 --- a/matrix_sdk_crypto/src/user_identity.rs +++ b/matrix_sdk_crypto/src/user_identity.rs @@ -137,9 +137,12 @@ impl MasterPubkey { // if self.0.usage.contains(&KeyUsage::Master) { // return Err(SignatureError::MissingSigningKey); // } - let subkey: CrossSigningSubKeys = subkey.into(); + if &self.0.user_id != subkey.user_id() { + return Err(SignatureError::UserIdMissmatch); + } + verify_json( &self.0.user_id, &DeviceKeyId::try_from(key_id.as_str())?,