From aafefa7f344441c709198e16cd07da11b4651a98 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 3 May 2020 02:53:40 -0400 Subject: also make the agent store decrypted org keys in memory --- src/bin/rbw-agent/actions.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/bin') diff --git a/src/bin/rbw-agent/actions.rs b/src/bin/rbw-agent/actions.rs index e24d044..3ca6d51 100644 --- a/src/bin/rbw-agent/actions.rs +++ b/src/bin/rbw-agent/actions.rs @@ -115,6 +115,14 @@ pub async fn unlock( "failed to find protected key in db" )); }; + let protected_private_key = + if let Some(protected_private_key) = db.protected_private_key { + protected_private_key + } else { + return Err(anyhow::anyhow!( + "failed to find protected private key in db" + )); + }; for i in 1u8..=3 { let err = if i > 1 { @@ -135,11 +143,15 @@ pub async fn unlock( &password, iterations, &protected_key, + &protected_private_key, + &db.protected_org_keys, ) .await; match res { - Ok(keys) => { - state.write().await.priv_key = Some(keys); + Ok((keys, org_keys)) => { + let mut state = state.write().await; + state.priv_key = Some(keys); + state.org_keys = org_keys; break; } Err(rbw::error::Error::IncorrectPassword) => { -- cgit v1.2.3-54-g00ecf