cleanup: KeyConfig::decrypt - show password hint on error

This commit is contained in:
Dietmar Maurer
2021-01-21 07:13:56 +01:00
parent f490dda05a
commit 8428063d9e
2 changed files with 12 additions and 15 deletions

View File

@ -484,19 +484,7 @@ pub async fn restore_key(
if let Some(key_config) = key_config {
let password_fn = || { Ok(password.as_bytes().to_vec()) };
let key = match key_config.decrypt(&password_fn) {
Ok((key, ..)) => key,
Err(_) => {
match key_config.hint {
Some(hint) => {
bail!("decrypt key failed (password hint: {})", hint);
}
None => {
bail!("decrypt key failed (wrong password)");
}
}
}
};
let (key, ..) = key_config.decrypt(&password_fn)?;
config::tape_encryption_keys::insert_key(key, key_config)?;
} else {
bail!("media does not contain any encryption key configuration");