Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ccptr authored and 71 committed Feb 2, 2024
1 parent 4aba996 commit c67b583
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
22 changes: 14 additions & 8 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ path = "src/main.rs"
required-features = ["default"]

[dependencies]
bitflags = "1.2"
hmac = "0.12"
bitflags = "2.4"
uint = { version = "0.9", default-features = false }
pbkdf2 = { version = "0.11", default-features = false }
pbkdf2 = { version = "0.12", default-features = false, features = ["hmac"] }
sha2 = { version = "0.10", default-features = false }

atty = { version = "0.2", optional = true }
Expand Down
18 changes: 11 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ extern crate std;

use core::mem::MaybeUninit;

use hmac::{Hmac, Mac};
use pbkdf2::pbkdf2;
use pbkdf2::{
hmac::{Hmac, Mac as _},
pbkdf2_hmac,
};
use sha2::{Sha256, Sha384, Sha512};

/// Selects the hash algorithm to use in PBKDF2.
Expand All @@ -34,14 +36,16 @@ pub enum Algorithm {
bitflags::bitflags! {
/// Flag that describes what characters are allowed when generating a
/// password.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct CharacterSet: u8 {
const Uppercase = 0b0001;
const Lowercase = 0b0010;
const Numbers = 0b0100;
const Symbols = 0b1000;

const Letters = Self::Uppercase.bits | Self::Lowercase.bits;
const All = Self::Letters.bits | Self::Numbers.bits | Self::Symbols.bits;
const Letters = Self::Uppercase.bits() | Self::Lowercase.bits();
const All = Self::Letters.bits() | Self::Numbers.bits() | Self::Symbols.bits();
}
}

Expand Down Expand Up @@ -229,13 +233,13 @@ pub fn generate_entropy_to(

match algorithm {
Algorithm::SHA256 => {
pbkdf2::<Hmac<Sha256>>(master_password.as_bytes(), salt, iterations, output)
pbkdf2_hmac::<Sha256>(master_password.as_bytes(), salt, iterations, output)
}
Algorithm::SHA384 => {
pbkdf2::<Hmac<Sha384>>(master_password.as_bytes(), salt, iterations, output)
pbkdf2_hmac::<Sha384>(master_password.as_bytes(), salt, iterations, output)
}
Algorithm::SHA512 => {
pbkdf2::<Hmac<Sha512>>(master_password.as_bytes(), salt, iterations, output)
pbkdf2_hmac::<Sha512>(master_password.as_bytes(), salt, iterations, output)
}
}
}
Expand Down

0 comments on commit c67b583

Please sign in to comment.