From c67b5833d44156597474b29421a1a25f88c6c9e6 Mon Sep 17 00:00:00 2001 From: ccptr Date: Thu, 1 Feb 2024 04:33:11 -0700 Subject: [PATCH] update dependencies --- Cargo.lock | 22 ++++++++++++++-------- Cargo.toml | 5 ++--- src/lib.rs | 18 +++++++++++------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8540800..6bfa488 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,6 +19,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + [[package]] name = "block-buffer" version = "0.10.3" @@ -52,7 +58,7 @@ version = "4.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", "is-terminal", @@ -110,9 +116,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -216,9 +222,8 @@ name = "lesspass" version = "0.4.1" dependencies = [ "atty", - "bitflags", + "bitflags 2.4.2", "clap", - "hmac", "pbkdf2", "rpassword", "sha2", @@ -251,11 +256,12 @@ checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] name = "pbkdf2" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ "digest", + "hmac", ] [[package]] @@ -316,7 +322,7 @@ version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", diff --git a/Cargo.toml b/Cargo.toml index 537814b..b4ab939 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/lib.rs b/src/lib.rs index d699eec..dae1ee2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. @@ -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(); } } @@ -229,13 +233,13 @@ pub fn generate_entropy_to( match algorithm { Algorithm::SHA256 => { - pbkdf2::>(master_password.as_bytes(), salt, iterations, output) + pbkdf2_hmac::(master_password.as_bytes(), salt, iterations, output) } Algorithm::SHA384 => { - pbkdf2::>(master_password.as_bytes(), salt, iterations, output) + pbkdf2_hmac::(master_password.as_bytes(), salt, iterations, output) } Algorithm::SHA512 => { - pbkdf2::>(master_password.as_bytes(), salt, iterations, output) + pbkdf2_hmac::(master_password.as_bytes(), salt, iterations, output) } } }