1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
mod qhmac;
use seckey::Bytes;
pub use self::qhmac::HMAC;
pub trait Mac {
fn key_length() -> usize;
fn tag_length() -> usize;
fn new(key: &[u8]) -> Self;
fn result<T>(&self, data: &[u8]) -> T
where T: From<Vec<u8>>;
fn verify(&self, data: &[u8], tag: &[u8]) -> bool {
self.result::<Bytes>(data) == tag
}
}
pub trait NonceMac: Mac {
fn nonce_length() -> usize;
fn with_nonce(&mut self, nonce: &[u8]) -> &mut Self;
fn with_size(&mut self, len: usize) -> &mut Self;
}