Commit
Author: Mauro D [mauro@stalw.art]
Hash: e589e5daf8ad12be96c98fa11193fd73afe450f4
Timestamp: Fri, 14 Apr 2023 11:12:50 +0000 (1 year ago)

+35 -106 +/-6 browse
v0.3.1
1diff --git a/CHANGELOG.md b/CHANGELOG.md
2index 966ff07..07c5f7b 100644
3--- a/CHANGELOG.md
4+++ b/CHANGELOG.md
5 @@ -1,3 +1,7 @@
6+ mail-auth 0.3.1
7+ ================================
8+ - Fix: Avoid panicking on invalid RSA key input (#17)
9+
10 mail-auth 0.3.0
11 ================================
12 - ``ring`` backend support.
13 diff --git a/Cargo.toml b/Cargo.toml
14index ac9dcdd..9cfcf1b 100644
15--- a/Cargo.toml
16+++ b/Cargo.toml
17 @@ -1,7 +1,7 @@
18 [package]
19 name = "mail-auth"
20 description = "DKIM, ARC, SPF and DMARC library for Rust"
21- version = "0.3.0"
22+ version = "0.3.1"
23 edition = "2021"
24 authors = [ "Stalwart Labs <hello@stalw.art>"]
25 license = "Apache-2.0 OR MIT"
26 diff --git a/src/arc/mod.rs b/src/arc/mod.rs
27index a285379..6d6f65d 100644
28--- a/src/arc/mod.rs
29+++ b/src/arc/mod.rs
30 @@ -79,19 +79,14 @@ pub struct Set<'x> {
31 pub(crate) results: Header<'x, &'x Results>,
32 }
33
34- #[derive(Debug, PartialEq, Eq, Clone)]
35+ #[derive(Debug, PartialEq, Eq, Clone, Default)]
36 pub(crate) enum ChainValidation {
37+ #[default]
38 None,
39 Fail,
40 Pass,
41 }
42
43- impl Default for ChainValidation {
44- fn default() -> Self {
45- ChainValidation::None
46- }
47- }
48-
49 impl VerifySignature for Signature {
50 fn signature(&self) -> &[u8] {
51 &self.b
52 diff --git a/src/common/crypto/mod.rs b/src/common/crypto/mod.rs
53index caadf17..5707dce 100644
54--- a/src/common/crypto/mod.rs
55+++ b/src/common/crypto/mod.rs
56 @@ -144,9 +144,10 @@ impl AsRef<[u8]> for HashOutput {
57 }
58 }
59
60- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
61+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
62 pub enum Algorithm {
63 RsaSha1,
64+ #[default]
65 RsaSha256,
66 Ed25519Sha256,
67 }
68 diff --git a/src/dkim/mod.rs b/src/dkim/mod.rs
69index 6c5be8a..3994232 100644
70--- a/src/dkim/mod.rs
71+++ b/src/dkim/mod.rs
72 @@ -24,8 +24,9 @@ pub mod parse;
73 pub mod sign;
74 pub mod verify;
75
76- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
77+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
78 pub enum Canonicalization {
79+ #[default]
80 Relaxed,
81 Simple,
82 }
83 @@ -63,18 +64,6 @@ pub struct Signature {
84 pub(crate) cb: Canonicalization,
85 }
86
87- impl Default for Algorithm {
88- fn default() -> Self {
89- Algorithm::RsaSha256
90- }
91- }
92-
93- impl Default for Canonicalization {
94- fn default() -> Self {
95- Canonicalization::Relaxed
96- }
97- }
98-
99 #[derive(Debug, PartialEq, Eq, Clone)]
100 pub struct DomainKeyReport {
101 pub(crate) ra: String,
102 diff --git a/src/report/mod.rs b/src/report/mod.rs
103index 1b955a4..86f894c 100644
104--- a/src/report/mod.rs
105+++ b/src/report/mod.rs
106 @@ -32,27 +32,30 @@ pub struct ReportMetadata {
107 error: Vec<String>,
108 }
109
110- #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
111+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
112 pub enum Alignment {
113 Relaxed,
114 Strict,
115+ #[default]
116 Unspecified,
117 }
118
119- #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
120+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
121 pub enum Disposition {
122 None,
123 Quarantine,
124 Reject,
125+ #[default]
126 Unspecified,
127 }
128
129- #[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
130+ #[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
131 pub enum ActionDisposition {
132 None,
133 Pass,
134 Quarantine,
135 Reject,
136+ #[default]
137 Unspecified,
138 }
139
140 @@ -70,20 +73,22 @@ pub struct PolicyPublished {
141
142 impl Eq for PolicyPublished {}
143
144- #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
145+ #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
146 pub enum DmarcResult {
147 Pass,
148 Fail,
149+ #[default]
150 Unspecified,
151 }
152
153- #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
154+ #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
155 pub enum PolicyOverride {
156 Forwarded,
157 SampledOut,
158 TrustedForwarder,
159 MailingList,
160 LocalPolicy,
161+ #[default]
162 Other,
163 }
164
165 @@ -121,8 +126,9 @@ pub struct Identifier {
166 header_from: String,
167 }
168
169- #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
170+ #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
171 pub enum DkimResult {
172+ #[default]
173 None,
174 Pass,
175 Fail,
176 @@ -140,15 +146,17 @@ pub struct DKIMAuthResult {
177 human_result: Option<String>,
178 }
179
180- #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
181+ #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
182 pub enum SPFDomainScope {
183 Helo,
184 MailFrom,
185+ #[default]
186 Unspecified,
187 }
188
189- #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
190+ #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
191 pub enum SpfResult {
192+ #[default]
193 None,
194 Neutral,
195 Pass,
196 @@ -191,54 +199,6 @@ pub struct Report {
197
198 impl Eq for Report {}
199
200- impl Default for Alignment {
201- fn default() -> Self {
202- Alignment::Unspecified
203- }
204- }
205-
206- impl Default for Disposition {
207- fn default() -> Self {
208- Disposition::Unspecified
209- }
210- }
211-
212- impl Default for ActionDisposition {
213- fn default() -> Self {
214- ActionDisposition::None
215- }
216- }
217-
218- impl Default for DmarcResult {
219- fn default() -> Self {
220- DmarcResult::Unspecified
221- }
222- }
223-
224- impl Default for PolicyOverride {
225- fn default() -> Self {
226- PolicyOverride::Other
227- }
228- }
229-
230- impl Default for DkimResult {
231- fn default() -> Self {
232- DkimResult::None
233- }
234- }
235-
236- impl Default for SpfResult {
237- fn default() -> Self {
238- SpfResult::None
239- }
240- }
241-
242- impl Default for SPFDomainScope {
243- fn default() -> Self {
244- SPFDomainScope::Unspecified
245- }
246- }
247-
248 #[derive(Debug, Clone, PartialEq, Eq)]
249 pub enum Error {
250 MailParseError,
251 @@ -287,7 +247,7 @@ pub struct Feedback<'x> {
252 headers: Option<Cow<'x, [u8]>>,
253 }
254
255- #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
256+ #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
257 pub enum AuthFailureType {
258 Adsp,
259 BodyHash,
260 @@ -295,62 +255,42 @@ pub enum AuthFailureType {
261 Signature,
262 Spf,
263 Dmarc,
264+ #[default]
265 Unspecified,
266 }
267
268- #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
269+ #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
270 pub enum IdentityAlignment {
271 None,
272 Spf,
273 Dkim,
274 DkimSpf,
275+ #[default]
276 Unspecified,
277 }
278
279- #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
280+ #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
281 pub enum DeliveryResult {
282 Delivered,
283 Spam,
284 Policy,
285 Reject,
286 Other,
287+ #[default]
288 Unspecified,
289 }
290
291- #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
292+ #[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
293 pub enum FeedbackType {
294 Abuse,
295 AuthFailure,
296 Fraud,
297 NotSpam,
298+ #[default]
299 Other,
300 Virus,
301 }
302
303- impl Default for AuthFailureType {
304- fn default() -> Self {
305- AuthFailureType::Unspecified
306- }
307- }
308-
309- impl Default for IdentityAlignment {
310- fn default() -> Self {
311- IdentityAlignment::Unspecified
312- }
313- }
314-
315- impl Default for DeliveryResult {
316- fn default() -> Self {
317- DeliveryResult::Unspecified
318- }
319- }
320-
321- impl Default for FeedbackType {
322- fn default() -> Self {
323- FeedbackType::Other
324- }
325- }
326-
327 impl From<&crate::DkimResult> for AuthFailureType {
328 fn from(value: &crate::DkimResult) -> Self {
329 match value {