From ae546b2d3e3af164636e137a14c48489ea4f7865 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 9 Mar 2022 19:07:22 +0100 Subject: [PATCH] Update sha1 --- Cargo.lock | 46 +++++++++++++++++++++++++++++++++++++--- Cargo.toml | 2 +- src/utils/crypt_utils.rs | 11 +++++++--- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56af0be..58e208b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -588,6 +588,15 @@ dependencies = [ "generic-array 0.14.5", ] +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array 0.14.5", +] + [[package]] name = "block-modes" version = "0.7.0" @@ -806,7 +815,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "sha1", + "sha1 0.10.1", "tokio 0.2.25", "url", "webauthn-rs", @@ -944,6 +953,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crypto-common" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +dependencies = [ + "generic-array 0.14.5", + "typenum", +] + [[package]] name = "curl" version = "0.4.42" @@ -1045,6 +1064,16 @@ dependencies = [ "generic-array 0.14.5", ] +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer 0.10.2", + "crypto-common", +] + [[package]] name = "discard" version = "1.0.4" @@ -2070,7 +2099,7 @@ dependencies = [ "rust_decimal", "serde", "serde_json", - "sha1", + "sha1 0.6.1", "sha2 0.8.2", "time 0.2.27", "twox-hash", @@ -2965,6 +2994,17 @@ dependencies = [ "sha1_smol", ] +[[package]] +name = "sha1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77f4e7f65455545c2153c1253d25056825e77ee2533f0e41deb65a93a34852f" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.3", +] + [[package]] name = "sha1_smol" version = "1.0.0" @@ -3136,7 +3176,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha1", + "sha1 0.6.1", "syn", ] diff --git a/Cargo.toml b/Cargo.toml index f4da4b4..ca13d6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ futures = "0.3.12" encoding_rs = "0.8.28" percent-encoding = "2.1.0" mailchecker = "4.0.3" -sha1 = "0.6.0" +sha1 = "0.10.1" rand = "0.8.3" chrono = "0.4.19" bytes = "1.0.1" diff --git a/src/utils/crypt_utils.rs b/src/utils/crypt_utils.rs index 439a30c..55880bf 100644 --- a/src/utils/crypt_utils.rs +++ b/src/utils/crypt_utils.rs @@ -4,9 +4,11 @@ extern crate sha1; -use crate::data::error::{ResultBoxError, ExecError}; -use rand::{thread_rng, Rng}; +use rand::{Rng, thread_rng}; use rand::distributions::Alphanumeric; +use sha1::Digest; + +use crate::data::error::{ExecError, ResultBoxError}; /// Generate a new sha1 string /// @@ -17,7 +19,10 @@ use rand::distributions::Alphanumeric; /// assert_eq!(res, "e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4"); /// ``` pub fn sha1_str(input: &str) -> String { - sha1::Sha1::from(input).digest().to_string() + let mut hasher = sha1::Sha1::default(); + hasher.update(input.as_bytes()); + let result = hasher.finalize(); + format!("{:x}", result) } /// One-way user password crypt