Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed May 4, 2024
1 parent b20504d commit 83ab968
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
4 changes: 1 addition & 3 deletions russh-keys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,7 @@ pub fn load_secret_key<P: AsRef<Path>>(
}

/// Load a openssh certificate
pub fn load_openssh_certificate<P: AsRef<Path>>(
cert_: P,
) -> Result<Certificate, ssh_key::Error> {
pub fn load_openssh_certificate<P: AsRef<Path>>(cert_: P) -> Result<Certificate, ssh_key::Error> {
let mut cert_file = std::fs::File::open(cert_)?;
let mut cert = String::new();
cert_file.read_to_string(&mut cert)?;
Expand Down
8 changes: 4 additions & 4 deletions russh/examples/client_exec_interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
21 changes: 16 additions & 5 deletions russh/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,22 @@ impl<R: AsyncRead + AsyncWrite + Unpin + Send + 'static> Signer
#[derive(Debug)]
pub enum Method {
None,
Password { password: String },
PublicKey { key: Arc<key::KeyPair> },
OpenSSHCertificate { key: Arc<key::KeyPair>, cert: Certificate },
FuturePublicKey { key: key::PublicKey },
KeyboardInteractive { submethods: String },
Password {
password: String,
},
PublicKey {
key: Arc<key::KeyPair>,
},
OpenSSHCertificate {
key: Arc<key::KeyPair>,
cert: Certificate,
},
FuturePublicKey {
key: key::PublicKey,
},
KeyboardInteractive {
submethods: String,
},
// Hostbased,
}

Expand Down
2 changes: 1 addition & 1 deletion russh/src/cert.rs
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]";
Expand Down
4 changes: 2 additions & 2 deletions russh/src/client/encrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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)?;
Expand Down
2 changes: 1 addition & 1 deletion russh/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl<H: Handler> Handle<H> {
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<U: Into<String>>(
&mut self,
user: U,
Expand Down
2 changes: 1 addition & 1 deletion russh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 83ab968

Please sign in to comment.