refactor(crypto): Rename our is_signed_by methods

This commit is contained in:
Damir Jelić
2022-06-06 12:58:49 +02:00
parent 5c12132569
commit efc53569ed
4 changed files with 9 additions and 12 deletions

View File

@@ -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 {

View File

@@ -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.

View File

@@ -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,

View File

@@ -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,