mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
hashsum: implement SHAKE-128 and SHAKE-256
This commit is contained in:
parent
8fa113123d
commit
362cabe1a6
12 changed files with 227 additions and 207 deletions
1
tests/fixtures/hashsum/sha3_224.expected
vendored
Normal file
1
tests/fixtures/hashsum/sha3_224.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
927b362eaf84a75785bbec3370d1c9711349e93f1104eda060784221
|
1
tests/fixtures/hashsum/sha3_256.expected
vendored
Normal file
1
tests/fixtures/hashsum/sha3_256.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
bfb3959527d7a3f2f09def2f6915452d55a8f122df9e164d6f31c7fcf6093e14
|
1
tests/fixtures/hashsum/sha3_384.expected
vendored
Normal file
1
tests/fixtures/hashsum/sha3_384.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
fbd0c5931195aaa9517869972b372f717bb69f7f9f72bfc0884ed0531c36a16fc2db5dd6d82131968b23ffe0e90757e5
|
1
tests/fixtures/hashsum/sha3_512.expected
vendored
Normal file
1
tests/fixtures/hashsum/sha3_512.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
2ed3a863a12e2f8ff140aa86232ff3603a7f24af62f0e2ca74672494ade175a9a3de42a351b5019d931a1deae0499609038d9b47268779d76198e1d410d20974
|
1
tests/fixtures/hashsum/shake128_256.expected
vendored
Normal file
1
tests/fixtures/hashsum/shake128_256.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
83d41db453072caa9953f2f316480fbbcb84a5f3505460a18b3a36a814ae8e9e
|
1
tests/fixtures/hashsum/shake256_512.expected
vendored
Normal file
1
tests/fixtures/hashsum/shake256_512.expected
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
7c9896ea84a2a1b80b2183a3f2b4e43cd59b7d48471dc213bcedaccb699d6e6f7ad5d304928ab79329f1fc62f6db072d95b51209eb807683f5c9371872a2dd4e
|
|
@ -5,28 +5,42 @@ macro_rules! get_hash(
|
|||
);
|
||||
|
||||
macro_rules! test_digest {
|
||||
($($t:ident)*) => ($(
|
||||
($($id:ident $t:ident $size:expr)*) => ($(
|
||||
|
||||
mod $t {
|
||||
mod $id {
|
||||
use::common::util::*;
|
||||
static DIGEST_ARG: &'static str = concat!("--", stringify!($t));
|
||||
static EXPECTED_FILE: &'static str = concat!(stringify!($t), ".expected");
|
||||
static BITS_ARG: &'static str = concat!("--bits=", stringify!($size));
|
||||
static EXPECTED_FILE: &'static str = concat!(stringify!($id), ".expected");
|
||||
|
||||
#[test]
|
||||
fn test_single_file() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg("input.txt").succeeds().no_stderr().stdout));
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg("input.txt").succeeds().no_stderr().stdout));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin() {
|
||||
let ts = TestScenario::new("hashsum");
|
||||
assert_eq!(ts.fixtures.read(EXPECTED_FILE),
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).pipe_in_fixture("input.txt").succeeds().no_stderr().stdout));
|
||||
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).pipe_in_fixture("input.txt").succeeds().no_stderr().stdout));
|
||||
}
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
test_digest! { md5 sha1 sha224 sha256 sha384 sha512 }
|
||||
test_digest! {
|
||||
md5 md5 128
|
||||
sha1 sha1 160
|
||||
sha224 sha224 224
|
||||
sha256 sha256 256
|
||||
sha384 sha384 384
|
||||
sha512 sha512 512
|
||||
sha3_224 sha3 224
|
||||
sha3_256 sha3 256
|
||||
sha3_384 sha3 384
|
||||
sha3_512 sha3 512
|
||||
shake128_256 shake128 256
|
||||
shake256_512 shake256 512
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue