diff options
Diffstat (limited to 'src/actions.rs')
-rw-r--r-- | src/actions.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/actions.rs b/src/actions.rs index 10ce357..3658139 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -3,7 +3,12 @@ use crate::prelude::*; pub async fn login( email: &str, password: &crate::locked::Password, -) -> Result<(String, u32, String, crate::locked::Keys)> { +) -> Result<( + String, + u32, + crate::cipherstring::CipherString, + crate::locked::Keys, +)> { let client = crate::api::Client::new_self_hosted("https://bitwarden.tozt.net"); @@ -14,9 +19,9 @@ pub async fn login( let (access_token, _refresh_token, protected_key) = client .login(&identity.email, &identity.master_password_hash) .await?; - let protected_key_cs = + let protected_key = crate::cipherstring::CipherString::new(&protected_key)?; - let master_keys = protected_key_cs.decrypt_locked(&identity.keys)?; + let master_keys = protected_key.decrypt_locked(&identity.keys)?; Ok(( access_token, @@ -30,13 +35,11 @@ pub async fn unlock( email: &str, password: &crate::locked::Password, iterations: u32, - protected_key: String, + protected_key: &crate::cipherstring::CipherString, ) -> Result<crate::locked::Keys> { let identity = crate::identity::Identity::new(email, password, iterations)?; - let protected_key = - crate::cipherstring::CipherString::new(&protected_key)?; let master_keys = protected_key.decrypt_locked(&identity.keys)?; Ok(crate::locked::Keys::new(master_keys)) |