-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements client support for OpenSSH Certificates (#278)
Adds support for using OpenSSH Certificates based on [OpenSSH Specs](https://cvsweb.openbsd.org/src/usr.bin/ssh/PROTOCOL.certkeys?annotate=HEAD) using the existing `PublicKey` authentication. **Approach:** Adds a new `authenticate_openssh_cert()` method, similar to `authenticate_publickey()` for passing certificate and the private key for authentication and signature generation. Internally a new `AuthMethod::OpenSSHCertificate` is added to handle certificate specific authentication flow. **Changes include -** - Updated example `examples/client_exec_interactive.rs` with an optional argument to pass the openssh certificate path. - Dependencies `ssh-key` and `ssh-encoding` are added from `RustCrypto/SSH` for parsing, encoding. The server-side support for this might be tricky, I am yet to explore.
- Loading branch information
1 parent
4b40f51
commit b20504d
Showing
10 changed files
with
159 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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]"; | ||
|
||
/// OpenSSH certificate for ECDSA (NIST P-256) public key | ||
const CERT_ECDSA_SHA2_P256: &str = "[email protected]"; | ||
|
||
/// OpenSSH certificate for ECDSA (NIST P-384) public key | ||
const CERT_ECDSA_SHA2_P384: &str = "[email protected]"; | ||
|
||
/// OpenSSH certificate for ECDSA (NIST P-521) public key | ||
const CERT_ECDSA_SHA2_P521: &str = "[email protected]"; | ||
|
||
/// OpenSSH certificate for Ed25519 public key | ||
const CERT_ED25519: &str = "[email protected]"; | ||
|
||
/// OpenSSH certificate with RSA public key | ||
const CERT_RSA: &str = "[email protected]"; | ||
|
||
/// OpenSSH certificate for ECDSA (NIST P-256) U2F/FIDO security key | ||
const CERT_SK_ECDSA_SHA2_P256: &str = "[email protected]"; | ||
|
||
/// OpenSSH certificate for Ed25519 U2F/FIDO security key | ||
const CERT_SK_SSH_ED25519: &str = "[email protected]"; | ||
|
||
/// None | ||
const NONE: &str = "none"; | ||
|
||
impl PubKey for Certificate { | ||
fn push_to(&self, buffer: &mut CryptoVec) { | ||
let mut cert_encoded = Vec::new(); | ||
let _ = self.encode(&mut cert_encoded); | ||
|
||
buffer.extend_ssh_string(&cert_encoded); | ||
} | ||
} | ||
|
||
impl Named for Certificate { | ||
fn name(&self) -> &'static str { | ||
match self.algorithm() { | ||
Algorithm::Dsa => CERT_DSA, | ||
Algorithm::Ecdsa { curve } => match curve { | ||
EcdsaCurve::NistP256 => CERT_ECDSA_SHA2_P256, | ||
EcdsaCurve::NistP384 => CERT_ECDSA_SHA2_P384, | ||
EcdsaCurve::NistP521 => CERT_ECDSA_SHA2_P521, | ||
}, | ||
Algorithm::Ed25519 => CERT_ED25519, | ||
Algorithm::Rsa { .. } => CERT_RSA, | ||
Algorithm::SkEcdsaSha2NistP256 => CERT_SK_ECDSA_SHA2_P256, | ||
Algorithm::SkEd25519 => CERT_SK_SSH_ED25519, | ||
Algorithm::Other(_) => NONE, | ||
_ => NONE, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,7 @@ pub mod mac; | |
|
||
mod compression; | ||
mod key; | ||
mod cert; | ||
mod msg; | ||
mod negotiation; | ||
mod ssh_read; | ||
|