Skip to content

Commit 1dfbb37

Browse files
committed
bash-prg-hash: add test from the methodic from apmi bsu
1 parent 177969a commit 1dfbb37

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

bash-prg-hash/tests/mod.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bash_prg_hash::{
22
BashPrgHash1281, BashPrgHash1282, BashPrgHash1921, BashPrgHash1922, BashPrgHash2561,
33
BashPrgHash2562,
44
};
5-
use digest::{ExtendableOutput, TryCustomizedInit};
5+
use digest::{ExtendableOutput, TryCustomizedInit, Update};
66
use hex_literal::hex;
77
use std::fmt::Debug;
88

@@ -100,6 +100,23 @@ macro_rules! test_bash_prg_rand {
100100
};
101101
}
102102

103+
// Test from the https://apmi.bsu.by/assets/files/std/met-v10.zip
104+
macro_rules! test_bash_prg_million {
105+
($name:ident, $hasher:ty, $expected:expr) => {
106+
#[test]
107+
fn $name() {
108+
let mut h = <$hasher>::default();
109+
let block = [0x61u8; 1000];
110+
for _ in 0..1000 {
111+
h.update(&block);
112+
}
113+
let mut output = [0u8; 64];
114+
h.finalize_xof_into(&mut output);
115+
assert_eq!(&output[..$expected.len()], $expected);
116+
}
117+
};
118+
}
119+
103120
test_bash_prg_rand!(
104121
bashprg1282_rand,
105122
BashPrgHash1282,
@@ -126,3 +143,30 @@ test_bash_prg_rand!(
126143
"D591F583FA27F6B0F7E73DA2B29AF382AC2374C04463B91A27F1C48FEE8AAB2C"
127144
)
128145
);
146+
147+
// BASH.PRG.HASH128.5
148+
test_bash_prg_million!(
149+
bashprg1282_million,
150+
BashPrgHash1282,
151+
hex!("F84CA85F610711674BB8ADDB87B747C6000A6B6735664687854052C60CE0F7B0")
152+
);
153+
154+
// BASH.PRG.HASH192.5
155+
test_bash_prg_million!(
156+
bashprg1922_million,
157+
BashPrgHash1922,
158+
hex!(
159+
"C9B4ABF055F1A2ED025385AA5480BA9ADFB1608409D3102BCC557C41B22C2866"
160+
"233212327DF735BE22D85DE44CB48C2E"
161+
)
162+
);
163+
164+
// BASH.PRG.HASH256.5
165+
test_bash_prg_million!(
166+
bashprg2562_million,
167+
BashPrgHash2562,
168+
hex!(
169+
"45911D1B40F84E5D53C3B27FBB91D696E96924C5F3BD61CC589F26FA9502F3F5"
170+
"847DF96A5D6B44D17388DFF413D0B8AE0D81073D010F1637A20892E06DAB1AF0"
171+
)
172+
);

0 commit comments

Comments
 (0)