Skip to content

Commit 37da262

Browse files
authored
Upgrade getrandom to 0.3 (#91)
Notably this removes the `js` feature in favor of a `cfg`
1 parent c905948 commit 37da262

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979

8080
- uses: dtolnay/rust-toolchain@master
8181
with:
82-
toolchain: 1.60.0
82+
toolchain: 1.63.0
8383
components: clippy
8484

8585
- run: cargo clippy -- -D warnings

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ include = ["src/**/*", "LICENSE", "README.md"]
1515
default = ["std", "zeroize"]
1616
std = ["getrandom/std", "base64/std"]
1717
alloc = ["base64/alloc", "getrandom"]
18-
js = ["getrandom/js"]
1918

2019
[dependencies]
2120
blowfish = { version = "0.9", features = ["bcrypt"] }
22-
getrandom = { version = "0.2", default-features = false, optional = true }
21+
getrandom = { version = "0.3", default-features = false, optional = true }
2322
base64 = { version = "0.22", default-features = false }
2423
zeroize = { version = "1.5.4", optional = true }
2524
subtle = { version = "2.4.1", default-features = false }

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use zeroize::Zeroize;
1717
use base64::{alphabet::BCRYPT, engine::general_purpose::NO_PAD, engine::GeneralPurpose};
1818
use core::fmt;
1919
#[cfg(any(feature = "alloc", feature = "std"))]
20-
use {base64::Engine, core::convert::AsRef, core::str::FromStr, getrandom::getrandom};
20+
use {base64::Engine, core::convert::AsRef, core::str::FromStr};
2121

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

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

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

226226
_hash_password(password.as_ref(), cost, salt, true)

0 commit comments

Comments
 (0)