Skip to content

Commit

Permalink
Fix clippy errors, and cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cchance27 committed Oct 16, 2023
1 parent 1e6c972 commit 452a856
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/algorithm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub enum PubKey {
RsaSha2_512,
#[cfg(feature = "deprecated-dss-sha1")]
#[strum(serialize = "ssh-dss")]
SshDss
SshDss,
}

/// MAC(message authentication code) algorithm
Expand Down
18 changes: 10 additions & 8 deletions src/algorithm/public_key/dss.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(feature = "deprecated-dss-sha1")]
use sha1::{Sha1, Digest};
use signature::DigestVerifier;
use sha1::{Digest, Sha1};
use signature::DigestVerifier;

use crate::algorithm::public_key::PublicKey as PubK;
use crate::model::Data;
Expand Down Expand Up @@ -28,12 +28,14 @@ impl PubK for DssSha1 {
let g = dsa::BigUint::from_bytes_be(data.get_u8s().as_slice());
let y = dsa::BigUint::from_bytes_be(data.get_u8s().as_slice());

let components = dsa::Components::from_components(p, q, g)
.map_err(|_| SshError::SshPubKeyError("SSH Public Key components were not valid".to_string()))?;

let components = dsa::Components::from_components(p, q, g).map_err(|_| {
SshError::SshPubKeyError("SSH Public Key components were not valid".to_string())
})?;

// Build the public key for verification of the message
let public_key = dsa::VerifyingKey::from_components(components, y)
.map_err(|_| SshError::SshPubKeyError("SSH Public Key components were not valid".to_string()))?;
let public_key = dsa::VerifyingKey::from_components(components, y).map_err(|_| {
SshError::SshPubKeyError("SSH Public Key components were not valid".to_string())
})?;

// Perform an SHA1 hash on the message
let digest = Sha1::new().chain_update(message);
Expand All @@ -48,4 +50,4 @@ impl PubK for DssSha1 {
// Verify the hashed message with the provided signature, matches the public_key
Ok(public_key.verify_digest(digest, &signature).is_ok())
}
}
}
7 changes: 4 additions & 3 deletions src/algorithm/public_key/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use crate::SshError;

#[cfg(feature = "deprecated-rsa-sha1")]
mod dss;
mod ed25519;
mod rsa;
mod dss;

#[cfg(feature = "deprecated-dss-sha1")]
use self::dss::DssSha1;
#[cfg(feature = "deprecated-rsa-sha1")]
use self::rsa::RsaSha1;
use self::rsa::RsaSha256;
use self::rsa::RsaSha512;
use super::PubKey;
use ed25519::Ed25519;
#[cfg(feature = "deprecated-dss-sha1")]
use self::dss::DssSha1;

/// # Public Key Algorithms
///
Expand Down
2 changes: 1 addition & 1 deletion tests/algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod test {
.run_local();
session.close();
}

#[cfg(feature = "deprecated-algorithms")]
#[test]
fn test_ssh_dss() {
Expand Down

0 comments on commit 452a856

Please sign in to comment.