Skip to content

Commit

Permalink
Update to digest 0.10 crate
Browse files Browse the repository at this point in the history
Update dependencies and Hash code to use digest v0.10 crate.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
  • Loading branch information
lumag committed Sep 21, 2022
1 parent 446c91b commit 2a3cdcd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ cipher = "^0.3"
crc24 = "^0.1"
derive_builder = "0.9.0"
des = "^0.7"
digest = "^0.9"
digest = "^0.10"
generic-array = "^0.14"
hex = "^0.4"
log = "0.4.6"
md-5 = "^0.9"
md-5 = "^0.10"
nom = "^4.2"
num-derive = "0.3.0"
num-traits = "0.2.6"
rand = "0.8"
ripemd160 = "^0.9"
ripemd = "^0.1"
rsa = "^0.6.0"
sha-1 = "^0.9"
sha2 = "^0.9"
sha3 = "0.9"
sha1 = "^0.10"
sha2 = "^0.10"
sha3 = "0.10"
signature = "1.3.0"
smallvec = "1.6.1"
thiserror = "1.0.9"
Expand Down Expand Up @@ -95,7 +95,7 @@ serde_json = "^1.0"
default = []
nightly = ["ed25519-dalek/nightly", "rsa/nightly", "rand/nightly", "num-bigint/nightly"]
profile = ["gperftools"]
asm = ["sha-1/asm", "sha2/asm", "md-5/asm", "nightly"]
asm = ["sha1/asm", "sha2/asm", "md-5/asm", "nightly"]
wasm = ["chrono/wasmbind", "getrandom", "getrandom/js"]

[profile.bench]
Expand Down
23 changes: 11 additions & 12 deletions src/crypto/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use std::convert::TryInto;

use rsa::Hash;

use digest::{Digest, FixedOutput};
use generic_array::typenum::Unsigned;
use digest::Digest;
use md5::Md5;
use ripemd160::Ripemd160;
use ripemd::Ripemd160;
use sha1::Sha1;

use crate::errors::{Error, Result};
Expand Down Expand Up @@ -147,15 +146,15 @@ impl HashAlgorithm {
/// Returns the expected digest size for the given algorithm.
pub fn digest_size(self) -> usize {
match self {
HashAlgorithm::MD5 => <Md5 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::SHA1 => <Sha1 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::RIPEMD160 => <Ripemd160 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::SHA2_256 => <sha2::Sha256 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::SHA2_384 => <sha2::Sha384 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::SHA2_512 => <sha2::Sha512 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::SHA2_224 => <sha2::Sha224 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::SHA3_256 => <sha3::Sha3_256 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::SHA3_512 => <sha3::Sha3_512 as FixedOutput>::OutputSize::to_usize(),
HashAlgorithm::MD5 => Md5::output_size(),
HashAlgorithm::SHA1 => Sha1::output_size(),
HashAlgorithm::RIPEMD160 => Ripemd160::output_size(),
HashAlgorithm::SHA2_256 => sha2::Sha256::output_size(),
HashAlgorithm::SHA2_384 => sha2::Sha384::output_size(),
HashAlgorithm::SHA2_512 => sha2::Sha512::output_size(),
HashAlgorithm::SHA2_224 => sha2::Sha224::output_size(),
HashAlgorithm::SHA3_256 => sha3::Sha3_256::output_size(),
HashAlgorithm::SHA3_512 => sha3::Sha3_512::output_size(),
_ => 0,
}
}
Expand Down

0 comments on commit 2a3cdcd

Please sign in to comment.