From 83ab9681dc31fb3a0a223cf997d0a4b5aa683fac Mon Sep 17 00:00:00 2001 From: Eugene Date: Sat, 4 May 2024 20:34:32 +0200 Subject: [PATCH] format --- russh-keys/src/lib.rs | 4 +--- russh/examples/client_exec_interactive.rs | 8 ++++---- russh/src/auth.rs | 21 ++++++++++++++++----- russh/src/cert.rs | 2 +- russh/src/client/encrypted.rs | 4 ++-- russh/src/client/mod.rs | 2 +- russh/src/lib.rs | 2 +- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/russh-keys/src/lib.rs b/russh-keys/src/lib.rs index aa378f0b..ba384720 100644 --- a/russh-keys/src/lib.rs +++ b/russh-keys/src/lib.rs @@ -323,9 +323,7 @@ pub fn load_secret_key>( } /// Load a openssh certificate -pub fn load_openssh_certificate>( - cert_: P, -) -> Result { +pub fn load_openssh_certificate>(cert_: P) -> Result { let mut cert_file = std::fs::File::open(cert_)?; let mut cert = String::new(); cert_file.read_to_string(&mut cert)?; diff --git a/russh/examples/client_exec_interactive.rs b/russh/examples/client_exec_interactive.rs index 2274c385..bd34bb40 100644 --- a/russh/examples/client_exec_interactive.rs +++ b/russh/examples/client_exec_interactive.rs @@ -112,16 +112,16 @@ impl Session { // use publickey authentication, with or without certificate if openssh_cert.is_none() { let auth_res = session - .authenticate_publickey(user, Arc::new(key_pair)) - .await?; + .authenticate_publickey(user, Arc::new(key_pair)) + .await?; if !auth_res { anyhow::bail!("Authentication (with publickey) failed"); } } else { let auth_res = session - .authenticate_openssh_cert(user, Arc::new(key_pair), openssh_cert.unwrap()) - .await?; + .authenticate_openssh_cert(user, Arc::new(key_pair), openssh_cert.unwrap()) + .await?; if !auth_res { anyhow::bail!("Authentication (with publickey+cert) failed"); diff --git a/russh/src/auth.rs b/russh/src/auth.rs index f4cbd40b..0de09a9e 100644 --- a/russh/src/auth.rs +++ b/russh/src/auth.rs @@ -78,11 +78,22 @@ impl Signer #[derive(Debug)] pub enum Method { None, - Password { password: String }, - PublicKey { key: Arc }, - OpenSSHCertificate { key: Arc, cert: Certificate }, - FuturePublicKey { key: key::PublicKey }, - KeyboardInteractive { submethods: String }, + Password { + password: String, + }, + PublicKey { + key: Arc, + }, + OpenSSHCertificate { + key: Arc, + cert: Certificate, + }, + FuturePublicKey { + key: key::PublicKey, + }, + KeyboardInteractive { + submethods: String, + }, // Hostbased, } diff --git a/russh/src/cert.rs b/russh/src/cert.rs index bc1a18fd..c1189cb4 100644 --- a/russh/src/cert.rs +++ b/russh/src/cert.rs @@ -1,8 +1,8 @@ +use crate::{key::PubKey, negotiation::Named}; use russh_cryptovec::CryptoVec; use russh_keys::encoding::Encoding; use ssh_encoding::Encode; use ssh_key::{Algorithm, Certificate, EcdsaCurve}; -use crate::{key::PubKey, negotiation::Named}; /// OpenSSH certificate for DSA public key const CERT_DSA: &str = "ssh-dss-cert-v01@openssh.com"; diff --git a/russh/src/client/encrypted.rs b/russh/src/client/encrypted.rs index c1278c68..280dda9e 100644 --- a/russh/src/client/encrypted.rs +++ b/russh/src/client/encrypted.rs @@ -1027,7 +1027,7 @@ impl Encrypted { buffer: &mut CryptoVec, ) -> Result<(), crate::Error> { match method { - auth::Method::PublicKey { ref key, .. } => { + auth::Method::PublicKey { ref key, .. } => { let i0 = self.client_make_to_sign(user, key.as_ref(), buffer); // Extend with self-signature. key.add_self_signature(buffer)?; @@ -1036,7 +1036,7 @@ impl Encrypted { self.write.extend(&buffer[i0..]); }) } - auth::Method::OpenSSHCertificate { ref key, ref cert } => { + auth::Method::OpenSSHCertificate { ref key, ref cert } => { let i0 = self.client_make_to_sign(user, cert, buffer); // Extend with self-signature. key.add_self_signature(buffer)?; diff --git a/russh/src/client/mod.rs b/russh/src/client/mod.rs index 6bdc3999..aec12cd2 100644 --- a/russh/src/client/mod.rs +++ b/russh/src/client/mod.rs @@ -355,7 +355,7 @@ impl Handle { self.wait_recv_reply().await } - /// Perform public OpenSSH Certificate-based SSH authentication + /// Perform public OpenSSH Certificate-based SSH authentication pub async fn authenticate_openssh_cert>( &mut self, user: U, diff --git a/russh/src/lib.rs b/russh/src/lib.rs index 5c955d26..80925bb8 100644 --- a/russh/src/lib.rs +++ b/russh/src/lib.rs @@ -114,9 +114,9 @@ pub mod kex; /// MAC algorithm names pub mod mac; +mod cert; mod compression; mod key; -mod cert; mod msg; mod negotiation; mod ssh_read;