Skip to content

Commit

Permalink
Merge branch 'master' into ppk-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jan 6, 2025
2 parents ae16955 + 023b360 commit 602c53c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion ssh-key/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const CERT_ED25519: &str = "[email protected]";
/// OpenSSH certificate with RSA public key
const CERT_RSA: &str = "[email protected]";

/// OpenSSH certificate with RSA + SHA-256 as described in RFC8332 § 3
const CERT_RSA_SHA2_256: &str = "[email protected]";

/// OpenSSH certificate with RSA + SHA-512 as described in RFC8332 § 3
const CERT_RSA_SHA2_512: &str = "[email protected]";

/// OpenSSH certificate for ECDSA (NIST P-256) U2F/FIDO security key
const CERT_SK_ECDSA_SHA2_P256: &str = "[email protected]";

Expand Down Expand Up @@ -176,6 +182,12 @@ impl Algorithm {
}),
CERT_ED25519 => Ok(Algorithm::Ed25519),
CERT_RSA => Ok(Algorithm::Rsa { hash: None }),
CERT_RSA_SHA2_256 => Ok(Algorithm::Rsa {
hash: Some(HashAlg::Sha256),
}),
CERT_RSA_SHA2_512 => Ok(Algorithm::Rsa {
hash: Some(HashAlg::Sha512),
}),
CERT_SK_ECDSA_SHA2_P256 => Ok(Algorithm::SkEcdsaSha2NistP256),
CERT_SK_SSH_ED25519 => Ok(Algorithm::SkEd25519),
#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -224,7 +236,13 @@ impl Algorithm {
EcdsaCurve::NistP521 => CERT_ECDSA_SHA2_P521,
},
Algorithm::Ed25519 => CERT_ED25519,
Algorithm::Rsa { .. } => CERT_RSA,
Algorithm::Rsa { hash: None } => CERT_RSA,
Algorithm::Rsa {
hash: Some(HashAlg::Sha256),
} => CERT_RSA_SHA2_256,
Algorithm::Rsa {
hash: Some(HashAlg::Sha512),
} => CERT_RSA_SHA2_512,
Algorithm::SkEcdsaSha2NistP256 => CERT_SK_ECDSA_SHA2_P256,
Algorithm::SkEd25519 => CERT_SK_SSH_ED25519,
Algorithm::Other(algorithm) => return algorithm.certificate_type(),
Expand Down

0 comments on commit 602c53c

Please sign in to comment.