Skip to content

Commit

Permalink
Update Clippy and fix lints (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Aug 7, 2023
1 parent e19aabd commit 7ff9080
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.67.0
toolchain: 1.71.0
components: clippy
- run: cargo clippy --all -- -D warnings

Expand Down
9 changes: 2 additions & 7 deletions argon2/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub const ARGON2I_IDENT: Ident<'_> = Ident::new_unwrap("argon2i");
pub const ARGON2ID_IDENT: Ident<'_> = Ident::new_unwrap("argon2id");

/// Argon2 primitive type: variants of the algorithm.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Default, Ord)]
pub enum Algorithm {
/// Optimizes against GPU cracking attacks but vulnerable to side-channels.
///
Expand All @@ -47,15 +47,10 @@ pub enum Algorithm {
/// TMTO/GPU cracking resistance as Argon2d, nor as good of side-channel
/// resistance as Argon2i, but overall provides the most well-rounded
/// approach to both classes of attacks.
#[default]
Argon2id = 2,
}

impl Default for Algorithm {
fn default() -> Algorithm {
Algorithm::Argon2id
}
}

impl Algorithm {
/// Parse an [`Algorithm`] from the provided string.
pub fn new(id: impl AsRef<str>) -> Result<Self> {
Expand Down
1 change: 1 addition & 0 deletions argon2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ impl<'key> From<&Params> for Argon2<'key> {
}

#[cfg(all(test, feature = "alloc", feature = "password-hash"))]
#[allow(clippy::unwrap_used)]
mod tests {
use crate::{Algorithm, Argon2, Params, PasswordHasher, Salt, Version};

Expand Down
1 change: 1 addition & 0 deletions argon2/tests/kat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ fn output_bad_length() {
// =======================================
// Taken from https://github.com/P-H-C/phc-winner-argon2/blob/master/src/test.c

#[allow(clippy::too_many_arguments)]
fn hashtest(
algorithm: Algorithm,
version: Version,
Expand Down
9 changes: 2 additions & 7 deletions balloon-hash/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use core::{
use password_hash::Ident;

/// Balloon primitive type: variants of the algorithm.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Default)]
pub enum Algorithm {
/// Standard Balloon hashing algorithm.
Balloon,
Expand All @@ -19,15 +19,10 @@ pub enum Algorithm {
///
/// Supports parallelism by computing M instances of the
/// single-core Balloon function and XORing all the outputs.
#[default]
BalloonM,
}

impl Default for Algorithm {
fn default() -> Algorithm {
Algorithm::BalloonM
}
}

impl Algorithm {
/// Balloon algorithm identifier
#[cfg(feature = "password-hash")]
Expand Down
4 changes: 2 additions & 2 deletions password-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)]
#![warn(
clippy::checked_conversions,
clippy::integer_arithmetic,
clippy::arithmetic_side_effects,
clippy::panic,
clippy::panic_in_result_fn,
clippy::unwrap_used,
Expand Down Expand Up @@ -142,7 +142,7 @@ mod tests {
let hash = generate_hash(EXAMPLE_PASSWORD);
assert!(verify_password(EXAMPLE_PASSWORD, &hash).is_ok());
assert!(verify_password("bogus", &hash).is_err());
assert!(!is_hash_obsolete(&hash).unwrap());
assert!(!is_hash_obsolete(&hash).expect("hash can be parsed"));
}

#[cfg(feature = "argon2")]
Expand Down
6 changes: 3 additions & 3 deletions pbkdf2/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn pbkdf2_hmac_sha1_16384_20(bh: &mut Bencher) {
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha1::Sha1>>(password, salt, 16_384, &mut buf);
pbkdf2::<Hmac<sha1::Sha1>>(password, salt, 16_384, &mut buf).unwrap();
test::black_box(&buf);
});
}
Expand All @@ -24,7 +24,7 @@ pub fn pbkdf2_hmac_sha256_16384_20(bh: &mut Bencher) {
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha2::Sha256>>(password, salt, 16_384, &mut buf);
pbkdf2::<Hmac<sha2::Sha256>>(password, salt, 16_384, &mut buf).unwrap();
test::black_box(&buf);
});
}
Expand All @@ -35,7 +35,7 @@ pub fn pbkdf2_hmac_sha512_16384_20(bh: &mut Bencher) {
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha2::Sha512>>(password, salt, 16_384, &mut buf);
pbkdf2::<Hmac<sha2::Sha512>>(password, salt, 16_384, &mut buf).unwrap();
test::black_box(&buf);
});
}
2 changes: 1 addition & 1 deletion pbkdf2/src/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<'a> TryFrom<&'a PasswordHash<'a>> for Params {
}
}

impl<'a> TryFrom<Params> for ParamsString {
impl TryFrom<Params> for ParamsString {
type Error = Error;

fn try_from(input: Params) -> Result<ParamsString> {
Expand Down

0 comments on commit 7ff9080

Please sign in to comment.