Commit
+34 -26 +/-9 browse
1 | diff --git a/src/arc/seal.rs b/src/arc/seal.rs |
2 | index cada5a8..b471559 100644 |
3 | --- a/src/arc/seal.rs |
4 | +++ b/src/arc/seal.rs |
5 | @@ -222,8 +222,9 @@ mod test { |
6 | crypto::{Ed25519Key, RsaKey, SigningKey}, |
7 | headers::HeaderWriter, |
8 | parse::TxtRecordParser, |
9 | + verify::DomainKey, |
10 | }, |
11 | - dkim::{DomainKey, Signature}, |
12 | + dkim::Signature, |
13 | AuthenticatedMessage, AuthenticationResults, DkimResult, Resolver, |
14 | }; |
15 | |
16 | diff --git a/src/arc/verify.rs b/src/arc/verify.rs |
17 | index 9cdf373..28c9c65 100644 |
18 | --- a/src/arc/verify.rs |
19 | +++ b/src/arc/verify.rs |
20 | @@ -17,9 +17,9 @@ use crate::{ |
21 | common::{ |
22 | crypto::{Algorithm, HashAlgorithm}, |
23 | headers::Header, |
24 | - verify::VerifySignature, |
25 | + verify::{DomainKey, VerifySignature}, |
26 | }, |
27 | - dkim::{verify::Verifier, Canonicalization, DomainKey}, |
28 | + dkim::{verify::Verifier, Canonicalization}, |
29 | ArcOutput, AuthenticatedMessage, DkimResult, Error, Resolver, |
30 | }; |
31 | |
32 | @@ -201,7 +201,8 @@ mod test { |
33 | }; |
34 | |
35 | use crate::{ |
36 | - common::parse::TxtRecordParser, dkim::DomainKey, AuthenticatedMessage, DkimResult, Resolver, |
37 | + common::{parse::TxtRecordParser, verify::DomainKey}, |
38 | + AuthenticatedMessage, DkimResult, Resolver, |
39 | }; |
40 | |
41 | #[tokio::test] |
42 | diff --git a/src/common/resolver.rs b/src/common/resolver.rs |
43 | index 9a8b9ca..55c5506 100644 |
44 | --- a/src/common/resolver.rs |
45 | +++ b/src/common/resolver.rs |
46 | @@ -23,7 +23,7 @@ use trust_dns_resolver::{ |
47 | }; |
48 | |
49 | use crate::{ |
50 | - dkim::{Atps, DomainKey, DomainKeyReport}, |
51 | + dkim::{Atps, DomainKeyReport}, |
52 | dmarc::Dmarc, |
53 | spf::{Macro, Spf}, |
54 | Error, Policy, Resolver, Txt, MX, |
55 | @@ -32,6 +32,7 @@ use crate::{ |
56 | use super::{ |
57 | lru::{DnsCache, LruCache}, |
58 | parse::TxtRecordParser, |
59 | + verify::DomainKey, |
60 | }; |
61 | |
62 | impl Resolver { |
63 | diff --git a/src/common/verify.rs b/src/common/verify.rs |
64 | index 1399ed8..891c74b 100644 |
65 | --- a/src/common/verify.rs |
66 | +++ b/src/common/verify.rs |
67 | @@ -8,7 +8,12 @@ |
68 | * except according to those terms. |
69 | */ |
70 | |
71 | - use crate::{common::crypto::Algorithm, dkim::DomainKey}; |
72 | + use super::crypto::{Algorithm, VerifyingKey}; |
73 | + |
74 | + pub struct DomainKey { |
75 | + pub(crate) p: Box<dyn VerifyingKey>, |
76 | + pub(crate) f: u64, |
77 | + } |
78 | |
79 | pub(crate) trait VerifySignature { |
80 | fn selector(&self) -> &str; |
81 | diff --git a/src/dkim/mod.rs b/src/dkim/mod.rs |
82 | index cafe4fc..51cfd40 100644 |
83 | --- a/src/dkim/mod.rs |
84 | +++ b/src/dkim/mod.rs |
85 | @@ -13,7 +13,7 @@ use std::borrow::Cow; |
86 | use crate::{ |
87 | arc::Set, |
88 | common::{ |
89 | - crypto::{Algorithm, HashAlgorithm, VerifyingKey}, |
90 | + crypto::{Algorithm, HashAlgorithm}, |
91 | verify::VerifySignature, |
92 | }, |
93 | ArcOutput, DkimOutput, DkimResult, Error, Version, |
94 | @@ -64,11 +64,6 @@ impl Default for Canonicalization { |
95 | } |
96 | } |
97 | |
98 | - pub struct DomainKey { |
99 | - pub(crate) p: Box<dyn VerifyingKey>, |
100 | - pub(crate) f: u64, |
101 | - } |
102 | - |
103 | #[derive(Debug, PartialEq, Eq, Clone)] |
104 | pub struct DomainKeyReport { |
105 | pub(crate) ra: String, |
106 | diff --git a/src/dkim/parse.rs b/src/dkim/parse.rs |
107 | index 56a5634..237c278 100644 |
108 | --- a/src/dkim/parse.rs |
109 | +++ b/src/dkim/parse.rs |
110 | @@ -13,14 +13,14 @@ use std::slice::Iter; |
111 | use mail_parser::decoders::base64::base64_decode_stream; |
112 | |
113 | use crate::{ |
114 | - common::{crypto::VerifyingKeyType, parse::*}, |
115 | + common::{crypto::VerifyingKeyType, parse::*, verify::DomainKey}, |
116 | dkim::{RR_EXPIRATION, RR_SIGNATURE, RR_UNKNOWN_TAG, RR_VERIFICATION}, |
117 | Error, |
118 | }; |
119 | |
120 | use super::{ |
121 | - Algorithm, Atps, Canonicalization, DomainKey, DomainKeyReport, Flag, HashAlgorithm, Service, |
122 | - Signature, Version, RR_DNS, RR_OTHER, RR_POLICY, |
123 | + Algorithm, Atps, Canonicalization, DomainKeyReport, Flag, HashAlgorithm, Service, Signature, |
124 | + Version, RR_DNS, RR_OTHER, RR_POLICY, |
125 | }; |
126 | |
127 | const ATPSH: u64 = (b'a' as u64) |
128 | @@ -463,11 +463,12 @@ mod test { |
129 | common::{ |
130 | crypto::{Algorithm, R_HASH_SHA1, R_HASH_SHA256}, |
131 | parse::TxtRecordParser, |
132 | + verify::DomainKey, |
133 | }, |
134 | dkim::{ |
135 | - Canonicalization, DomainKey, DomainKeyReport, Signature, RR_DNS, RR_EXPIRATION, |
136 | - RR_OTHER, RR_POLICY, RR_SIGNATURE, RR_UNKNOWN_TAG, RR_VERIFICATION, |
137 | - R_FLAG_MATCH_DOMAIN, R_FLAG_TESTING, R_SVC_ALL, R_SVC_EMAIL, |
138 | + Canonicalization, DomainKeyReport, Signature, RR_DNS, RR_EXPIRATION, RR_OTHER, |
139 | + RR_POLICY, RR_SIGNATURE, RR_UNKNOWN_TAG, RR_VERIFICATION, R_FLAG_MATCH_DOMAIN, |
140 | + R_FLAG_TESTING, R_SVC_ALL, R_SVC_EMAIL, |
141 | }, |
142 | }; |
143 | |
144 | diff --git a/src/dkim/sign.rs b/src/dkim/sign.rs |
145 | index cb77dde..7e694f3 100644 |
146 | --- a/src/dkim/sign.rs |
147 | +++ b/src/dkim/sign.rs |
148 | @@ -158,8 +158,9 @@ mod test { |
149 | common::{ |
150 | crypto::{Ed25519Key, RsaKey}, |
151 | parse::TxtRecordParser, |
152 | + verify::DomainKey, |
153 | }, |
154 | - dkim::{Atps, Canonicalization, DomainKey, DomainKeyReport, HashAlgorithm, Signature}, |
155 | + dkim::{Atps, Canonicalization, DomainKeyReport, HashAlgorithm, Signature}, |
156 | AuthenticatedMessage, DkimOutput, DkimResult, Resolver, |
157 | }; |
158 | |
159 | diff --git a/src/dkim/verify.rs b/src/dkim/verify.rs |
160 | index 3e91116..fa6fe65 100644 |
161 | --- a/src/dkim/verify.rs |
162 | +++ b/src/dkim/verify.rs |
163 | @@ -14,13 +14,16 @@ use sha1::{Digest, Sha1}; |
164 | use sha2::Sha256; |
165 | |
166 | use crate::{ |
167 | - common::{base32::Base32Writer, verify::VerifySignature}, |
168 | + common::{ |
169 | + base32::Base32Writer, |
170 | + verify::{DomainKey, VerifySignature}, |
171 | + }, |
172 | is_within_pct, AuthenticatedMessage, DkimOutput, DkimResult, Error, Resolver, |
173 | }; |
174 | |
175 | use super::{ |
176 | - Algorithm, Atps, DomainKey, DomainKeyReport, Flag, HashAlgorithm, Signature, RR_DNS, |
177 | - RR_EXPIRATION, RR_OTHER, RR_SIGNATURE, RR_VERIFICATION, |
178 | + Algorithm, Atps, DomainKeyReport, Flag, HashAlgorithm, Signature, RR_DNS, RR_EXPIRATION, |
179 | + RR_OTHER, RR_SIGNATURE, RR_VERIFICATION, |
180 | }; |
181 | |
182 | impl Resolver { |
183 | @@ -375,8 +378,8 @@ mod test { |
184 | }; |
185 | |
186 | use crate::{ |
187 | - common::parse::TxtRecordParser, |
188 | - dkim::{verify::Verifier, DomainKey}, |
189 | + common::{parse::TxtRecordParser, verify::DomainKey}, |
190 | + dkim::verify::Verifier, |
191 | AuthenticatedMessage, DkimResult, Resolver, |
192 | }; |
193 | |
194 | diff --git a/src/lib.rs b/src/lib.rs |
195 | index 050b94e..c3de0f5 100644 |
196 | --- a/src/lib.rs |
197 | +++ b/src/lib.rs |
198 | @@ -262,8 +262,8 @@ use std::{ |
199 | }; |
200 | |
201 | use arc::Set; |
202 | - use common::{crypto::HashAlgorithm, headers::Header, lru::LruCache}; |
203 | - use dkim::{Atps, Canonicalization, DomainKey, DomainKeyReport}; |
204 | + use common::{crypto::HashAlgorithm, headers::Header, lru::LruCache, verify::DomainKey}; |
205 | + use dkim::{Atps, Canonicalization, DomainKeyReport}; |
206 | use dmarc::Dmarc; |
207 | use spf::{Macro, Spf}; |
208 | use trust_dns_resolver::{proto::op::ResponseCode, TokioAsyncResolver}; |