From 20ac7d3d39cc81eee8bcd8dd5caad44fc1cab82d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 3 May 2020 03:02:15 -0400 Subject: pass along the entry's org id when requesting decryption --- src/bin/rbw/commands.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/bin/rbw/commands.rs') diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 0991f08..51d0453 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -659,6 +659,8 @@ fn find_entry_raw( } fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result { + // folder name should always be decrypted with the local key because + // folders are local to a specific user's vault, not the organization let folder = entry .folder .as_ref() @@ -674,7 +676,9 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result { let username = entry .username .as_ref() - .map(|username| crate::actions::decrypt(username, None)) + .map(|username| { + crate::actions::decrypt(username, entry.org_id.as_deref()) + }) .transpose(); let username = match username { Ok(username) => username, @@ -686,7 +690,9 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result { let password = entry .password .as_ref() - .map(|password| crate::actions::decrypt(password, None)) + .map(|password| { + crate::actions::decrypt(password, entry.org_id.as_deref()) + }) .transpose(); let password = match password { Ok(password) => password, @@ -698,7 +704,7 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result { let notes = entry .notes .as_ref() - .map(|notes| crate::actions::decrypt(notes, None)) + .map(|notes| crate::actions::decrypt(notes, entry.org_id.as_deref())) .transpose(); let notes = match notes { Ok(notes) => notes, @@ -710,17 +716,20 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result { let history = entry .history .iter() - .map(|entry| { + .map(|history_entry| { Ok(DecryptedHistoryEntry { - last_used_date: entry.last_used_date.clone(), - password: crate::actions::decrypt(&entry.password, None)?, + last_used_date: history_entry.last_used_date.clone(), + password: crate::actions::decrypt( + &history_entry.password, + entry.org_id.as_deref(), + )?, }) }) .collect::>()?; Ok(DecryptedCipher { id: entry.id.clone(), folder, - name: crate::actions::decrypt(&entry.name, None)?, + name: crate::actions::decrypt(&entry.name, entry.org_id.as_deref())?, username, password, notes, -- cgit v1.2.3-54-g00ecf