aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-08 04:05:36 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-08 04:05:36 -0400
commitc255e08021bf722558988b5a08c8e1427488c618 (patch)
tree5b1110908f5853f1e79f85afa359b8e51d87d270 /src/actions.rs
parentbc04f794ca08395577d507c0a746d3d7b01e29dc (diff)
downloadrbw-c255e08021bf722558988b5a08c8e1427488c618.tar.gz
rbw-c255e08021bf722558988b5a08c8e1427488c618.zip
also use cipherstring objects
Diffstat (limited to 'src/actions.rs')
-rw-r--r--src/actions.rs15
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))