-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathenums.rs
More file actions
183 lines (168 loc) · 5.15 KB
/
enums.rs
File metadata and controls
183 lines (168 loc) · 5.15 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
use num_enum::{IntoPrimitive, TryFromPrimitive};
use zeroize::Zeroize;
#[cfg(feature = "fuzz")]
use arbitrary::Arbitrary;
#[cfg(feature = "wbindgen")]
use wasm_bindgen::prelude::*;
/// The different data types.
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum DataType {
/// No data type. Only used as a default value.
#[default]
None = 0,
/// A wrapped key.
Key = 1,
/// A wrapped ciphertext. Can be either symmetric or asymmetric.
Ciphertext = 2,
/// A wrapped password hash. Used to verify a password.
PasswordHash = 3,
/// A wrapped share. Used for secret sharing scheme.
Share = 4,
/// A wrapped key used to sign data.
SigningKey = 5,
/// A wrapped signature.
Signature = 6,
/// A wrapped online ciphertextr that can be encrypted/decrypted chunk by chunk
OnlineCiphertext = 7,
}
/// The versions of the encryption scheme to use.
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum CiphertextVersion {
/// Uses the latest version.
#[default]
Latest = 0,
/// Uses version 1: AES256-CBC-HMAC-SHA2-256.
V1 = 1,
/// Uses version 2: XChaCha20-Poly1305.
V2 = 2,
}
/// The versions of the online encryption scheme to use.
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum OnlineCiphertextVersion {
/// Uses the latest version.
#[default]
Latest = 0,
/// Uses version 1: XChaCha20-Poly1305 wrapped in a STREAM construction.
V1 = 1,
}
/// The versions of the password hashing scheme to use.
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum PasswordHashVersion {
/// Uses the latest version.
#[default]
Latest = 0,
/// Uses version 1: PBKDF2-HMAC-SHA2-256.
V1 = 1,
}
/// The versions of the key scheme to use.
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum KeyVersion {
/// Uses the latest version.
#[default]
Latest = 0,
/// Uses version 1: Curve25519 keys and x25519 key exchange.
V1 = 1,
}
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum SigningKeyVersion {
/// Uses the latest version.
#[default]
Latest = 0,
/// Uses version 1: Ed25519.
V1 = 1,
}
/// The versions of the secret sharing scheme to use.
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum SecretSharingVersion {
/// Uses the latest version.
#[default]
Latest = 0,
/// Uses version 1: Shamir Secret Sharing over GF256.
V1 = 1,
}
/// The versions of the secret sharing scheme to use.
#[cfg_attr(feature = "wbindgen", wasm_bindgen())]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[repr(u16)]
#[derive(Default)]
pub enum SignatureVersion {
/// Uses the latest version.
#[default]
Latest = 0,
/// Uses version 1: ed25519
V1 = 1,
}
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[repr(u16)]
#[derive(Default)]
pub enum CiphertextSubtype {
#[default]
None = 0,
Symmetric = 1,
Asymmetric = 2,
}
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[repr(u16)]
#[derive(Default)]
pub enum KeySubtype {
#[default]
None = 0,
Private = 1,
Public = 2,
Pair = 3,
}
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[repr(u16)]
#[derive(Default)]
pub enum PasswordHashSubtype {
#[default]
None = 0,
}
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[repr(u16)]
#[derive(Default)]
pub enum ShareSubtype {
#[default]
None = 0,
}
#[derive(Clone, Copy, PartialEq, Eq, Zeroize, IntoPrimitive, TryFromPrimitive, Debug)]
#[cfg_attr(feature = "fuzz", derive(Arbitrary))]
#[repr(u16)]
#[derive(Default)]
pub enum SignatureSubtype {
#[default]
None = 0,
}