libqabu/mode/
mod.rs

1pub(crate) mod util;
2
3#[allow(unused_macros)]
4macro_rules! define_internals {
5	(
6        $mode:tt,
7        $C:tt,
8        $IV:tt
9    ) => {
10		impl<$C, const BLOCK: usize> internals::Mode for $mode<'_, $C, BLOCK>
11		where
12			$C: Block
13		{
14			type IV = $IV;
15			type C = $C;
16
17			fn get_base_iv(&self) -> &$IV { &self.iv }
18
19			fn get_state(&self) -> &$IV { &self.state }
20
21			fn set_base_iv(&mut self, iv: $IV) -> () { self.iv = iv }
22
23			fn set_state(&mut self, state: $IV) -> () { self.state = state; }
24
25			fn cipher_ref(&self) -> &$C { self.cipher }
26		}
27
28		#[cfg(feature = "shred")]
29		impl<$C, const BLOCK: usize> Drop for $mode<'_, $C, BLOCK>
30		where
31			$C: Block
32		{
33			fn drop(&mut self) { self.shred(); }
34		}
35	};
36
37	(
38        $mode:tt,
39        $C:tt,
40        $IV:tt,
41        $IVG: tt
42    ) => {
43		impl<$C, const BLOCK: usize> internals::Mode for $mode<'_, $C, BLOCK>
44		where
45			$C: Block
46		{
47			type IV = $IV<$IVG>;
48			type C = $C;
49
50			fn get_base_iv(&self) -> &$IV<$IVG> { &self.iv }
51
52			fn get_state(&self) -> &$IV<$IVG> { &self.state }
53
54			fn set_base_iv(&mut self, iv: $IV<$IVG>) -> () { self.iv = iv }
55
56			fn set_state(&mut self, state: $IV<$IVG>) -> () { self.state = state; }
57
58			fn cipher_ref(&self) -> &$C { self.cipher }
59		}
60
61		#[cfg(feature = "shred")]
62		impl<$C, const BLOCK: usize> Drop for $mode<'_, $C, BLOCK>
63		where
64			$C: Block
65		{
66			fn drop(&mut self) { self.shred(); }
67		}
68	};
69}
70
71#[cfg(feature = "ecb")]
72mod ecb;
73#[cfg(feature = "ecb")]
74pub use ecb::*;
75
76#[cfg(feature = "cbc")]
77mod cbc;
78#[cfg(feature = "cbc")]
79pub use cbc::*;
80
81#[cfg(feature = "pcbc")]
82mod pcbc;
83#[cfg(feature = "pcbc")]
84pub use pcbc::*;
85
86#[cfg(feature = "cfb")]
87mod cfb;
88#[cfg(feature = "cfb")]
89pub use cfb::*;
90
91#[cfg(feature = "ofb")]
92mod ofb;
93#[cfg(feature = "ofb")]
94pub use ofb::*;
95
96#[cfg(feature = "ctr")]
97mod ctr;
98#[cfg(feature = "ctr")]
99pub use ctr::*;