Skip to content

Commit 3611ab1

Browse files
mariotakuEugeny
authored andcommitted
don't panic when passphrase is not supplied to openssh private key
1 parent 062b57b commit 3611ab1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

russh-keys/src/format/openssh.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ fn decrypt_secret_key(
120120
let rounds = kdfopts.read_u32()?;
121121
#[allow(clippy::unwrap_used)] // parameters are static
122122
#[allow(clippy::indexing_slicing)] // output length is static
123-
bcrypt_pbkdf::bcrypt_pbkdf(password, salt, rounds, &mut key[..n]).unwrap();
123+
match bcrypt_pbkdf::bcrypt_pbkdf(password, salt, rounds, &mut key[..n]) {
124+
Err(bcrypt_pbkdf::Error::InvalidParamLen) => return Err(Error::KeyIsEncrypted),
125+
e => e.unwrap()
126+
}
124127
}
125128
_kdfname => {
126129
return Err(Error::CouldNotReadKey);

0 commit comments

Comments
 (0)