diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-08 03:45:45 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-08 03:45:45 -0400 |
commit | 56d47b757da04bdb4414e350e6438a93242f53c8 (patch) | |
tree | ba28afa56e7746f9c33f8021c37d2c2b45d41204 /src/actions.rs | |
parent | 47968ec94ee172f5ae8924f2bb3850142e77dcd3 (diff) | |
download | rbw-56d47b757da04bdb4414e350e6438a93242f53c8.tar.gz rbw-56d47b757da04bdb4414e350e6438a93242f53c8.zip |
mlock sensitive memory
Diffstat (limited to 'src/actions.rs')
-rw-r--r-- | src/actions.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/actions.rs b/src/actions.rs index f9b1354..0402a10 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -2,7 +2,7 @@ use crate::prelude::*; pub async fn login( email: &str, - password: &str, + password: &crate::locked::Password, ) -> Result<(String, u32, String)> { let client = crate::api::Client::new_self_hosted("https://bitwarden.tozt.net"); @@ -20,22 +20,18 @@ pub async fn login( pub async fn unlock( email: &str, - password: &str, + password: &crate::locked::Password, iterations: u32, protected_key: String, -) -> Result<(Vec<u8>, Vec<u8>)> { +) -> Result<crate::locked::Keys> { let identity = crate::identity::Identity::new(email, password, iterations)?; let protected_key = crate::cipherstring::CipherString::new(&protected_key)?; - let master_key = - protected_key.decrypt(&identity.enc_key, &identity.mac_key)?; + let master_keys = protected_key.decrypt_locked(&identity.keys)?; - let enc_key = &master_key[0..32]; - let mac_key = &master_key[32..64]; - - Ok((enc_key.to_vec(), mac_key.to_vec())) + Ok(crate::locked::Keys::new(master_keys)) } pub async fn sync( |