Skip to content

Commit

Permalink
refactor to avoid clippy errors
Browse files Browse the repository at this point in the history
is there a better way to deal with that?
  • Loading branch information
vaf-hub committed Mar 3, 2025
1 parent d4c5abb commit 08c9e96
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions tuta-sdk/rust/sdk/src/crypto/asymmetric_crypto_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl AsymmetricCryptoFacade {
/// @param identifier the identifier to load the public key to verify that it matches the one used in the protocol run.
/// @param sender_identity_pub_key the sender_identity_pub_key that was used to encrypt/authenticate the data.
/// @param sender_key_version the version of the sender_identity_pub_key.
#[allow(clippy::needless_lifetimes)]
pub async fn authenticate_sender<'a>(
&self,
identifier: PublicKeyIdentifier,
Expand Down
34 changes: 17 additions & 17 deletions tuta-sdk/rust/sdk/src/crypto_entity_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,31 +226,31 @@ impl CryptoEntityClient {

match &mail.bucketKey {
None => None,
Some(bucket_key) => Some(
self.authenticate_main_instance(
sender_identity_pub_key
.as_ref()
.map(|sender_identity_pub_key| Versioned {
Some(bucket_key) => {
Some(
self.authenticate_main_instance(
sender_identity_pub_key.map(|sender_identity_pub_key| Versioned {
version: convert_version_to_u64(bucket_key.senderKeyVersion.expect(
"sender key version should be set on TutaCrypt bucket key",
)),
object: sender_identity_pub_key,
}),
mail,
bucket_key
.keyGroup
.as_ref()
.expect("key group should be set on TutaCrypt bucket key"),
mail,
bucket_key
.keyGroup
.as_ref()
.expect("key group should be set on TutaCrypt bucket key"),
)
.await,
)
.await,
),
},
}
}

/// @return None if not a main instance, the EncryptionAuthStatus from the asymmetric decryption otherwise
async fn authenticate_main_instance<'a>(
async fn authenticate_main_instance(
&self,
sender_identity_pub_key: Option<Versioned<&'a EccPublicKey>>,
sender_identity_pub_key: Option<Versioned<EccPublicKey>>,
mail: &Mail,
recipient_group: &GeneratedId,
) -> EncryptionAuthStatus {
Expand Down Expand Up @@ -289,10 +289,10 @@ impl CryptoEntityClient {
}
}

async fn tuta_crypt_authenticate_sender_of_main_instance<'a>(
async fn tuta_crypt_authenticate_sender_of_main_instance(
&self,
sender_mail_address: String,
sender_identity_pub_key: Versioned<&'a EccPublicKey>,
sender_identity_pub_key: Versioned<EccPublicKey>,
) -> EncryptionAuthStatus {
let result = self
.asymmetric_crypto_facade
Expand All @@ -301,7 +301,7 @@ impl CryptoEntityClient {
identifier: sender_mail_address,
identifier_type: PublicKeyIdentifierType::MailAddress,
},
sender_identity_pub_key,
sender_identity_pub_key.as_ref(),
)
.await;
match result {
Expand Down
6 changes: 6 additions & 0 deletions tuta-sdk/rust/sdk/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ impl<T> Versioned<T> {
pub fn new(object: T, version: u64) -> Versioned<T> {
Versioned { object, version }
}
pub fn as_ref(&self) -> Versioned<&T> {
Versioned {
object: &self.object,
version: self.version,
}
}
}

pub fn convert_version_to_u64(version: i64) -> u64 {
Expand Down

0 comments on commit 08c9e96

Please sign in to comment.