From efc53569edef7ca465e3b747799d75f9ca94e60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 6 Jun 2022 12:58:49 +0200 Subject: [PATCH] refactor(crypto): Rename our is_signed_by methods --- crates/matrix-sdk-crypto/src/backups/mod.rs | 6 +++--- crates/matrix-sdk-crypto/src/identities/device.rs | 11 ++++------- crates/matrix-sdk-crypto/src/identities/user.rs | 2 +- crates/matrix-sdk-crypto/src/olm/account.rs | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/matrix-sdk-crypto/src/backups/mod.rs b/crates/matrix-sdk-crypto/src/backups/mod.rs index 2f3993745..98d6402ae 100644 --- a/crates/matrix-sdk-crypto/src/backups/mod.rs +++ b/crates/matrix-sdk-crypto/src/backups/mod.rs @@ -173,7 +173,7 @@ impl BackupMachine { signatures: &Signatures, auth_data: &str, ) -> SignatureState { - match self.account.is_signed_by_raw(signatures, auth_data) { + match self.account.has_signed_raw(signatures, auth_data) { Ok(_) => SignatureState::ValidAndTrusted, Err(e) => match e { crate::SignatureError::NoSignatureFound => SignatureState::Missing, @@ -193,7 +193,7 @@ impl BackupMachine { let identity = self.store.get_identity(user_id).await?; let ret = if let Some(identity) = identity.and_then(|i| i.own()) { - match identity.master_key().is_signed_by_raw(signatures, auth_data) { + match identity.master_key().has_signed_raw(signatures, auth_data) { Ok(_) => { if identity.is_verified() { SignatureState::ValidAndTrusted @@ -221,7 +221,7 @@ impl BackupMachine { signatures: &Signatures, auth_data: &str, ) -> SignatureState { - if device.is_signed_by_device_raw(signatures, auth_data).is_ok() { + if device.has_signed_raw(signatures, auth_data).is_ok() { if device.verified() { SignatureState::ValidAndTrusted } else { diff --git a/crates/matrix-sdk-crypto/src/identities/device.rs b/crates/matrix-sdk-crypto/src/identities/device.rs index ce7cdd601..27461d0f0 100644 --- a/crates/matrix-sdk-crypto/src/identities/device.rs +++ b/crates/matrix-sdk-crypto/src/identities/device.rs @@ -572,7 +572,7 @@ impl ReadOnlyDevice { /// correctly canonicalized and make sure that the object you are checking /// the signature for is allowed to be signed by a device. #[cfg(feature = "backups_v1")] - pub(crate) fn is_signed_by_device_raw( + pub(crate) fn has_signed_raw( &self, signatures: &Signatures, canonical_json: &str, @@ -584,10 +584,7 @@ impl ReadOnlyDevice { key.verify_canonicalized_json(user_id, key_id, signatures, canonical_json) } - fn is_signed_by_device( - &self, - signed_object: &impl SignedJsonObject, - ) -> Result<(), SignatureError> { + fn has_signed(&self, signed_object: &impl SignedJsonObject) -> Result<(), SignatureError> { let key = self.ed25519_key().ok_or(SignatureError::MissingSigningKey)?; let user_id = self.user_id(); let key_id = &DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, self.device_id()); @@ -599,14 +596,14 @@ impl ReadOnlyDevice { &self, device_keys: &DeviceKeys, ) -> Result<(), SignatureError> { - self.is_signed_by_device(device_keys) + self.has_signed(device_keys) } pub(crate) fn verify_one_time_key( &self, one_time_key: &SignedKey, ) -> Result<(), SignatureError> { - self.is_signed_by_device(one_time_key) + self.has_signed(one_time_key) } /// Mark the device as deleted. diff --git a/crates/matrix-sdk-crypto/src/identities/user.rs b/crates/matrix-sdk-crypto/src/identities/user.rs index 3c08f6c53..33d19b66b 100644 --- a/crates/matrix-sdk-crypto/src/identities/user.rs +++ b/crates/matrix-sdk-crypto/src/identities/user.rs @@ -433,7 +433,7 @@ impl MasterPubkey { /// correctly canonicalized and make sure that the object you are checking /// the signature for is allowed to be signed by a master key. #[cfg(feature = "backups_v1")] - pub(crate) fn is_signed_by_raw( + pub(crate) fn has_signed_raw( &self, signatures: &Signatures, canonical_json: &str, diff --git a/crates/matrix-sdk-crypto/src/olm/account.rs b/crates/matrix-sdk-crypto/src/olm/account.rs index 8c11c8daa..96392d30d 100644 --- a/crates/matrix-sdk-crypto/src/olm/account.rs +++ b/crates/matrix-sdk-crypto/src/olm/account.rs @@ -685,7 +685,7 @@ impl ReadOnlyAccount { /// correctly canonicalized and make sure that the object you are checking /// the signature for is allowed to be signed by our own device. #[cfg(feature = "backups_v1")] - pub fn is_signed_by_raw( + pub fn has_signed_raw( &self, signatures: &crate::types::Signatures, canonical_json: &str,