From a03e88aa004ad1164b22a96813b1a3ca80c73dff Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 23 Jul 2019 19:20:52 +0200 Subject: [PATCH] Update dependencies --- .travis.yml | 13 +++++++------ Cargo.toml | 3 +-- src/lib.rs | 17 +++++++---------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba5399b..4447009 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,6 @@ rust: - beta matrix: - # Since this item is allowed to fail, don't wait for it's result to mark the - # build complete. fast_finish: true allow_failures: - env: NAME='nightly' @@ -15,12 +13,14 @@ matrix: include: - env: NAME='nightly' rust: nightly - - env: NAME='rustfmt' - rust: nightly + + - env: NAME='clippy' + rust: nightly-2019-07-19 before_script: - - rustup component add rustfmt-preview + - rustup component add clippy script: - - cargo fmt --all -- --check + - cargo clippy --all --all-features -- -D clippy::all + - env: NAME='kcov' sudo: required # travis-ci/travis-ci#9061 before_script: @@ -48,3 +48,4 @@ script: - cargo build --verbose --all-features - cargo test --verbose --all-features - cargo doc --verbose --all-features --no-deps + diff --git a/Cargo.toml b/Cargo.toml index f194cf8..cdc83ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,7 @@ categories = ["cryptography", "algorithms"] readme = "README.md" [dependencies] -ring = "^0.13.0" -rand = "^0.5.0" +ring = "^0.16.1" [package.metadata.release] sign-commit = true diff --git a/src/lib.rs b/src/lib.rs index 119d72c..e127194 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,12 +12,10 @@ unused_qualifications )] -extern crate rand; extern crate ring; -use rand::OsRng; -use rand::RngCore; use ring::digest::{Algorithm, Context}; +use ring::rand::{SecureRandom, SystemRandom}; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; @@ -176,15 +174,14 @@ impl PrivateKey { /// Generates a new random one-time signing key. This method can panic if OS RNG fails pub fn new(algorithm: &'static Algorithm) -> PrivateKey { let generate_bit_hash_values = || -> Vec> { - let mut rng = match OsRng::new() { - Ok(g) => g, - Err(e) => panic!("Failed to obtain OS RNG: {}", e), - }; + let rng = SystemRandom::new(); + let buffer_byte = vec![0u8; algorithm.output_len]; let mut buffer = vec![buffer_byte; algorithm.output_len * 8]; for hash in &mut buffer { - rng.fill_bytes(hash) + rng.fill(hash) + .expect("Unable to fill buffer with random data"); } buffer @@ -274,7 +271,7 @@ impl Drop for PrivateKey { } impl PartialEq for PrivateKey { - // ⚠️ This is not a constant-time implementation + // ⚠️ This is not a constant-time implementation fn eq(&self, other: &PrivateKey) -> bool { if self.algorithm != other.algorithm { return false; @@ -310,7 +307,7 @@ impl PartialOrd for PrivateKey { } impl Ord for PrivateKey { - // ⚠️ This is not a constant-time implementation + // ⚠️ This is not a constant-time implementation fn cmp(&self, other: &PrivateKey) -> Ordering { self.one_values .cmp(&other.one_values)