Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh-key: support for reading PPK format private keys #324

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Prev Previous commit
lint
Eugeny committed Jan 6, 2025
commit cb33ea45ca33d73212d501e5741b44cd454219b8
8 changes: 4 additions & 4 deletions ssh-key/src/ppk.rs
Original file line number Diff line number Diff line change
@@ -106,24 +106,24 @@ impl Cipher {
key.try_into().unwrap(),
#[allow(clippy::unwrap_used)] // const size
iv.try_into().unwrap(),
#[allow(clippy::unwrap_used)] // const size
mac_key.try_into().unwrap(),
mac_key.into(),
))
}
Kdf::PpkV2 => {
let mut hashes = {
let mut hash = Sha1::default();
hash.update(&[0, 0, 0, 0]);
hash.update([0, 0, 0, 0]);
hash.update(password.as_bytes());
hash.finalize().to_vec()
};
hashes.extend_from_slice({
let mut hash = Sha1::default();
hash.update(&[0, 0, 0, 1]);
hash.update([0, 0, 0, 1]);
hash.update(password.as_bytes());
hash.finalize().as_slice()
});

#[allow(clippy::unwrap_used)] // known size
let aes_key = hashes[..32].try_into().unwrap();
let iv = [0; 16];