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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use rand_core::RngCore;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct KeyNumber([u8; Self::LEN]);
impl KeyNumber {
pub const LEN: usize = 8;
pub(crate) fn new(num: [u8; Self::LEN]) -> Self {
Self(num)
}
pub(crate) fn generate<R: RngCore>(rng: &mut R) -> Self {
let mut num = [0u8; Self::LEN];
rng.fill_bytes(&mut num);
Self(num)
}
}
impl AsRef<[u8]> for KeyNumber {
fn as_ref(&self) -> &[u8] {
&self.0
}
}
pub(crate) const PUBLIC_KEY_LEN: usize = 32;
pub(crate) const FULL_KEY_LEN: usize = 64;
pub(crate) const SIG_LEN: usize = 64;
pub(crate) const PKGALG: [u8; 2] = *b"Ed";
pub(crate) const KDFALG: [u8; 2] = *b"BK";
pub(crate) const COMMENT_HEADER: &str = "untrusted comment: ";
pub(crate) const COMMENT_MAX_LEN: usize = 1024;
pub const DEFAULT_KDF_ROUNDS: u32 = 42;
#[cfg(test)]
mod tests {
use super::KeyNumber;
use core::fmt::Debug;
use core::hash::Hash;
static_assertions::assert_impl_all!(
KeyNumber: Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
Ord,
PartialOrd,
Send,
Sync
);
}