Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ jobs:
for feature in blake2 ripemd sha1 sha2 sha3 sm3 streebog whirlpool; do
cargo test -p devmap-verity --no-default-features --features "$feature" --all-targets
done
# Exercise both digest generations together without all-features
# unification hiding accidental feature dependencies.
# Combine hash families without relying on all-features
# to hide a missing feature dependency.
for features in sha1,sha2 sha3,whirlpool blake2,sm3 ripemd,streebog; do
cargo test -p devmap-verity --no-default-features --features "$features" --all-targets
done
Expand Down
99 changes: 22 additions & 77 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions verity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,26 @@ rustdoc-args = ["--cfg", "docsrs"]
[features]
tokio = ["dep:tokio"]
sha1 = ["dep:sha1", "dep:digest"]
sha2 = ["dep:sha2", "dep:digest-next"]
sha3 = ["dep:sha3", "dep:digest-next"]
ripemd = ["dep:ripemd", "dep:digest-next"]
sha2 = ["dep:sha2", "dep:digest"]
sha3 = ["dep:sha3", "dep:digest"]
ripemd = ["dep:ripemd", "dep:digest"]
whirlpool = ["dep:whirlpool", "dep:digest"]
streebog = ["dep:streebog", "dep:digest"]
sm3 = ["dep:sm3", "dep:digest"]
blake2 = ["dep:blake2", "dep:digest-next"]
blake2 = ["dep:blake2", "dep:digest"]

[dependencies]
devmap-core = { version = "0.1.0", path = "../core" }
blake2 = { version = "0.11", optional = true }
digest = { version = "0.10", optional = true }
digest-next = { package = "digest", version = "0.11", optional = true }
digest = { version = "0.11", optional = true }
tokio = { version = "1", features = ["io-util"], optional = true }
ripemd = { version = "0.2", optional = true }
sha1 = { version = "0.10", optional = true }
sha1 = { version = "0.11", optional = true }
sha2 = { version = "0.11", optional = true }
sha3 = { version = "0.12", optional = true }
sm3 = { version = "0.4", optional = true }
streebog = { version = "0.10", optional = true }
whirlpool = { version = "0.10", optional = true }
sm3 = { version = "0.5", optional = true }
streebog = { version = "0.11", optional = true }
whirlpool = { version = "0.11", optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
devmap-linux = { version = "0.1.0", path = "../linux" }
Expand Down
62 changes: 24 additions & 38 deletions verity/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,11 @@ use std::io;
feature = "sm3",
feature = "blake2"
))]
use crate::hasher::Hasher;
#[cfg(any(
feature = "sha1",
feature = "whirlpool",
feature = "streebog",
feature = "sm3"
))]
use crate::hasher::legacy;
#[cfg(any(
feature = "sha2",
feature = "sha3",
feature = "blake2",
feature = "ripemd"
))]
use crate::hasher::modern;
use crate::hasher::{Hasher, boxed};
#[cfg(feature = "blake2")]
use blake2::{Blake2b, Blake2s};
#[cfg(feature = "blake2")]
use digest_next::consts::{U16, U20, U28, U32, U48, U64};
use digest::consts::{U16, U20, U28, U32, U48, U64};
#[cfg(feature = "ripemd")]
use ripemd::Ripemd160;
#[cfg(feature = "sha1")]
Expand Down Expand Up @@ -159,49 +145,49 @@ impl Algorithm {
pub(crate) fn hasher(self) -> Option<Box<dyn Hasher>> {
match self {
#[cfg(feature = "sha1")]
Self::Sha1 => Some(legacy(Sha1::default())),
Self::Sha1 => Some(boxed(Sha1::default())),
#[cfg(feature = "sha2")]
Self::Sha224 => Some(modern(Sha224::default())),
Self::Sha224 => Some(boxed(Sha224::default())),
#[cfg(feature = "sha2")]
Self::Sha256 => Some(modern(Sha256::default())),
Self::Sha256 => Some(boxed(Sha256::default())),
#[cfg(feature = "sha2")]
Self::Sha384 => Some(modern(Sha384::default())),
Self::Sha384 => Some(boxed(Sha384::default())),
#[cfg(feature = "sha2")]
Self::Sha512 => Some(modern(Sha512::default())),
Self::Sha512 => Some(boxed(Sha512::default())),
#[cfg(feature = "ripemd")]
Self::Ripemd160 => Some(modern(Ripemd160::default())),
Self::Ripemd160 => Some(boxed(Ripemd160::default())),
#[cfg(feature = "whirlpool")]
Self::Whirlpool => Some(legacy(Whirlpool::default())),
Self::Whirlpool => Some(boxed(Whirlpool::default())),
#[cfg(feature = "sha3")]
Self::Sha3_224 => Some(modern(Sha3_224::default())),
Self::Sha3_224 => Some(boxed(Sha3_224::default())),
#[cfg(feature = "sha3")]
Self::Sha3_256 => Some(modern(Sha3_256::default())),
Self::Sha3_256 => Some(boxed(Sha3_256::default())),
#[cfg(feature = "sha3")]
Self::Sha3_384 => Some(modern(Sha3_384::default())),
Self::Sha3_384 => Some(boxed(Sha3_384::default())),
#[cfg(feature = "sha3")]
Self::Sha3_512 => Some(modern(Sha3_512::default())),
Self::Sha3_512 => Some(boxed(Sha3_512::default())),
#[cfg(feature = "streebog")]
Self::Streebog256 => Some(legacy(Streebog256::default())),
Self::Streebog256 => Some(boxed(Streebog256::default())),
#[cfg(feature = "streebog")]
Self::Streebog512 => Some(legacy(Streebog512::default())),
Self::Streebog512 => Some(boxed(Streebog512::default())),
#[cfg(feature = "sm3")]
Self::Sm3 => Some(legacy(Sm3::default())),
Self::Sm3 => Some(boxed(Sm3::default())),
#[cfg(feature = "blake2")]
Self::Blake2b160 => Some(modern(Blake2b::<U20>::default())),
Self::Blake2b160 => Some(boxed(Blake2b::<U20>::default())),
#[cfg(feature = "blake2")]
Self::Blake2b256 => Some(modern(Blake2b::<U32>::default())),
Self::Blake2b256 => Some(boxed(Blake2b::<U32>::default())),
#[cfg(feature = "blake2")]
Self::Blake2b384 => Some(modern(Blake2b::<U48>::default())),
Self::Blake2b384 => Some(boxed(Blake2b::<U48>::default())),
#[cfg(feature = "blake2")]
Self::Blake2b512 => Some(modern(Blake2b::<U64>::default())),
Self::Blake2b512 => Some(boxed(Blake2b::<U64>::default())),
#[cfg(feature = "blake2")]
Self::Blake2s128 => Some(modern(Blake2s::<U16>::default())),
Self::Blake2s128 => Some(boxed(Blake2s::<U16>::default())),
#[cfg(feature = "blake2")]
Self::Blake2s160 => Some(modern(Blake2s::<U20>::default())),
Self::Blake2s160 => Some(boxed(Blake2s::<U20>::default())),
#[cfg(feature = "blake2")]
Self::Blake2s224 => Some(modern(Blake2s::<U28>::default())),
Self::Blake2s224 => Some(boxed(Blake2s::<U28>::default())),
#[cfg(feature = "blake2")]
Self::Blake2s256 => Some(modern(Blake2s::<U32>::default())),
Self::Blake2s256 => Some(boxed(Blake2s::<U32>::default())),
_ => None,
}
}
Expand Down
Loading
Loading