Skip to content

Commit

Permalink
Back to ring crate from rust-crypto ones, but it did not fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wigy-opensource-developer committed Jan 23, 2019
1 parent 7959a32 commit 1ea5bc0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ failure = "0.1.3"
# Note: hashbrown is going to be merged into Rust std
hashbrown = "0.1.7"
sha2 = "0.8.0"
hmac = "0.7.0"
pbkdf2 = { version = "0.3.0", features=["parallel"], default-features = false }
ring = "0.14.3"
rand = "0.6.1"
once_cell = { version = "0.1.6", features = [ "parking_lot" ] }

Expand Down
10 changes: 5 additions & 5 deletions src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
//! [Seed]: ../seed/struct.Seed.html
//!

extern crate rand;
use self::rand::{ thread_rng, RngCore };
use rand::{ thread_rng, RngCore };
use ring::{digest, pbkdf2};
use sha2::Digest;
use hmac::Hmac;

const PBKDF2_ROUNDS: usize = 2048;
const PBKDF2_ROUNDS: u32 = 2048;
const PBKDF2_BYTES: usize = 64;

/// SHA256 helper function, internal to the crate
Expand All @@ -36,8 +35,9 @@ pub(crate) fn gen_random_bytes(byte_length: usize) -> Vec<u8> {
///
pub(crate) fn pbkdf2(input: &[u8], salt: &str) -> Vec<u8> {
let mut seed = vec![0u8; PBKDF2_BYTES];
static DIGEST_ALG: &'static digest::Algorithm = &digest::SHA512;

pbkdf2::pbkdf2::<Hmac<sha2::Sha512>>(input, salt.as_bytes(), PBKDF2_ROUNDS, &mut seed);
pbkdf2::derive(DIGEST_ALG, std::num::NonZeroU32::new(PBKDF2_ROUNDS).unwrap(), salt.as_bytes(), input, &mut seed);

seed
}
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
//!
#[macro_use] extern crate failure;
#[macro_use] extern crate once_cell;
extern crate pbkdf2;
extern crate hashbrown;
extern crate sha2;
extern crate hmac;
extern crate ring;
extern crate rand;

mod mnemonic;
mod error;
Expand Down

0 comments on commit 1ea5bc0

Please sign in to comment.