Skip to content

Commit c67b583

Browse files
ccptr71
authored andcommitted
update dependencies
1 parent 4aba996 commit c67b583

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

Cargo.lock

+14-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ path = "src/main.rs"
2323
required-features = ["default"]
2424

2525
[dependencies]
26-
bitflags = "1.2"
27-
hmac = "0.12"
26+
bitflags = "2.4"
2827
uint = { version = "0.9", default-features = false }
29-
pbkdf2 = { version = "0.11", default-features = false }
28+
pbkdf2 = { version = "0.12", default-features = false, features = ["hmac"] }
3029
sha2 = { version = "0.10", default-features = false }
3130

3231
atty = { version = "0.2", optional = true }

src/lib.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ extern crate std;
66

77
use core::mem::MaybeUninit;
88

9-
use hmac::{Hmac, Mac};
10-
use pbkdf2::pbkdf2;
9+
use pbkdf2::{
10+
hmac::{Hmac, Mac as _},
11+
pbkdf2_hmac,
12+
};
1113
use sha2::{Sha256, Sha384, Sha512};
1214

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

43-
const Letters = Self::Uppercase.bits | Self::Lowercase.bits;
44-
const All = Self::Letters.bits | Self::Numbers.bits | Self::Symbols.bits;
47+
const Letters = Self::Uppercase.bits() | Self::Lowercase.bits();
48+
const All = Self::Letters.bits() | Self::Numbers.bits() | Self::Symbols.bits();
4549
}
4650
}
4751

@@ -229,13 +233,13 @@ pub fn generate_entropy_to(
229233

230234
match algorithm {
231235
Algorithm::SHA256 => {
232-
pbkdf2::<Hmac<Sha256>>(master_password.as_bytes(), salt, iterations, output)
236+
pbkdf2_hmac::<Sha256>(master_password.as_bytes(), salt, iterations, output)
233237
}
234238
Algorithm::SHA384 => {
235-
pbkdf2::<Hmac<Sha384>>(master_password.as_bytes(), salt, iterations, output)
239+
pbkdf2_hmac::<Sha384>(master_password.as_bytes(), salt, iterations, output)
236240
}
237241
Algorithm::SHA512 => {
238-
pbkdf2::<Hmac<Sha512>>(master_password.as_bytes(), salt, iterations, output)
242+
pbkdf2_hmac::<Sha512>(master_password.as_bytes(), salt, iterations, output)
239243
}
240244
}
241245
}

0 commit comments

Comments
 (0)