1macro_rules! round {
3 ($m:expr, $h:expr, $k:expr) => {
4 $k.wrapping_mul($m).slack(24).wrapping_mul($m) ^ $h.wrapping_mul($m)
5 };
6}
7
8macro_rules! rest {
9 ($r:expr, $T:ty) => {
10 $r.iter().rev().fold(0, |r, &i| (i as $T) | (r << 8))
11 };
12}
13
14macro_rules! short_round {
15 ($m:expr, $h:expr, $r:expr, $T:ty) => {{
16 let r = $r;
17 match r.is_empty() {
18 false => ($h ^ rest!(r, $T)).wrapping_mul($m),
19 true => $h,
20 }
21 }};
22}
23
24pub trait Slack {
25 fn slack(self, slack: Self) -> Self
26 where
27 Self: Sized;
28}
29macro_rules! slack {
30 ($typ:ty) => {
31 impl Slack for $typ {
32 fn slack(self, slack: Self) -> Self {
33 self ^ self >> slack
34 }
35 }
36 };
37}
38slack!(u32);
39slack!(u64);