Skip to content

Commit

Permalink
Upgrade getrandom to 0.3 (#91)
Browse files Browse the repository at this point in the history
Notably this removes the `js` feature in favor of a `cfg`
  • Loading branch information
alex authored Jan 30, 2025
1 parent c905948 commit 37da262
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:

- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.60.0
toolchain: 1.63.0
components: clippy

- run: cargo clippy -- -D warnings
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ include = ["src/**/*", "LICENSE", "README.md"]
default = ["std", "zeroize"]
std = ["getrandom/std", "base64/std"]
alloc = ["base64/alloc", "getrandom"]
js = ["getrandom/js"]

[dependencies]
blowfish = { version = "0.9", features = ["bcrypt"] }
getrandom = { version = "0.2", default-features = false, optional = true }
getrandom = { version = "0.3", default-features = false, optional = true }
base64 = { version = "0.22", default-features = false }
zeroize = { version = "1.5.4", optional = true }
subtle = { version = "2.4.1", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zeroize::Zeroize;
use base64::{alphabet::BCRYPT, engine::general_purpose::NO_PAD, engine::GeneralPurpose};
use core::fmt;
#[cfg(any(feature = "alloc", feature = "std"))]
use {base64::Engine, core::convert::AsRef, core::str::FromStr, getrandom::getrandom};
use {base64::Engine, core::convert::AsRef, core::str::FromStr};

mod bcrypt;
mod errors;
Expand All @@ -32,7 +32,7 @@ pub const DEFAULT_COST: u32 = 12;
pub const BASE_64: GeneralPurpose = GeneralPurpose::new(&BCRYPT, NO_PAD);

#[cfg(any(feature = "alloc", feature = "std"))]
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// A bcrypt hash result before concatenating
pub struct HashParts {
cost: u32,
Expand Down Expand Up @@ -203,7 +203,7 @@ pub fn non_truncating_hash<P: AsRef<[u8]>>(password: P, cost: u32) -> BcryptResu
pub fn hash_with_result<P: AsRef<[u8]>>(password: P, cost: u32) -> BcryptResult<HashParts> {
let salt = {
let mut s = [0u8; 16];
getrandom(&mut s).map(|_| s)
getrandom::fill(&mut s).map(|_| s)
}?;

_hash_password(password.as_ref(), cost, salt, false)
Expand All @@ -220,7 +220,7 @@ pub fn non_truncating_hash_with_result<P: AsRef<[u8]>>(
) -> BcryptResult<HashParts> {
let salt = {
let mut s = [0u8; 16];
getrandom(&mut s).map(|_| s)
getrandom::fill(&mut s).map(|_| s)
}?;

_hash_password(password.as_ref(), cost, salt, true)
Expand Down

0 comments on commit 37da262

Please sign in to comment.