-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathmechanisms.rs
More file actions
106 lines (85 loc) · 2.68 KB
/
mechanisms.rs
File metadata and controls
106 lines (85 loc) · 2.68 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// NOTE: The mechanism implementations are currently littered with `#[inline(never)]`,
// which is annoyingly explicit + manual (easy to forget).
// The underlying concern is that the stack use of `ServiceResources::reply_to` would be
// "too big" if they all get inlined.
//
// Removing these inlines (2021-03-12) changes the `text` code size of an entire solo-bee
// firmware from 350416 to 351376 (larger), so it's at least not obvious that these inlines
// happen.
//
// The question of breaking down `reply_to` into smaller, more globally understandable pieces,
// should be revisited.
// TODO: rename to aes256-cbc-zero-iv
#[allow(unused_macros)]
macro_rules! dummy_impl {
($Mechanism:ident) => {
impl crate::service::Agree for $Mechanism {}
impl crate::service::DeriveKey for $Mechanism {}
impl crate::service::DeserializeKey for $Mechanism {}
impl crate::service::Exists for $Mechanism {}
impl crate::service::GenerateKey for $Mechanism {}
impl crate::service::SerializeKey for $Mechanism {}
impl crate::service::Sign for $Mechanism {}
impl crate::service::Verify for $Mechanism {}
}
}
pub struct Aes256Cbc {}
mod aes256cbc;
pub struct Chacha8Poly1305 {}
mod chacha8poly1305;
pub struct Ed255 {}
mod ed255;
pub struct HmacBlake2s {}
#[cfg(feature = "hmac-blake2s")]
mod hmacblake2s;
#[cfg(not(feature = "hmac-blake2s"))]
impl crate::service::DeriveKey for HmacBlake2s {}
#[cfg(not(feature = "hmac-blake2s"))]
impl crate::service::Sign for HmacBlake2s {}
pub struct HmacSha1 {}
mod hmacsha1;
pub struct HmacSha256 {}
mod hmacsha256;
pub struct HmacSha512 {}
#[cfg(feature = "hmac-sha512")]
mod hmacsha512;
#[cfg(not(feature = "hmac-sha512"))]
impl crate::service::DeriveKey for HmacSha512 {}
#[cfg(not(feature = "hmac-sha512"))]
impl crate::service::Sign for HmacSha512 {}
pub struct P384 {}
#[cfg(feature = "p384")]
mod p384;
#[cfg(not(feature = "p384"))]
dummy_impl!(P384);
pub struct Rsa2k {}
#[cfg(feature = "rsa2k")]
mod rsa2k;
pub struct P256 {}
pub struct P256Prehashed {}
mod p256;
pub struct Sha256 {}
mod sha256;
pub struct Tdes {}
mod tdes;
pub struct Totp {}
mod totp;
pub struct Trng {}
mod trng;
pub struct X255 {}
mod x255;
// pub enum MechanismEnum {
// NotImplemented,
// Ed255(ed255::Ed255),
// P256(p256::P256),
// }
// use crate::types::Mechanism;
// pub fn enum_to_type(mechanism: Mechanism) -> MechanismEnum {
// match mechanism {
// #[cfg(feature = "ed255")]
// Mechanism::Ed255 => MechanismEnum::Ed255(ed255::Ed255 {} ),
// #[cfg(feature = "p256")]
// Mechanism::P256 => MechanismEnum::P256(p256::P256 {} ),
// _ => MechanismEnum::NotImplemented,
// }
// }