Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: dkimpy
3 Version: 1.1.8
4 Summary: DKIM (DomainKeys Identified Mail), ARC (Authenticated Receive Chain), and TLSRPT (TLS Report) email signing and verification
5 Home-page: https://launchpad.net/dkimpy
6 Author: Scott Kitterman
7 Author-email: [email protected]
8 License: BSD-like
9 Classifier: Development Status :: 5 - Production/Stable
10 Classifier: Environment :: No Input/Output (Daemon)
11 Classifier: Intended Audience :: Developers
12 Classifier: License :: DFSG approved
13 Classifier: Natural Language :: English
14 Classifier: Operating System :: OS Independent
15 Classifier: Programming Language :: Python :: 3
16 Classifier: Topic :: Communications :: Email :: Mail Transport Agents
17 Classifier: Topic :: Communications :: Email :: Filters
18 Classifier: Topic :: Internet :: Name Service (DNS)
19 Classifier: Topic :: Software Development :: Libraries :: Python Modules
20 Description-Content-Type: text/markdown
21 Provides-Extra: ARC
22 Provides-Extra: asyncio
23 Provides-Extra: ed25519
24 Provides-Extra: testing
25 License-File: LICENSE
26
27 dkimpy - DKIM (DomainKeys Identified Mail)
28 https://launchpad.net/dkimpy/
29
30 Friendly fork of:
31 http://hewgill.com/pydkim/
32
33 # INTRODUCTION
34
35 dkimpy is a library that implements DKIM (DomainKeys Identified Mail) email
36 signing and verification. Basic DKIM requirements are defined in RFC 6376:
37
38 https://tools.ietf.org/html/rfc6376
39
40 # VERSION
41
42 This is dkimpy 1.1.8.
43
44 # REQUIREMENTS
45
46 Dependencies will be automatically included for normal DKIM usage. The
47 extras_requires feature 'ed25519' will add the dependencies needed for signing
48 and verifying using the new DCRUP ed25519-sha256 algorithm. The
49 extras_requires feature 'ARC' will add the extra dependencies needed for ARC.
50 Similarly, extras_requires feature 'asyncio' will add the extra dependencies
51 needed for asyncio.
52
53 - Python 3.x >= 3.5. Recent versions have not been tested on python3 < 3.4,
54 but may still work on earlier python3 versions.
55 - dnspython or py3dns. dnspython is preferred if both are present and
56 installed to satisfy the DNS module requirement if neither are installed.
57 - authres. Needed for ARC.
58 - PyNaCl. Needed for use of ed25519 capability.
59 - aiodns. Needed for asycnio (Requires python3.5 or later)
60
61 # INSTALLATION
62
63 This package includes a scripts and man pages. For those to be installed when
64 installing using setup.py, the following incantation is required because
65 setuptools developers decided not being able to do this by default is a
66 feature:
67
68 ```python3 setup.py install --single-version-externally-managed --record=/dev/null```
69
70 # DOCUMENTATION
71
72 An online version of the package documentation for the most recent release can
73 be found at:
74
75 https://pymilter.org/pydkim/
76
77 # TESTING
78
79 To run dkimpy's test suite:
80
81 ```PYTHONPATH=. python3 dkim```
82
83 or
84
85 ```python3 test.py```
86
87 or
88
89 ```PYTHONPATH=. python3 -m unittest dkim.tests.test_suite```
90
91
92 Alternatively, if you have testrepository installed:
93
94 ```testr init```
95
96 ```testr run```
97
98 You should install all optional dependencies required for the test suite, e.g.
99 by creating a virtualenv and using:
100
101 ```pip install -e '.[testing]'```
102
103 The included ARC tests are very limited. The primary testing method for ARC
104 is using the ARC test suite: https://github.com/ValiMail/arc_test_suite
105
106 As of 0.6.0, all tests pass for both python2.7 and python3. The test suite
107 ships with test runners for dkimpy. After downloading the test suite, you
108 can run the signing and validation tests like this:
109
110 ```python3 ./testarc.py sign runners/arcsigntest.py```
111 ```python3 ./testarc.py validate runners/arcverifytest.py```
112
113 As ov version 1.1.0, python2.7 is no longer supported.
114
115 # USAGE
116
117 The dkimpy library offers one module called dkim. The sign() function takes an
118 RFC822 formatted message, along with some signing options, and returns a
119 DKIM-Signature header line that can be prepended to the message. The verify()
120 function takes an RFC822 formatted message, and returns True or False depending
121 on whether the signature verifies correctly. There is also a DKIM class which
122 can be used to perform these functions in a more modern way.
123
124 In version 0.9.0, the default set of header fields that are oversigned was
125 changed from 'from', 'subject', 'date' to 'from' to reduce fragility of
126 signatures. To restore the previous behavior, you can add them back after
127 instantiating your DKIM class using the add_frozen function as shown in the
128 following example:
129
130 ```python
131 >>> dkim = DKIM()
132 >>> dkim.add_frozen((b'date',b'subject'))
133 >>> [text(x) for x in sorted(dkim.frozen_sign)]
134 ['date', 'from', 'subject']
135 ```
136
137 ## DKIM RSA MODERNIZATION (RFC 8301)
138
139 RFC8301 updated DKIM requirements in two ways:
140
141 1. It set the minimum valid RSA key size to 1024 bits.
142 2. It removed use of rsa-sha1.
143
144 As of version 0.7, the dkimpy defaults largely support these requirements.
145
146 It is possible to override the minimum key size to a lower value, but this is
147 strongly discouraged. As of 2018, keys much smaller than the minimum are not
148 difficult to factor.
149
150 The code for rsa-sha1 signing and verification is retained, but not used for
151 signing by default. Future releases will raise warnings and then errors when
152 verifying rsa-sha1 signatures. There are still some significant users of
153 rsa-sha1 signatures, so operationally it's premature to disable verification
154 of rsa-sha1.
155
156 ## ED25519 (RFC 8463) SUPPORT
157
158 As of version 0.7, experimental signing and verifying of DKIM Ed25519
159 signatures is supported as described in draft-ietf-dcrup-dkim-crypto:
160
161 https://datatracker.ietf.org/doc/draft-ietf-dcrup-dkim-crypto/
162
163 The RFC that documents ed25519 DKIM signatures, RFC 8463, has been released
164 and dkimpy 0.7 and later are aligned to its requirements. As of 0.8, ed25519
165 need not be considered experimental. The dkimpy implementation has
166 successfully interoperated with three other implementations and the technical
167 parameters for ed25519-sha256 are defined and stable.
168
169 To install from pypi with the required optional depenencies, use the ed25519
170 option:
171
172 ```pip install -e '.[ed25519]'```
173
174 ## DKIM SCRIPTS
175
176 Three helper programs are also supplied: dknewkey, dkimsign and
177 dkimverify
178
179 dknewkey is s script that produces private and public key pairs suitable
180 for use with DKIM. Note that the private key file format used for ed25519 is
181 not standardized (there is no standard) and is unique to dkimpy. Creation of
182 keys should be done in a secure environment. If an unauthorized entity gains
183 access to current private keys they can generate signed email that will pass
184 DKIM checkes and will be difficult to repudiate.
185
186 dkimsign is a filter that reads an RFC822 message on standard input, and
187 writes the same message on standard output with a DKIM-Signature line
188 prepended. The signing options are specified on the command line:
189
190 dkimsign selector domain privatekeyfile [identity]
191
192 The identity is optional and defaults to "@domain".
193
194 dkimverify reads an RFC822 message on standard input, and returns with exit
195 code 0 if the signature verifies successfully. Otherwise, it returns with exit
196 code 1.
197
198 ## ARC (Authenticated Receive Chain)
199
200 As of version 0.6.0, dkimpy provides experimental support for ARC (Authenticated
201 Received Chain). See RFC 8617 for the current version of ARC:
202
203 https://tools.ietf.org/html/rfc8617
204
205 In addition to arcsign and arcverify, the dkim module now provides
206 arc_sign and arc_verify functions as well as an ARC class.
207
208 If an invalid authentication results header field is included in the set for
209 ARC, it is ignored and no error is raised.
210
211 Both DKIM ed25519 and ARC are now considered stable (no longer experimantal).
212
213 ## ASYNC SUPPORT
214
215 As of version 1.0, an alternative to dkim.verify for use in an async
216 environment is provied. It requires aiodns, https://pypi.org/project/aiodns/.
217 Here is a simple example of dkim.verify_async usage:
218
219 ```python
220 >>> sys.stdin = sys.stdin.detach()
221 >>>
222 >>> async def main():
223 >>> res = await dkim.verify_async(message)
224 >>> return res
225 >>>
226 >>> if __name__ == "__main__":
227 >>> res = asyncio.run(main())
228 ```
229
230 This feature requires python3.5 or newer.
231
232 If aiodns is available, the async functions will be used. To avoide async
233 when aiodns is availale, set dkim.USE_ASYNC = False.
234
235 ## TLSRPT (TLS Report)
236
237 As of version 1.0, the RFC 8460 tlsrpt service type is supported:
238
239 https://tools.ietf.org/html/rfc8460
240
241 A non-tlsrpt signed with a key record with s=tlsrpt won't verify. Since the
242 service type (s=) is optional in the DKIM public key record, it is not
243 required by RFC 8460. When checking for a tlsrpt signature, set the tlsrpt=
244 flag when verifying the signature:
245
246 ```python
247 >>> res = dkim.verify(smessage, tlsrpt='strict')
248 ```
249
250 If tlsrpt='strict', only public key records with s=tlsrpt will be considered
251 valid. If set to tlsrpt=True, the service type is not required, but other
252 RFC 8460 requirements are applied.
253
254 # LIMITATIONS
255
256 Dkimpy will correctly sign/verify messages with ASCII or UTF-8 content.
257 Messages that contain other types of content will not verify correctly. It
258 does not yet implement RFC 8616, Email Authentication for Internationalized
259 Mail.
260
261 # FEEDBACK
262
263 Bug reports may be submitted to the bug tracker for the dkimpy project on
264 launchpad.