Skip to content

Commit

Permalink
Change to use StdRng to generate salt
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Aug 10, 2023
1 parent 12c7e76 commit d7ae1e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ toc::[]
=== Changed

* Split `Params` from `format.rs` ({pull-request-url}/38[#38])
* Use `StdRng` instead of `ChaCha20Rng` to generate salt
({pull-request-url}/38[#38])

== {compare-url}/v0.5.3\...v0.6.0[0.6.0] - 2023-08-09

Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ exclude = [
aes = "0.8.3"
ctr = "0.9.2"
hmac = "0.12.1"
rand = { version = "0.8.5", default-features = false, features = ["getrandom"] }
rand_chacha = { version = "0.3.1", default-features = false }
rand = { version = "0.8.5", default-features = false, features = ["getrandom", "std_rng"] }
scrypt = { version = "0.11.0", default-features = false }
sha2 = { version = "0.10.7", default-features = false }

Expand Down
6 changes: 2 additions & 4 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
//! Specifications of the scrypt encrypted data format.

use hmac::{digest::MacError, Hmac, Mac};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha20Rng;
use rand::{rngs::StdRng, Rng, SeedableRng};
use sha2::{Digest, Sha256};

use crate::error::Error;
Expand Down Expand Up @@ -44,8 +43,7 @@ impl Header {
/// Creates a new `Header`.
pub fn new(params: scrypt::Params) -> Self {
fn generate_salt() -> [u8; 32] {
let mut rng = ChaCha20Rng::from_entropy();
rng.gen()
StdRng::from_entropy().gen()
}

let magic_number = Self::MAGIC_NUMBER;
Expand Down

0 comments on commit d7ae1e7

Please sign in to comment.