Skip to content

Commit 4e1fd46

Browse files
authored
Merge pull request #31 from RustCrypto/pbkdf2/rand-v0.7
pbkdf2: bump `rand` dependency to v0.7
2 parents e02e069 + 8511786 commit 4e1fd46

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

pbkdf2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ byteorder = { version = "1", default-features = false }
1616

1717
rayon = { version = "1", optional = true }
1818
base64 = { version = "0.9", optional = true }
19-
rand = { version = "0.5", optional = true }
19+
rand = { version = "0.7", optional = true }
2020
hmac = { version = "0.8", optional = true }
2121
sha2 = { version = "0.9", optional = true }
2222
subtle = { version = "2", default-features = false , optional = true }

pbkdf2/src/simple.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use std::string::ToString;
66
use crate::errors::CheckError;
77
use base64;
88
use hmac::Hmac;
9-
use rand::{OsRng, RngCore};
9+
use rand::RngCore;
10+
use rand::rngs::OsRng;
1011
use sha2::Sha256;
1112
use subtle::ConstantTimeEq;
1213

@@ -35,11 +36,9 @@ use byteorder::{BigEndian, ByteOrder};
3536
/// * `password` - The password to process
3637
/// * `c` - The iteration count
3738
pub fn pbkdf2_simple(password: &str, c: u32) -> io::Result<String> {
38-
let mut rng = OsRng::new()?;
39-
4039
// 128-bit salt
4140
let mut salt = [0u8; 16];
42-
rng.try_fill_bytes(&mut salt)?;
41+
OsRng.try_fill_bytes(&mut salt)?;
4342

4443
// 256-bit derived key
4544
let mut dk = [0u8; 32];

0 commit comments

Comments
 (0)