Commit
Author: Mauro D [mauro@stalw.art]
Hash: 5caa04142a6185809c9b53a9ea30969e542bc8c8
Timestamp: Sun, 08 Jan 2023 14:45:44 +0000 (1 year ago)

+107 -102 +/-13 browse
Switched from Cow to String in Signatures and Seals.
1diff --git a/src/arc/builder.rs b/src/arc/builder.rs
2index 347a12b..f5780d4 100644
3--- a/src/arc/builder.rs
4+++ b/src/arc/builder.rs
5 @@ -1,4 +1,12 @@
6- use std::borrow::Cow;
7+ /*
8+ * Copyright (c) 2020-2023, Stalwart Labs Ltd.
9+ *
10+ * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
11+ * https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
12+ * <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
13+ * option. This file may not be copied, modified, or distributed
14+ * except according to those terms.
15+ */
16
17 use sha2::Sha256;
18
19 @@ -9,8 +17,8 @@ use crate::{
20
21 use super::{ArcSealer, Seal, Signature};
22
23- impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T> {
24- pub fn from_key(key: T) -> ArcSealer<'x, T, NeedDomain> {
25+ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T> {
26+ pub fn from_key(key: T) -> ArcSealer<T, NeedDomain> {
27 ArcSealer {
28 _state: Default::default(),
29 signature: Signature {
30 @@ -26,12 +34,9 @@ impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T> {
31 }
32 }
33
34- impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, NeedDomain> {
35+ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, NeedDomain> {
36 /// Sets the domain to use for signing.
37- pub fn domain(
38- mut self,
39- domain: impl Into<Cow<'x, str>> + Clone,
40- ) -> ArcSealer<'x, T, NeedSelector> {
41+ pub fn domain(mut self, domain: impl Into<String> + Clone) -> ArcSealer<T, NeedSelector> {
42 self.signature.d = domain.clone().into();
43 self.seal.d = domain.into();
44 ArcSealer {
45 @@ -43,12 +48,9 @@ impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, NeedDomain> {
46 }
47 }
48
49- impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, NeedSelector> {
50+ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, NeedSelector> {
51 /// Sets the selector to use for signing.
52- pub fn selector(
53- mut self,
54- selector: impl Into<Cow<'x, str>> + Clone,
55- ) -> ArcSealer<'x, T, NeedHeaders> {
56+ pub fn selector(mut self, selector: impl Into<String> + Clone) -> ArcSealer<T, NeedHeaders> {
57 self.signature.s = selector.clone().into();
58 self.seal.s = selector.into();
59 ArcSealer {
60 @@ -60,12 +62,12 @@ impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, NeedSelector> {
61 }
62 }
63
64- impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, NeedHeaders> {
65+ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, NeedHeaders> {
66 /// Sets the headers to sign.
67 pub fn headers(
68 mut self,
69- headers: impl IntoIterator<Item = impl Into<Cow<'x, str>>>,
70- ) -> ArcSealer<'x, T, Done> {
71+ headers: impl IntoIterator<Item = impl Into<String>>,
72+ ) -> ArcSealer<T, Done> {
73 self.signature.h = headers.into_iter().map(|h| h.into()).collect();
74 ArcSealer {
75 _state: Default::default(),
76 @@ -76,7 +78,7 @@ impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, NeedHeaders> {
77 }
78 }
79
80- impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, Done> {
81+ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, Done> {
82 /// Sets the number of seconds from now to use for the signature expiration.
83 pub fn expiration(mut self, expiration: u64) -> Self {
84 self.signature.x = expiration;
85 diff --git a/src/arc/headers.rs b/src/arc/headers.rs
86index 613dd1e..f88d5be 100644
87--- a/src/arc/headers.rs
88+++ b/src/arc/headers.rs
89 @@ -19,7 +19,7 @@ use crate::{
90
91 use super::{ArcSet, ChainValidation, Seal, Signature};
92
93- impl<'x> Signature<'x> {
94+ impl Signature {
95 pub(crate) fn write(&self, writer: &mut impl Writer, as_header: bool) {
96 let (header, new_line) = match self.ch {
97 Canonicalization::Relaxed if !as_header => (&b"arc-message-signature:"[..], &b" "[..]),
98 @@ -98,7 +98,7 @@ impl<'x> Signature<'x> {
99 }
100 }
101
102- impl<'x> Seal<'x> {
103+ impl Seal {
104 pub(crate) fn write(&self, writer: &mut impl Writer, as_header: bool) {
105 let (header, new_line) = if !as_header {
106 (&b"arc-seal:"[..], &b" "[..])
107 diff --git a/src/arc/mod.rs b/src/arc/mod.rs
108index 19d5cd6..ed4ea20 100644
109--- a/src/arc/mod.rs
110+++ b/src/arc/mod.rs
111 @@ -14,8 +14,6 @@ pub mod parse;
112 pub mod seal;
113 pub mod verify;
114
115- use std::borrow::Cow;
116-
117 use sha2::Sha256;
118
119 use crate::{
120 @@ -29,23 +27,23 @@ use crate::{
121 };
122
123 #[derive(Debug, PartialEq, Eq, Clone, Default)]
124- pub struct ArcSealer<'x, T: SigningKey<Hasher = Sha256>, State = NeedDomain> {
125+ pub struct ArcSealer<T: SigningKey<Hasher = Sha256>, State = NeedDomain> {
126 _state: std::marker::PhantomData<State>,
127 pub(crate) key: T,
128- pub(crate) signature: Signature<'x>,
129- pub(crate) seal: Seal<'x>,
130+ pub(crate) signature: Signature,
131+ pub(crate) seal: Seal,
132 }
133
134 #[derive(Debug, PartialEq, Eq, Clone, Default)]
135- pub struct Signature<'x> {
136+ pub struct Signature {
137 pub(crate) i: u32,
138 pub(crate) a: Algorithm,
139- pub(crate) d: Cow<'x, str>,
140- pub(crate) s: Cow<'x, str>,
141+ pub(crate) d: String,
142+ pub(crate) s: String,
143 pub(crate) b: Vec<u8>,
144 pub(crate) bh: Vec<u8>,
145- pub(crate) h: Vec<Cow<'x, str>>,
146- pub(crate) z: Vec<Cow<'x, str>>,
147+ pub(crate) h: Vec<String>,
148+ pub(crate) z: Vec<String>,
149 pub(crate) l: u64,
150 pub(crate) x: u64,
151 pub(crate) t: u64,
152 @@ -54,12 +52,12 @@ pub struct Signature<'x> {
153 }
154
155 #[derive(Debug, PartialEq, Eq, Clone, Default)]
156- pub struct Seal<'x> {
157+ pub struct Seal {
158 pub(crate) i: u32,
159 pub(crate) a: Algorithm,
160 pub(crate) b: Vec<u8>,
161- pub(crate) d: Cow<'x, str>,
162- pub(crate) s: Cow<'x, str>,
163+ pub(crate) d: String,
164+ pub(crate) s: String,
165 pub(crate) t: u64,
166 pub(crate) cv: ChainValidation,
167 }
168 @@ -71,15 +69,15 @@ pub struct Results {
169
170 #[derive(Debug, Clone, PartialEq, Eq)]
171 pub struct ArcSet<'x> {
172- pub(crate) signature: Signature<'x>,
173- pub(crate) seal: Seal<'x>,
174+ pub(crate) signature: Signature,
175+ pub(crate) seal: Seal,
176 pub(crate) results: &'x AuthenticationResults<'x>,
177 }
178
179 #[derive(Debug, Clone, PartialEq, Eq)]
180 pub struct Set<'x> {
181- pub(crate) signature: Header<'x, &'x Signature<'x>>,
182- pub(crate) seal: Header<'x, &'x Seal<'x>>,
183+ pub(crate) signature: Header<'x, &'x Signature>,
184+ pub(crate) seal: Header<'x, &'x Seal>,
185 pub(crate) results: Header<'x, &'x Results>,
186 }
187
188 @@ -96,7 +94,7 @@ impl Default for ChainValidation {
189 }
190 }
191
192- impl<'x> VerifySignature for Signature<'x> {
193+ impl VerifySignature for Signature {
194 fn signature(&self) -> &[u8] {
195 &self.b
196 }
197 @@ -114,7 +112,7 @@ impl<'x> VerifySignature for Signature<'x> {
198 }
199 }
200
201- impl<'x> VerifySignature for Seal<'x> {
202+ impl VerifySignature for Seal {
203 fn signature(&self) -> &[u8] {
204 &self.b
205 }
206 diff --git a/src/arc/parse.rs b/src/arc/parse.rs
207index 5a31b2c..c8db680 100644
208--- a/src/arc/parse.rs
209+++ b/src/arc/parse.rs
210 @@ -22,7 +22,7 @@ use crate::common::parse::*;
211
212 pub(crate) const CV: u64 = (b'c' as u64) | ((b'v' as u64) << 8);
213
214- impl<'x> Signature<'x> {
215+ impl Signature {
216 #[allow(clippy::while_let_on_iterator)]
217 pub fn parse(header: &'_ [u8]) -> crate::Result<Self> {
218 let mut signature = Signature {
219 @@ -67,10 +67,10 @@ impl<'x> Signature<'x> {
220 signature.ch = ch;
221 signature.cb = cb;
222 }
223- D => signature.d = header.text(true).into(),
224+ D => signature.d = header.text(true),
225 H => signature.h = header.items(),
226 L => signature.l = header.number().unwrap_or(0),
227- S => signature.s = header.text(true).into(),
228+ S => signature.s = header.text(true),
229 T => signature.t = header.number().unwrap_or(0),
230 X => signature.x = header.number().unwrap_or(0),
231 Z => signature.z = header.headers_qp(),
232 @@ -91,7 +91,7 @@ impl<'x> Signature<'x> {
233 }
234 }
235
236- impl<'x> Seal<'x> {
237+ impl Seal {
238 #[allow(clippy::while_let_on_iterator)]
239 pub fn parse(header: &'_ [u8]) -> crate::Result<Self> {
240 let mut seal = Seal {
241 @@ -119,8 +119,8 @@ impl<'x> Seal<'x> {
242 seal.b =
243 base64_decode_stream(&mut header, header_len, b';').ok_or(Error::Base64)?
244 }
245- D => seal.d = header.text(true).into(),
246- S => seal.s = header.text(true).into(),
247+ D => seal.d = header.text(true),
248+ S => seal.s = header.text(true),
249 T => seal.t = header.number().unwrap_or(0),
250 CV => {
251 match header.next_skip_whitespaces().unwrap_or(0) {
252 diff --git a/src/arc/seal.rs b/src/arc/seal.rs
253index bbeee2a..25eaf2f 100644
254--- a/src/arc/seal.rs
255+++ b/src/arc/seal.rs
256 @@ -8,7 +8,7 @@
257 * except according to those terms.
258 */
259
260- use std::{borrow::Cow, io::Write, time::SystemTime};
261+ use std::{io::Write, time::SystemTime};
262
263 use mail_builder::encoders::base64::base64_encode;
264 use sha2::{Digest, Sha256};
265 @@ -21,8 +21,8 @@ use crate::{
266
267 use super::{ArcSealer, ArcSet, ChainValidation, Signature};
268
269- impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, Done> {
270- pub fn seal(
271+ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, Done> {
272+ pub fn seal<'x>(
273 &self,
274 message: &'x AuthenticatedMessage<'x>,
275 results: &'x AuthenticationResults,
276 @@ -120,14 +120,14 @@ impl<'x, T: SigningKey<Hasher = Sha256>> ArcSealer<'x, T, Done> {
277 }
278 }
279
280- impl<'x> Signature<'x> {
281+ impl Signature {
282 #[allow(clippy::while_let_on_iterator)]
283- pub(crate) fn canonicalize(
284+ pub(crate) fn canonicalize<'x>(
285 &self,
286 message: &'x AuthenticatedMessage<'x>,
287 header_hasher: &mut impl Writer,
288 body_hasher: &mut impl Writer,
289- ) -> crate::Result<(usize, Vec<Cow<'x, str>>)> {
290+ ) -> crate::Result<(usize, Vec<String>)> {
291 let mut headers = Vec::with_capacity(self.h.len());
292 let mut found_headers = vec![false; self.h.len()];
293 let mut signed_headers = Vec::with_capacity(self.h.len());
294 @@ -153,7 +153,7 @@ impl<'x> Signature<'x> {
295 signed_headers.reverse();
296 for (header, found) in self.h.iter().zip(found_headers) {
297 if !found {
298- signed_headers.push(header.to_string().into());
299+ signed_headers.push(header.to_string());
300 }
301 }
302
303 diff --git a/src/dkim/builder.rs b/src/dkim/builder.rs
304index f7def04..aeeafa4 100644
305--- a/src/dkim/builder.rs
306+++ b/src/dkim/builder.rs
307 @@ -1,10 +1,19 @@
308+ /*
309+ * Copyright (c) 2020-2023, Stalwart Labs Ltd.
310+ *
311+ * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
312+ * https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
313+ * <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
314+ * option. This file may not be copied, modified, or distributed
315+ * except according to those terms.
316+ */
317+
318 use crate::common::crypto::{HashAlgorithm, SigningKey};
319- use std::borrow::Cow;
320
321 use super::{Canonicalization, DkimSigner, Done, NeedDomain, NeedHeaders, NeedSelector, Signature};
322
323- impl<'x, T: SigningKey> DkimSigner<'x, T> {
324- pub fn from_key(key: T) -> DkimSigner<'x, T, NeedDomain> {
325+ impl<T: SigningKey> DkimSigner<T> {
326+ pub fn from_key(key: T) -> DkimSigner<T, NeedDomain> {
327 DkimSigner {
328 _state: Default::default(),
329 template: Signature {
330 @@ -17,9 +26,9 @@ impl<'x, T: SigningKey> DkimSigner<'x, T> {
331 }
332 }
333
334- impl<'x, T: SigningKey> DkimSigner<'x, T, NeedDomain> {
335+ impl<T: SigningKey> DkimSigner<T, NeedDomain> {
336 /// Sets the domain to use for signing.
337- pub fn domain(mut self, domain: impl Into<Cow<'x, str>>) -> DkimSigner<'x, T, NeedSelector> {
338+ pub fn domain(mut self, domain: impl Into<String>) -> DkimSigner<T, NeedSelector> {
339 self.template.d = domain.into();
340 DkimSigner {
341 _state: Default::default(),
342 @@ -29,9 +38,9 @@ impl<'x, T: SigningKey> DkimSigner<'x, T, NeedDomain> {
343 }
344 }
345
346- impl<'x, T: SigningKey> DkimSigner<'x, T, NeedSelector> {
347+ impl<T: SigningKey> DkimSigner<T, NeedSelector> {
348 /// Sets the selector to use for signing.
349- pub fn selector(mut self, selector: impl Into<Cow<'x, str>>) -> DkimSigner<'x, T, NeedHeaders> {
350+ pub fn selector(mut self, selector: impl Into<String>) -> DkimSigner<T, NeedHeaders> {
351 self.template.s = selector.into();
352 DkimSigner {
353 _state: Default::default(),
354 @@ -41,12 +50,12 @@ impl<'x, T: SigningKey> DkimSigner<'x, T, NeedSelector> {
355 }
356 }
357
358- impl<'x, T: SigningKey> DkimSigner<'x, T, NeedHeaders> {
359+ impl<T: SigningKey> DkimSigner<T, NeedHeaders> {
360 /// Sets the headers to sign.
361 pub fn headers(
362 mut self,
363- headers: impl IntoIterator<Item = impl Into<Cow<'x, str>>>,
364- ) -> DkimSigner<'x, T, Done> {
365+ headers: impl IntoIterator<Item = impl Into<String>>,
366+ ) -> DkimSigner<T, Done> {
367 self.template.h = headers.into_iter().map(|h| h.into()).collect();
368 DkimSigner {
369 _state: Default::default(),
370 @@ -56,9 +65,9 @@ impl<'x, T: SigningKey> DkimSigner<'x, T, NeedHeaders> {
371 }
372 }
373
374- impl<'x, T: SigningKey> DkimSigner<'x, T, Done> {
375+ impl<T: SigningKey> DkimSigner<T, Done> {
376 /// Sets the third party signature.
377- pub fn atps(mut self, atps: impl Into<Cow<'x, str>>) -> Self {
378+ pub fn atps(mut self, atps: impl Into<String>) -> Self {
379 self.template.atps = Some(atps.into());
380 self
381 }
382 @@ -70,7 +79,7 @@ impl<'x, T: SigningKey> DkimSigner<'x, T, Done> {
383 }
384
385 /// Sets the selector to use for signing.
386- pub fn agent_user_identifier(mut self, auid: impl Into<Cow<'x, str>>) -> Self {
387+ pub fn agent_user_identifier(mut self, auid: impl Into<String>) -> Self {
388 self.template.i = auid.into();
389 self
390 }
391 diff --git a/src/dkim/canonicalize.rs b/src/dkim/canonicalize.rs
392index 424074b..7ad70bd 100644
393--- a/src/dkim/canonicalize.rs
394+++ b/src/dkim/canonicalize.rs
395 @@ -8,8 +8,6 @@
396 * except according to those terms.
397 */
398
399- use std::borrow::Cow;
400-
401 use sha1::Digest;
402
403 use crate::common::headers::{HeaderIterator, Writer};
404 @@ -146,14 +144,14 @@ impl Canonicalization {
405 }
406 }
407
408- impl<'x> Signature<'x> {
409+ impl Signature {
410 #[allow(clippy::while_let_on_iterator)]
411 pub(crate) fn canonicalize(
412 &self,
413- message: &'x [u8],
414+ message: &[u8],
415 header_hasher: &mut impl Writer,
416 body_hasher: &mut impl Writer,
417- ) -> (usize, Vec<Cow<'x, str>>) {
418+ ) -> (usize, Vec<String>) {
419 let mut headers_it = HeaderIterator::new(message);
420 let mut headers = Vec::with_capacity(self.h.len());
421 let mut found_headers = vec![false; self.h.len()];
422 @@ -184,7 +182,7 @@ impl<'x> Signature<'x> {
423 signed_headers.reverse();
424 for (header, found) in self.h.iter().zip(found_headers) {
425 if !found {
426- signed_headers.push(header.to_string().into());
427+ signed_headers.push(header.to_string());
428 }
429 }
430
431 diff --git a/src/dkim/headers.rs b/src/dkim/headers.rs
432index e12f30f..6f70bd0 100644
433--- a/src/dkim/headers.rs
434+++ b/src/dkim/headers.rs
435 @@ -14,7 +14,7 @@ use crate::common::headers::{HeaderWriter, Writer};
436
437 use super::{Algorithm, Canonicalization, HashAlgorithm, Signature};
438
439- impl<'x> Signature<'x> {
440+ impl Signature {
441 pub(crate) fn write(&self, writer: &mut impl Writer, as_header: bool) {
442 let (header, new_line) = match self.ch {
443 Canonicalization::Relaxed if !as_header => (&b"dkim-signature:"[..], &b" "[..]),
444 @@ -131,13 +131,13 @@ impl<'x> Signature<'x> {
445 }
446 }
447
448- impl<'x> HeaderWriter for Signature<'x> {
449+ impl HeaderWriter for Signature {
450 fn write_header(&self, writer: &mut impl Writer) {
451 self.write(writer, true);
452 }
453 }
454
455- impl<'x> Display for Signature<'x> {
456+ impl Display for Signature {
457 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
458 let mut buf = Vec::new();
459 self.write(&mut buf, false);
460 diff --git a/src/dkim/mod.rs b/src/dkim/mod.rs
461index 846ff4b..e4bc283 100644
462--- a/src/dkim/mod.rs
463+++ b/src/dkim/mod.rs
464 @@ -8,8 +8,6 @@
465 * except according to those terms.
466 */
467
468- use std::borrow::Cow;
469-
470 use crate::{
471 arc::Set,
472 common::{
473 @@ -33,10 +31,10 @@ pub enum Canonicalization {
474 }
475
476 #[derive(Debug, PartialEq, Eq, Clone, Default)]
477- pub struct DkimSigner<'x, T: SigningKey, State = NeedDomain> {
478+ pub struct DkimSigner<T: SigningKey, State = NeedDomain> {
479 _state: std::marker::PhantomData<State>,
480 pub(crate) key: T,
481- pub(crate) template: Signature<'x>,
482+ pub(crate) template: Signature,
483 }
484
485 pub struct NeedDomain;
486 @@ -45,21 +43,21 @@ pub struct NeedHeaders;
487 pub struct Done;
488
489 #[derive(Debug, PartialEq, Eq, Clone, Default)]
490- pub struct Signature<'x> {
491+ pub struct Signature {
492 pub(crate) v: u32,
493 pub(crate) a: Algorithm,
494- pub(crate) d: Cow<'x, str>,
495- pub(crate) s: Cow<'x, str>,
496+ pub(crate) d: String,
497+ pub(crate) s: String,
498 pub(crate) b: Vec<u8>,
499 pub(crate) bh: Vec<u8>,
500- pub(crate) h: Vec<Cow<'x, str>>,
501- pub(crate) z: Vec<Cow<'x, str>>,
502- pub(crate) i: Cow<'x, str>,
503+ pub(crate) h: Vec<String>,
504+ pub(crate) z: Vec<String>,
505+ pub(crate) i: String,
506 pub(crate) l: u64,
507 pub(crate) x: u64,
508 pub(crate) t: u64,
509 pub(crate) r: bool, // RFC 6651
510- pub(crate) atps: Option<Cow<'x, str>>, // RFC 6541
511+ pub(crate) atps: Option<String>, // RFC 6541
512 pub(crate) atpsh: Option<HashAlgorithm>, // RFC 6541
513 pub(crate) ch: Canonicalization,
514 pub(crate) cb: Canonicalization,
515 @@ -145,7 +143,7 @@ impl From<Algorithm> for HashAlgorithm {
516 }
517 }
518
519- impl<'x> VerifySignature for Signature<'x> {
520+ impl VerifySignature for Signature {
521 fn signature(&self) -> &[u8] {
522 &self.b
523 }
524 @@ -217,7 +215,7 @@ impl<'x> DkimOutput<'x> {
525 }
526 }
527
528- pub(crate) fn with_signature(mut self, signature: &'x Signature<'x>) -> Self {
529+ pub(crate) fn with_signature(mut self, signature: &'x Signature) -> Self {
530 self.signature = signature.into();
531 self
532 }
533 diff --git a/src/dkim/parse.rs b/src/dkim/parse.rs
534index 211f8b9..077e461 100644
535--- a/src/dkim/parse.rs
536+++ b/src/dkim/parse.rs
537 @@ -43,7 +43,7 @@ const RR: u64 = (b'r' as u64) | (b'r' as u64) << 8;
538 const RS: u64 = (b'r' as u64) | (b's' as u64) << 8;
539 const ALL: u64 = (b'a' as u64) | (b'l' as u64) << 8 | (b'l' as u64) << 16;
540
541- impl<'x> Signature<'x> {
542+ impl Signature {
543 #[allow(clippy::while_let_on_iterator)]
544 pub fn parse(header: &'_ [u8]) -> crate::Result<Self> {
545 let mut signature = Signature {
546 @@ -92,18 +92,18 @@ impl<'x> Signature<'x> {
547 signature.ch = ch;
548 signature.cb = cb;
549 }
550- D => signature.d = header.text(true).into(),
551+ D => signature.d = header.text(true),
552 H => signature.h = header.items(),
553- I => signature.i = header.text_qp(Vec::with_capacity(20), true, false).into(),
554+ I => signature.i = header.text_qp(Vec::with_capacity(20), true, false),
555 L => signature.l = header.number().unwrap_or(0),
556- S => signature.s = header.text(true).into(),
557+ S => signature.s = header.text(true),
558 T => signature.t = header.number().unwrap_or(0),
559 X => signature.x = header.number().unwrap_or(0),
560 Z => signature.z = header.headers_qp(),
561 R => signature.r = header.value() == Y,
562 ATPS => {
563 if signature.atps.is_none() {
564- signature.atps = Some(header.text(true).into());
565+ signature.atps = Some(header.text(true));
566 }
567 }
568 ATPSH => {
569 diff --git a/src/dkim/sign.rs b/src/dkim/sign.rs
570index b7f38f4..05093a8 100644
571--- a/src/dkim/sign.rs
572+++ b/src/dkim/sign.rs
573 @@ -16,10 +16,10 @@ use sha1::Digest;
574 use super::{DkimSigner, Done, Signature};
575 use crate::{common::crypto::SigningKey, Error};
576
577- impl<'x, T: SigningKey> DkimSigner<'x, T, Done> {
578+ impl<T: SigningKey> DkimSigner<T, Done> {
579 /// Signs a message.
580 #[inline(always)]
581- pub fn sign(&self, message: &'x [u8]) -> crate::Result<Signature<'x>> {
582+ pub fn sign(&self, message: &[u8]) -> crate::Result<Signature> {
583 self.sign_(
584 message,
585 SystemTime::now()
586 @@ -29,7 +29,7 @@ impl<'x, T: SigningKey> DkimSigner<'x, T, Done> {
587 )
588 }
589
590- fn sign_(&self, message: &'x [u8], now: u64) -> crate::Result<Signature<'x>> {
591+ fn sign_(&self, message: &[u8], now: u64) -> crate::Result<Signature> {
592 let mut body_hasher = self.key.hasher();
593 let mut header_hasher = self.key.hasher();
594
595 @@ -359,7 +359,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc=
596
597 async fn verify<'x>(
598 resolver: &Resolver,
599- signature: Signature<'x>,
600+ signature: Signature,
601 message_: &'x str,
602 expect: Result<(), super::Error>,
603 ) -> Vec<DkimOutput<'x>> {
604 diff --git a/src/dkim/verify.rs b/src/dkim/verify.rs
605index 01c60fe..402a659 100644
606--- a/src/dkim/verify.rs
607+++ b/src/dkim/verify.rs
608 @@ -8,7 +8,7 @@
609 * except according to those terms.
610 */
611
612- use std::{borrow::Cow, io::Write, time::SystemTime};
613+ use std::{io::Write, time::SystemTime};
614
615 use sha1::{Digest, Sha1};
616 use sha2::Sha256;
617 @@ -252,7 +252,7 @@ impl Resolver {
618 impl<'x> AuthenticatedMessage<'x> {
619 pub fn signed_headers<'z: 'x>(
620 &'z self,
621- headers: &'x [Cow<'x, str>],
622+ headers: &'x [String],
623 dkim_hdr_name: &'x [u8],
624 dkim_hdr_value: &'x [u8],
625 ) -> impl Iterator<Item = (&'x [u8], &'x [u8])> {
626 @@ -288,7 +288,7 @@ impl<'x> AuthenticatedMessage<'x> {
627 }
628 }
629
630- impl<'x> Signature<'x> {
631+ impl Signature {
632 #[allow(clippy::while_let_on_iterator)]
633 pub(crate) fn validate_auid(&self, record: &DomainKey) -> bool {
634 // Enforce t=s flag
635 diff --git a/src/lib.rs b/src/lib.rs
636index 47a0947..10a08a4 100644
637--- a/src/lib.rs
638+++ b/src/lib.rs
639 @@ -320,9 +320,9 @@ pub struct AuthenticatedMessage<'x> {
640 pub(crate) from: Vec<String>,
641 pub(crate) body: &'x [u8],
642 pub(crate) body_hashes: Vec<(Canonicalization, HashAlgorithm, u64, Vec<u8>)>,
643- pub(crate) dkim_headers: Vec<Header<'x, crate::Result<dkim::Signature<'x>>>>,
644- pub(crate) ams_headers: Vec<Header<'x, crate::Result<arc::Signature<'x>>>>,
645- pub(crate) as_headers: Vec<Header<'x, crate::Result<arc::Seal<'x>>>>,
646+ pub(crate) dkim_headers: Vec<Header<'x, crate::Result<dkim::Signature>>>,
647+ pub(crate) ams_headers: Vec<Header<'x, crate::Result<arc::Signature>>>,
648+ pub(crate) as_headers: Vec<Header<'x, crate::Result<arc::Seal>>>,
649 pub(crate) aar_headers: Vec<Header<'x, crate::Result<arc::Results>>>,
650 }
651
652 @@ -352,7 +352,7 @@ pub enum DkimResult {
653 #[derive(Debug, PartialEq, Eq, Clone)]
654 pub struct DkimOutput<'x> {
655 result: DkimResult,
656- signature: Option<&'x dkim::Signature<'x>>,
657+ signature: Option<&'x dkim::Signature>,
658 report: Option<String>,
659 is_atps: bool,
660 }