diff --git a/apps/desktop/desktop_native/core/src/biometric/windows.rs b/apps/desktop/desktop_native/core/src/biometric/windows.rs index b6041b68f55..02b21994808 100644 --- a/apps/desktop/desktop_native/core/src/biometric/windows.rs +++ b/apps/desktop/desktop_native/core/src/biometric/windows.rs @@ -4,11 +4,11 @@ //! The former via UV + ephemerally (but protected) keys. This only works after first unlock. //! The latter via a signing API, that deterministically signs a challenge, from which a windows hello key is derived. This key //! is used to encrypt the protected key. -//! +//! //! # Security //! The security goal is that a locked vault - a running app - cannot be unlocked when the device (user-space) //! is compromised in this state. -//! +//! //! ## UV path //! When first unlocking the app, the app sends the user-key to this module, which holds it in secure memory, //! protected by DPAPI. This makes it inaccessible to other processes, unless they compromise the system administrator, or kernel. @@ -16,7 +16,7 @@ //! `windows_hello_authenticate` to get a yes/no decision on whether to release the key to the app. //! Note: Further process isolation is needed here so that code cannot be injected into the running process, which may //! circumvent DPAPI. -//! +//! //! ## Sign path //! In this scenario, when enrolling, the app sends the user-key to this module, which derives the windows hello key //! with the Windows Hello prompt. This is done by signing a per-user challenge, which produces a deterministic @@ -26,9 +26,7 @@ //! Therefore, to circumvent the security measure, the attacker would need to create a fake Windows-Hello prompt, and //! get the user to confirm it. -use std::{ - sync::{atomic::AtomicBool, Arc}, -}; +use std::sync::{atomic::AtomicBool, Arc}; use aes::cipher::KeyInit; use anyhow::{anyhow, Result}; @@ -47,8 +45,7 @@ use windows::{ Cryptography::CryptographicBuffer, }, Win32::{ - System::WinRT::IUserConsentVerifierInterop, - UI::WindowsAndMessaging::GetForegroundWindow, + System::WinRT::IUserConsentVerifierInterop, UI::WindowsAndMessaging::GetForegroundWindow, }, }; use windows_future::IAsyncOperation; @@ -136,7 +133,10 @@ impl super::BiometricTrait for BiometricLockSystem { } async fn provide_key(&self, user_id: &str, key: &[u8]) { - self.secure_memory.lock().await.put(user_id.to_string(), key); + self.secure_memory + .lock() + .await + .put(user_id.to_string(), key); } async fn unlock(&self, user_id: &str, hwnd: Vec) -> Result> { @@ -324,7 +324,13 @@ fn decrypt_data(key: &[u8; 32], ciphertext: &[u8], nonce: &[u8; 24]) -> Result