From 22a8f12f3860196568a85451f3045d76c60448b8 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 29 Aug 2025 15:29:35 +0200 Subject: [PATCH 1/2] Fix clippy issues --- .../desktop_native/core/src/biometric/windows.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/desktop/desktop_native/core/src/biometric/windows.rs b/apps/desktop/desktop_native/core/src/biometric/windows.rs index 5d770a2d672..badf1890a22 100644 --- a/apps/desktop/desktop_native/core/src/biometric/windows.rs +++ b/apps/desktop/desktop_native/core/src/biometric/windows.rs @@ -115,7 +115,7 @@ impl super::BiometricTrait for BiometricLockSystem { // This key is unique to the challenge let windows_hello_key = windows_hello_authenticate_with_crypto(&challenge)?; - let (wrapped_key, nonce) = encrypt_data(&windows_hello_key, key).unwrap(); + let (wrapped_key, nonce) = encrypt_data(&windows_hello_key, key)?; set_keychain_entry( user_id, @@ -138,7 +138,7 @@ impl super::BiometricTrait for BiometricLockSystem { .put(user_id.to_string(), key); } - async fn unlock(&self, user_id: &str, hwnd: Vec) -> Result> { + async fn unlock(&self, user_id: &str, _hwnd: Vec) -> Result> { // Allow restoring focus to the previous window (broweser) let previous_active_window = super::windows_focus::get_active_window(); let _focus_scopeguard = scopeguard::guard((), |_| { @@ -271,7 +271,7 @@ fn windows_hello_authenticate_with_crypto(challenge: &[u8; 16]) -> Result<[u8; 3 let signature_buffer = signature.Result()?; let mut signature_value = - windows::core::Array::::with_len(signature_buffer.Length().unwrap() as usize); + windows::core::Array::::with_len(signature_buffer.Length().map_err(|e| anyhow!(e))? as usize); CryptographicBuffer::CopyToByteArray(&signature_buffer, &mut signature_value)?; // The signature is deterministic based on the challenge and keychain key. Thus, it can be hashed to a key. // It is unclear what entropy this key provides. @@ -309,7 +309,7 @@ fn encrypt_data(key: &[u8; 32], plaintext: &[u8]) -> Result<(Vec, [u8; 24])> let mut nonce = [0u8; 24]; rand::fill(&mut nonce); let ciphertext = cipher - .encrypt(&XNonce::from_slice(&nonce), plaintext) + .encrypt(XNonce::from_slice(&nonce), plaintext) .map_err(|e| anyhow!(e))?; Ok((ciphertext, nonce)) } @@ -318,7 +318,7 @@ fn encrypt_data(key: &[u8; 32], plaintext: &[u8]) -> Result<(Vec, [u8; 24])> fn decrypt_data(key: &[u8; 32], ciphertext: &[u8], nonce: &[u8; 24]) -> Result> { let cipher = XChaCha20Poly1305::new(key.into()); let plaintext = cipher - .decrypt(&XNonce::from_slice(nonce), ciphertext) + .decrypt(XNonce::from_slice(nonce), ciphertext) .map_err(|e| anyhow!(e))?; Ok(plaintext) } From e3e21b94b40fc98108167083bc4eb0f1194b29a1 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 29 Aug 2025 15:29:50 +0200 Subject: [PATCH 2/2] Cargo fmt --- apps/desktop/desktop_native/core/src/biometric/windows.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/desktop/desktop_native/core/src/biometric/windows.rs b/apps/desktop/desktop_native/core/src/biometric/windows.rs index badf1890a22..a49f0418eaf 100644 --- a/apps/desktop/desktop_native/core/src/biometric/windows.rs +++ b/apps/desktop/desktop_native/core/src/biometric/windows.rs @@ -270,8 +270,9 @@ fn windows_hello_authenticate_with_crypto(challenge: &[u8; 16]) -> Result<[u8; 3 } let signature_buffer = signature.Result()?; - let mut signature_value = - windows::core::Array::::with_len(signature_buffer.Length().map_err(|e| anyhow!(e))? as usize); + let mut signature_value = windows::core::Array::::with_len( + signature_buffer.Length().map_err(|e| anyhow!(e))? as usize, + ); CryptographicBuffer::CopyToByteArray(&signature_buffer, &mut signature_value)?; // The signature is deterministic based on the challenge and keychain key. Thus, it can be hashed to a key. // It is unclear what entropy this key provides.