Skip to content

Commit

Permalink
fixed tests again
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Dec 29, 2024
1 parent b900735 commit 2efb1c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions ssh-key/src/ppk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use sha2::Sha256;

use crate::private::KeypairData;
use crate::public::KeyData;
use crate::{Algorithm, Error, Mpint, PublicKey};
use crate::{Algorithm, Error, PublicKey};
use encoding::base64::{self, Base64, Encoding};
use encoding::{Decode, Encode, LabelError, Reader};
use subtle::ConstantTimeEq;
Expand Down Expand Up @@ -397,6 +397,7 @@ fn decode_private_key_as(
match (&algorithm, public.key_data()) {
(Algorithm::Dsa { .. }, KeyData::Dsa(pk)) => {
use crate::private::{DsaKeypair, DsaPrivateKey};

Ok(KeypairData::Dsa(DsaKeypair::new(
pk.clone(),
DsaPrivateKey::decode(reader)?,
Expand All @@ -406,6 +407,7 @@ fn decode_private_key_as(
#[cfg(feature = "rsa")]
(Algorithm::Rsa { .. }, KeyData::Rsa(pk)) => {
use crate::private::{RsaKeypair, RsaPrivateKey};
use crate::Mpint;

let d = Mpint::decode(reader)?;
let p = Mpint::decode(reader)?;
Expand All @@ -419,6 +421,7 @@ fn decode_private_key_as(
(Algorithm::Ed25519 { .. }, KeyData::Ed25519(pk)) => {
// PPK encodes Ed25519 private exponent as an mpint
use crate::private::{Ed25519Keypair, Ed25519PrivateKey};
use crate::Mpint;
use zeroize::Zeroizing;

// Copy and pad exponent
Expand All @@ -445,7 +448,7 @@ fn decode_private_key_as(
// PPK encodes EcDSA private exponent as an mpint
use crate::private::EcdsaKeypair;
use crate::public::EcdsaPublicKey;
use crate::EcdsaCurve;
use crate::{EcdsaCurve, Mpint};

// Copy and pad exponent
let e = Mpint::decode(reader)?;
Expand Down
8 changes: 4 additions & 4 deletions ssh-key/tests/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use hex_literal::hex;
use ssh_key::{Algorithm, Cipher, KdfAlg, PrivateKey};

#[cfg(feature = "ecdsa")]
#[cfg(any(feature = "p256", feature = "p384", feature = "p521"))]
use ssh_key::EcdsaCurve;

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -66,11 +66,11 @@ const OPENSSH_ED25519_64COLS_EXAMPLE: &str = include_str!("examples/id_ed25519.6
const OPENSSH_RSA_3072_EXAMPLE: &str = include_str!("examples/id_rsa_3072");

/// Same key, converted by puttygen
#[cfg(feature = "ppk")]
#[cfg(all(feature = "ppk", feature = "rsa"))]
const PPK_RSA_3072_EXAMPLE: &str = include_str!("examples/id_rsa_3072.ppk");

/// Same key, converted and encrypted by puttygen
#[cfg(all(feature = "ppk", feature = "encryption"))]
#[cfg(all(feature = "ppk", feature = "rsa", feature = "encryption"))]
const PPK_RSA_3072_EXAMPLE_ENCRYPTED: &str = include_str!("examples/id_rsa_3072_enc.ppk");

/// RSA (4096-bit) OpenSSH-formatted public key
Expand All @@ -83,7 +83,7 @@ const OPENSSH_OPAQUE_EXAMPLE: &str = include_str!("examples/id_opaque");

/// OpenSSH-formatted private key with no internal or external padding, and no comment
/// Trips a corner case in base64ct
#[cfg(feature = "ecdsa")]
#[cfg(feature = "p384")]
const OPENSSH_PADLESS_WONDER_EXAMPLE: &str = include_str!("examples/padless_wonder");

/// Get a path into the `tests/scratch` directory.
Expand Down

0 comments on commit 2efb1c6

Please sign in to comment.