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
70
71
72
73
74
75
76
77
use std::fmt::{self, Debug, Display, Formatter};
use util::Sealed;
pub trait RsaKeyBits: Sized + Copy + Clone + Default + Display + Debug + Sealed {
const BITS: usize;
}
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq, Hash)]
pub struct B2048;
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq, Hash)]
pub struct B3072;
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq, Hash)]
pub struct B4096;
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq, Hash)]
pub struct B6144;
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq, Hash)]
pub struct B8192;
macro_rules! impl_bits {
($name:ident, $bits:expr) => {
impl RsaKeyBits for $name {
const BITS: usize = $bits;
}
impl Display for $name {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
write!(f, "{} bits", $bits)
}
}
impl Sealed for $name {}
};
}
impl_bits!(B2048, 2048);
impl_bits!(B3072, 3072);
impl_bits!(B4096, 4096);
impl_bits!(B6144, 6144);
impl_bits!(B8192, 8192);