keymgr: Remove unused helper.
This helper is no longer needed (the logic from `parse_ssh_format_erased` changed).
This commit is contained in:
parent
fade75ae16
commit
9d8c28c639
|
@ -122,39 +122,6 @@ impl HasKind for SshKeyError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper for reading Ed25519 OpenSSH private keys from disk.
|
|
||||||
fn read_ed25519_keypair(key_type: KeyType, key: UnparsedOpenSshKey) -> Result<ed25519::Keypair> {
|
|
||||||
let sk =
|
|
||||||
ssh_key::PrivateKey::from_openssh(&*key.inner).map_err(|e| SshKeyError::SshKeyParse {
|
|
||||||
// TODO: rust thinks this clone is necessary because key.path is also used below (but
|
|
||||||
// if we get to this point, we're going to return an error and never reach the other
|
|
||||||
// error handling branches where we use key.path).
|
|
||||||
path: key.path.clone(),
|
|
||||||
key_type,
|
|
||||||
err: e.into(),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
// Build the expected key type (i.e. convert ssh_key key types to the key types
|
|
||||||
// we're using internally).
|
|
||||||
let key = match sk.key_data() {
|
|
||||||
KeypairData::Ed25519(key) => {
|
|
||||||
ed25519::Keypair::from_bytes(&key.to_bytes()).map_err(|_| {
|
|
||||||
tor_error::internal!("failed to build ed25519 key out of ed25519 OpenSSH key")
|
|
||||||
})?
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return Err(SshKeyError::UnexpectedSshKeyType {
|
|
||||||
path: key.path,
|
|
||||||
wanted_key_algo: key_type.ssh_algorithm(),
|
|
||||||
found_key_algo: sk.algorithm().into(),
|
|
||||||
}
|
|
||||||
.boxed());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
impl KeyType {
|
impl KeyType {
|
||||||
/// Get the algorithm of this key type.
|
/// Get the algorithm of this key type.
|
||||||
pub(crate) fn ssh_algorithm(&self) -> SshKeyAlgorithm {
|
pub(crate) fn ssh_algorithm(&self) -> SshKeyAlgorithm {
|
||||||
|
|
Loading…
Reference in New Issue