disallow blank encryption passkeys (#186)

fixes #185
This commit is contained in:
Carson McManus 2023-03-18 10:08:57 -04:00 committed by GitHub
parent 2d4f9bb25c
commit 3457f9cb43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -86,6 +86,11 @@ impl Manifest {
/// Tells the manifest to keep track of the encryption passkey, and use it for encryption when loading or saving accounts. /// Tells the manifest to keep track of the encryption passkey, and use it for encryption when loading or saving accounts.
pub fn submit_passkey(&mut self, passkey: Option<String>) { pub fn submit_passkey(&mut self, passkey: Option<String>) {
if let Some(p) = passkey.as_ref() {
if p.is_empty() {
panic!("Encryption passkey cannot be empty");
}
}
if passkey.is_some() { if passkey.is_some() {
debug!("passkey was submitted to manifest"); debug!("passkey was submitted to manifest");
} else { } else {

View file

@ -641,6 +641,12 @@ fn do_subcmd_encrypt(
let mut passkey; let mut passkey;
loop { loop {
passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok(); passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok();
if let Some(p) = passkey.as_ref() {
if p.is_empty() {
error!("Passkey cannot be empty, try again.");
continue;
}
}
let passkey_confirm = let passkey_confirm =
rpassword::prompt_password_stdout("Confirm encryption passkey: ").ok(); rpassword::prompt_password_stdout("Confirm encryption passkey: ").ok();
if passkey == passkey_confirm { if passkey == passkey_confirm {