7Network Working Group E. Allman
8Request for Comments: 4871 Sendmail, Inc.
9Obsoletes: 4870 J. Callas
10Category: Standards Track PGP Corporation
20 DomainKeys Identified Mail (DKIM) Signatures
24 This document specifies an Internet standards track protocol for the
25 Internet community, and requests discussion and suggestions for
26 improvements. Please refer to the current edition of the "Internet
27 Official Protocol Standards" (STD 1) for the standardization state
28 and status of this protocol. Distribution of this memo is unlimited.
32 Copyright (C) The IETF Trust (2007).
36 DomainKeys Identified Mail (DKIM) defines a domain-level
37 authentication framework for email using public-key cryptography and
38 key server technology to permit verification of the source and
39 contents of messages by either Mail Transfer Agents (MTAs) or Mail
40 User Agents (MUAs). The ultimate goal of this framework is to permit
41 a signing domain to assert responsibility for a message, thus
42 protecting message signer identity and the integrity of the messages
43 they convey while retaining the functionality of Internet email as it
44 is known today. Protection of email identity may assist in the
45 global control of "spam" and "phishing".
58Allman, et al. Standards Track [Page 1]
60RFC 4871 DKIM Signatures May 2007
65 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4
66 1.1. Signing Identity . . . . . . . . . . . . . . . . . . . . . 5
67 1.2. Scalability . . . . . . . . . . . . . . . . . . . . . . . 5
68 1.3. Simple Key Management . . . . . . . . . . . . . . . . . . 5
69 2. Terminology and Definitions . . . . . . . . . . . . . . . . . 5
70 2.1. Signers . . . . . . . . . . . . . . . . . . . . . . . . . 6
71 2.2. Verifiers . . . . . . . . . . . . . . . . . . . . . . . . 6
72 2.3. Whitespace . . . . . . . . . . . . . . . . . . . . . . . . 6
73 2.4. Common ABNF Tokens . . . . . . . . . . . . . . . . . . . . 6
74 2.5. Imported ABNF Tokens . . . . . . . . . . . . . . . . . . . 7
75 2.6. DKIM-Quoted-Printable . . . . . . . . . . . . . . . . . . 7
76 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . . 8
77 3.1. Selectors . . . . . . . . . . . . . . . . . . . . . . . . 8
78 3.2. Tag=Value Lists . . . . . . . . . . . . . . . . . . . . . 10
79 3.3. Signing and Verification Algorithms . . . . . . . . . . . 11
80 3.4. Canonicalization . . . . . . . . . . . . . . . . . . . . . 13
81 3.5. The DKIM-Signature Header Field . . . . . . . . . . . . . 17
82 3.6. Key Management and Representation . . . . . . . . . . . . 25
83 3.7. Computing the Message Hashes . . . . . . . . . . . . . . . 29
84 3.8. Signing by Parent Domains . . . . . . . . . . . . . . . . 31
85 4. Semantics of Multiple Signatures . . . . . . . . . . . . . . . 32
86 4.1. Example Scenarios . . . . . . . . . . . . . . . . . . . . 32
87 4.2. Interpretation . . . . . . . . . . . . . . . . . . . . . . 33
88 5. Signer Actions . . . . . . . . . . . . . . . . . . . . . . . . 34
89 5.1. Determine Whether the Email Should Be Signed and by
90 Whom . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
91 5.2. Select a Private Key and Corresponding Selector
92 Information . . . . . . . . . . . . . . . . . . . . . . . 35
93 5.3. Normalize the Message to Prevent Transport Conversions . . 35
94 5.4. Determine the Header Fields to Sign . . . . . . . . . . . 36
95 5.5. Recommended Signature Content . . . . . . . . . . . . . . 38
96 5.6. Compute the Message Hash and Signature . . . . . . . . . . 39
97 5.7. Insert the DKIM-Signature Header Field . . . . . . . . . . 40
98 6. Verifier Actions . . . . . . . . . . . . . . . . . . . . . . . 40
99 6.1. Extract Signatures from the Message . . . . . . . . . . . 41
100 6.2. Communicate Verification Results . . . . . . . . . . . . . 46
101 6.3. Interpret Results/Apply Local Policy . . . . . . . . . . . 47
102 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 48
103 7.1. DKIM-Signature Tag Specifications . . . . . . . . . . . . 48
104 7.2. DKIM-Signature Query Method Registry . . . . . . . . . . . 49
105 7.3. DKIM-Signature Canonicalization Registry . . . . . . . . . 49
106 7.4. _domainkey DNS TXT Record Tag Specifications . . . . . . . 50
107 7.5. DKIM Key Type Registry . . . . . . . . . . . . . . . . . . 50
108 7.6. DKIM Hash Algorithms Registry . . . . . . . . . . . . . . 51
109 7.7. DKIM Service Types Registry . . . . . . . . . . . . . . . 51
110 7.8. DKIM Selector Flags Registry . . . . . . . . . . . . . . . 52
114Allman, et al. Standards Track [Page 2]
116RFC 4871 DKIM Signatures May 2007
119 7.9. DKIM-Signature Header Field . . . . . . . . . . . . . . . 52
120 8. Security Considerations . . . . . . . . . . . . . . . . . . . 52
121 8.1. Misuse of Body Length Limits ("l=" Tag) . . . . . . . . . 52
122 8.2. Misappropriated Private Key . . . . . . . . . . . . . . . 53
123 8.3. Key Server Denial-of-Service Attacks . . . . . . . . . . . 54
124 8.4. Attacks Against the DNS . . . . . . . . . . . . . . . . . 54
125 8.5. Replay Attacks . . . . . . . . . . . . . . . . . . . . . . 55
126 8.6. Limits on Revoking Keys . . . . . . . . . . . . . . . . . 55
127 8.7. Intentionally Malformed Key Records . . . . . . . . . . . 56
128 8.8. Intentionally Malformed DKIM-Signature Header Fields . . . 56
129 8.9. Information Leakage . . . . . . . . . . . . . . . . . . . 56
130 8.10. Remote Timing Attacks . . . . . . . . . . . . . . . . . . 56
131 8.11. Reordered Header Fields . . . . . . . . . . . . . . . . . 56
132 8.12. RSA Attacks . . . . . . . . . . . . . . . . . . . . . . . 56
133 8.13. Inappropriate Signing by Parent Domains . . . . . . . . . 57
134 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 57
135 9.1. Normative References . . . . . . . . . . . . . . . . . . . 57
136 9.2. Informative References . . . . . . . . . . . . . . . . . . 58
137 Appendix A. Example of Use (INFORMATIVE) . . . . . . . . . . . . 60
138 A.1. The user composes an email . . . . . . . . . . . . . . . . 60
139 A.2. The email is signed . . . . . . . . . . . . . . . . . . . 61
140 A.3. The email signature is verified . . . . . . . . . . . . . 61
141 Appendix B. Usage Examples (INFORMATIVE) . . . . . . . . . . . . 62
142 B.1. Alternate Submission Scenarios . . . . . . . . . . . . . . 63
143 B.2. Alternate Delivery Scenarios . . . . . . . . . . . . . . . 65
144 Appendix C. Creating a Public Key (INFORMATIVE) . . . . . . . . . 67
145 Appendix D. MUA Considerations . . . . . . . . . . . . . . . . . 68
146 Appendix E. Acknowledgements . . . . . . . . . . . . . . . . . . 69
170Allman, et al. Standards Track [Page 3]
172RFC 4871 DKIM Signatures May 2007
177 DomainKeys Identified Mail (DKIM) defines a mechanism by which email
178 messages can be cryptographically signed, permitting a signing domain
179 to claim responsibility for the introduction of a message into the
180 mail stream. Message recipients can verify the signature by querying
181 the signer's domain directly to retrieve the appropriate public key,
182 and thereby confirm that the message was attested to by a party in
183 possession of the private key for the signing domain.
185 The approach taken by DKIM differs from previous approaches to
186 message signing (e.g., Secure/Multipurpose Internet Mail Extensions
187 (S/MIME) [RFC1847], OpenPGP [RFC2440]) in that:
189 o the message signature is written as a message header field so that
190 neither human recipients nor existing MUA (Mail User Agent)
191 software is confused by signature-related content appearing in the
194 o there is no dependency on public and private key pairs being
195 issued by well-known, trusted certificate authorities;
197 o there is no dependency on the deployment of any new Internet
198 protocols or services for public key distribution or revocation;
200 o signature verification failure does not force rejection of the
203 o no attempt is made to include encryption as part of the mechanism;
205 o message archiving is not a design goal.
209 o is compatible with the existing email infrastructure and
210 transparent to the fullest extent possible;
212 o requires minimal new infrastructure;
214 o can be implemented independently of clients in order to reduce
217 o can be deployed incrementally;
219 o allows delegation of signing to third parties.
226Allman, et al. Standards Track [Page 4]
228RFC 4871 DKIM Signatures May 2007
233 DKIM separates the question of the identity of the signer of the
234 message from the purported author of the message. In particular, a
235 signature includes the identity of the signer. Verifiers can use the
236 signing information to decide how they want to process the message.
237 The signing identity is included as part of the signature header
240 INFORMATIVE RATIONALE: The signing identity specified by a DKIM
241 signature is not required to match an address in any particular
242 header field because of the broad methods of interpretation by
243 recipient mail systems, including MUAs.
247 DKIM is designed to support the extreme scalability requirements that
248 characterize the email identification problem. There are currently
249 over 70 million domains and a much larger number of individual
250 addresses. DKIM seeks to preserve the positive aspects of the
251 current email infrastructure, such as the ability for anyone to
252 communicate with anyone else without introduction.
2541.3. Simple Key Management
256 DKIM differs from traditional hierarchical public-key systems in that
257 no Certificate Authority infrastructure is required; the verifier
258 requests the public key from a repository in the domain of the
259 claimed signer directly rather than from a third party.
261 The DNS is proposed as the initial mechanism for the public keys.
262 Thus, DKIM currently depends on DNS administration and the security
263 of the DNS system. DKIM is designed to be extensible to other key
264 fetching services as they become available.
2662. Terminology and Definitions
268 This section defines terms used in the rest of the document. Syntax
269 descriptions use the form described in Augmented BNF for Syntax
270 Specifications [RFC4234].
272 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
273 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
274 document are to be interpreted as described in [RFC2119].
282Allman, et al. Standards Track [Page 5]
284RFC 4871 DKIM Signatures May 2007
289 Elements in the mail system that sign messages on behalf of a domain
290 are referred to as signers. These may be MUAs (Mail User Agents),
291 MSAs (Mail Submission Agents), MTAs (Mail Transfer Agents), or other
292 agents such as mailing list exploders. In general, any signer will
293 be involved in the injection of a message into the message system in
294 some way. The key issue is that a message must be signed before it
295 leaves the administrative domain of the signer.
299 Elements in the mail system that verify signatures are referred to as
300 verifiers. These may be MTAs, Mail Delivery Agents (MDAs), or MUAs.
301 In most cases it is expected that verifiers will be close to an end
302 user (reader) of the message or some consuming agent such as a
303 mailing list exploder.
307 There are three forms of whitespace:
309 o WSP represents simple whitespace, i.e., a space or a tab character
310 (formal definition in [RFC4234]).
312 o LWSP is linear whitespace, defined as WSP plus CRLF (formal
313 definition in [RFC4234]).
315 o FWS is folding whitespace. It allows multiple lines separated by
316 CRLF followed by at least one whitespace, to be joined.
318 The formal ABNF for these are (WSP and LWSP are given for information
322 LWSP = *(WSP / CRLF WSP)
323 FWS = [*WSP CRLF] 1*WSP
325 The definition of FWS is identical to that in [RFC2822] except for
326 the exclusion of obs-FWS.
3282.4. Common ABNF Tokens
330 The following ABNF tokens are used elsewhere in this document:
331 hyphenated-word = ALPHA [ *(ALPHA / DIGIT / "-") (ALPHA / DIGIT) ]
332 base64string = 1*(ALPHA / DIGIT / "+" / "/" / [FWS])
333 [ "=" [FWS] [ "=" [FWS] ] ]
338Allman, et al. Standards Track [Page 6]
340RFC 4871 DKIM Signatures May 2007
3432.5. Imported ABNF Tokens
345 The following tokens are imported from other RFCs as noted. Those
346 RFCs should be considered definitive.
348 The following tokens are imported from [RFC2821]:
350 o "Local-part" (implementation warning: this permits quoted strings)
354 The following tokens are imported from [RFC2822]:
356 o "field-name" (name of a header field)
358 o "dot-atom-text" (in the Local-part of an email address)
360 The following tokens are imported from [RFC2045]:
362 o "qp-section" (a single line of quoted-printable-encoded text)
364 o "hex-octet" (a quoted-printable encoded octet)
366 INFORMATIVE NOTE: Be aware that the ABNF in RFC 2045 does not obey
367 the rules of RFC 4234 and must be interpreted accordingly,
368 particularly as regards case folding.
370 Other tokens not defined herein are imported from [RFC4234]. These
371 are intuitive primitives such as SP, HTAB, WSP, ALPHA, DIGIT, CRLF,
3742.6. DKIM-Quoted-Printable
376 The DKIM-Quoted-Printable encoding syntax resembles that described in
377 Quoted-Printable [RFC2045], Section 6.7: any character MAY be encoded
378 as an "=" followed by two hexadecimal digits from the alphabet
379 "0123456789ABCDEF" (no lowercase characters permitted) representing
380 the hexadecimal-encoded integer value of that character. All control
381 characters (those with values < %x20), 8-bit characters (values >
382 %x7F), and the characters DEL (%x7F), SPACE (%x20), and semicolon
383 (";", %x3B) MUST be encoded. Note that all whitespace, including
384 SPACE, CR, and LF characters, MUST be encoded. After encoding, FWS
385 MAY be added at arbitrary locations in order to avoid excessively
386 long lines; such whitespace is NOT part of the value, and MUST be
387 removed before decoding.
394Allman, et al. Standards Track [Page 7]
396RFC 4871 DKIM Signatures May 2007
401 dkim-quoted-printable =
402 *(FWS / hex-octet / dkim-safe-char)
403 ; hex-octet is from RFC 2045
404 dkim-safe-char = %x21-3A / %x3C / %x3E-7E
405 ; '!' - ':', '<', '>' - '~'
406 ; Characters not listed as "mail-safe" in
407 ; RFC 2049 are also not recommended.
409 INFORMATIVE NOTE: DKIM-Quoted-Printable differs from Quoted-
410 Printable as defined in RFC 2045 in several important ways:
412 1. Whitespace in the input text, including CR and LF, must be
413 encoded. RFC 2045 does not require such encoding, and does
414 not permit encoding of CR or LF characters that are part of a
417 2. Whitespace in the encoded text is ignored. This is to allow
418 tags encoded using DKIM-Quoted-Printable to be wrapped as
419 needed. In particular, RFC 2045 requires that line breaks in
420 the input be represented as physical line breaks; that is not
423 3. The "soft line break" syntax ("=" as the last non-whitespace
424 character on the line) does not apply.
426 4. DKIM-Quoted-Printable does not require that encoded lines be
427 no more than 76 characters long (although there may be other
428 requirements depending on the context in which the encoded
433 Protocol Elements are conceptual parts of the protocol that are not
434 specific to either signers or verifiers. The protocol descriptions
435 for signers and verifiers are described in later sections (Signer
436 Actions (Section 5) and Verifier Actions (Section 6)). NOTE: This
437 section must be read in the context of those sections.
441 To support multiple concurrent public keys per signing domain, the
442 key namespace is subdivided using "selectors". For example,
443 selectors might indicate the names of office locations (e.g.,
444 "sanfrancisco", "coolumbeach", and "reykjavik"), the signing date
445 (e.g., "january2005", "february2005", etc.), or even the individual
450Allman, et al. Standards Track [Page 8]
452RFC 4871 DKIM Signatures May 2007
455 Selectors are needed to support some important use cases. For
458 o Domains that want to delegate signing capability for a specific
459 address for a given duration to a partner, such as an advertising
460 provider or other outsourced function.
462 o Domains that want to allow frequent travelers to send messages
463 locally without the need to connect with a particular MSA.
465 o "Affinity" domains (e.g., college alumni associations) that
466 provide forwarding of incoming mail, but that do not operate a
467 mail submission agent for outgoing mail.
469 Periods are allowed in selectors and are component separators. When
470 keys are retrieved from the DNS, periods in selectors define DNS
471 label boundaries in a manner similar to the conventional use in
472 domain names. Selector components might be used to combine dates
473 with locations, for example, "march2005.reykjavik". In a DNS
474 implementation, this can be used to allow delegation of a portion of
475 the selector namespace.
479 selector = sub-domain *( "." sub-domain )
481 The number of public keys and corresponding selectors for each domain
482 is determined by the domain owner. Many domain owners will be
483 satisfied with just one selector, whereas administratively
484 distributed organizations may choose to manage disparate selectors
485 and key pairs in different regions or on different email servers.
487 Beyond administrative convenience, selectors make it possible to
488 seamlessly replace public keys on a routine basis. If a domain
489 wishes to change from using a public key associated with selector
490 "january2005" to a public key associated with selector
491 "february2005", it merely makes sure that both public keys are
492 advertised in the public-key repository concurrently for the
493 transition period during which email may be in transit prior to
494 verification. At the start of the transition period, the outbound
495 email servers are configured to sign with the "february2005" private
496 key. At the end of the transition period, the "january2005" public
497 key is removed from the public-key repository.
499 INFORMATIVE NOTE: A key may also be revoked as described below.
500 The distinction between revoking and removing a key selector
501 record is subtle. When phasing out keys as described above, a
502 signing domain would probably simply remove the key record after
506Allman, et al. Standards Track [Page 9]
508RFC 4871 DKIM Signatures May 2007
511 the transition period. However, a signing domain could elect to
512 revoke the key (but maintain the key record) for a further period.
513 There is no defined semantic difference between a revoked key and
516 While some domains may wish to make selector values well known,
517 others will want to take care not to allocate selector names in a way
518 that allows harvesting of data by outside parties. For example, if
519 per-user keys are issued, the domain owner will need to make the
520 decision as to whether to associate this selector directly with the
521 user name, or make it some unassociated random value, such as a
522 fingerprint of the public key.
524 INFORMATIVE OPERATIONS NOTE: Reusing a selector with a new key
525 (for example, changing the key associated with a user's name)
526 makes it impossible to tell the difference between a message that
527 didn't verify because the key is no longer valid versus a message
528 that is actually forged. For this reason, signers are ill-advised
529 to reuse selectors for new keys. A better strategy is to assign
530 new keys to new selectors.
534 DKIM uses a simple "tag=value" syntax in several contexts, including
535 in messages and domain signature records.
537 Values are a series of strings containing either plain text, "base64"
538 text (as defined in [RFC2045], Section 6.8), "qp-section" (ibid,
539 Section 6.7), or "dkim-quoted-printable" (as defined in Section 2.6).
540 The name of the tag will determine the encoding of each value.
541 Unencoded semicolon (";") characters MUST NOT occur in the tag value,
542 since that separates tag-specs.
544 INFORMATIVE IMPLEMENTATION NOTE: Although the "plain text" defined
545 below (as "tag-value") only includes 7-bit characters, an
546 implementation that wished to anticipate future standards would be
547 advised not to preclude the use of UTF8-encoded text in tag=value
562Allman, et al. Standards Track [Page 10]
564RFC 4871 DKIM Signatures May 2007
567 Formally, the syntax rules are as follows:
569 tag-list = tag-spec 0*( ";" tag-spec ) [ ";" ]
570 tag-spec = [FWS] tag-name [FWS] "=" [FWS] tag-value [FWS]
571 tag-name = ALPHA 0*ALNUMPUNC
572 tag-value = [ tval 0*( 1*(WSP / FWS) tval ) ]
573 ; WSP and FWS prohibited at beginning and end
575 VALCHAR = %x21-3A / %x3C-7E
576 ; EXCLAMATION to TILDE except SEMICOLON
577 ALNUMPUNC = ALPHA / DIGIT / "_"
579 Note that WSP is allowed anywhere around tags. In particular, any
580 WSP after the "=" and any WSP before the terminating ";" is not part
581 of the value; however, WSP inside the value is significant.
583 Tags MUST be interpreted in a case-sensitive manner. Values MUST be
584 processed as case sensitive unless the specific tag description of
585 semantics specifies case insensitivity.
587 Tags with duplicate names MUST NOT occur within a single tag-list; if
588 a tag name does occur more than once, the entire tag-list is invalid.
590 Whitespace within a value MUST be retained unless explicitly excluded
591 by the specific tag description.
593 Tag=value pairs that represent the default value MAY be included to
596 Unrecognized tags MUST be ignored.
598 Tags that have an empty value are not the same as omitted tags. An
599 omitted tag is treated as having the default value; a tag with an
600 empty value explicitly designates the empty string as the value. For
601 example, "g=" does not mean "g=*", even though "g=*" is the default
6043.3. Signing and Verification Algorithms
606 DKIM supports multiple digital signature algorithms. Two algorithms
607 are defined by this specification at this time: rsa-sha1 and rsa-
608 sha256. The rsa-sha256 algorithm is the default if no algorithm is
609 specified. Verifiers MUST implement both rsa-sha1 and rsa-sha256.
610 Signers MUST implement and SHOULD sign using rsa-sha256.
618Allman, et al. Standards Track [Page 11]
620RFC 4871 DKIM Signatures May 2007
623 INFORMATIVE NOTE: Although sha256 is strongly encouraged, some
624 senders of low-security messages (such as routine newsletters) may
625 prefer to use sha1 because of reduced CPU requirements to compute
626 a sha1 hash. In general, sha256 should always be used whenever
6293.3.1. The rsa-sha1 Signing Algorithm
631 The rsa-sha1 Signing Algorithm computes a message hash as described
632 in Section 3.7 below using SHA-1 [FIPS.180-2.2002] as the hash-alg.
633 That hash is then signed by the signer using the RSA algorithm
634 (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the
635 signer's private key. The hash MUST NOT be truncated or converted
636 into any form other than the native binary form before being signed.
637 The signing algorithm SHOULD use a public exponent of 65537.
6393.3.2. The rsa-sha256 Signing Algorithm
641 The rsa-sha256 Signing Algorithm computes a message hash as described
642 in Section 3.7 below using SHA-256 [FIPS.180-2.2002] as the hash-alg.
643 That hash is then signed by the signer using the RSA algorithm
644 (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the
645 signer's private key. The hash MUST NOT be truncated or converted
646 into any form other than the native binary form before being signed.
650 Selecting appropriate key sizes is a trade-off between cost,
651 performance, and risk. Since short RSA keys more easily succumb to
652 off-line attacks, signers MUST use RSA keys of at least 1024 bits for
653 long-lived keys. Verifiers MUST be able to validate signatures with
654 keys ranging from 512 bits to 2048 bits, and they MAY be able to
655 validate signatures with larger keys. Verifier policies may use the
656 length of the signing key as one metric for determining whether a
657 signature is acceptable.
659 Factors that should influence the key size choice include the
662 o The practical constraint that large (e.g., 4096 bit) keys may not
663 fit within a 512-byte DNS UDP response packet
665 o The security constraint that keys smaller than 1024 bits are
666 subject to off-line attacks
668 o Larger keys impose higher CPU costs to verify and sign email
674Allman, et al. Standards Track [Page 12]
676RFC 4871 DKIM Signatures May 2007
679 o Keys can be replaced on a regular basis, thus their lifetime can
682 o The security goals of this specification are modest compared to
683 typical goals of other systems that employ digital signatures
685 See [RFC3766] for further discussion on selecting key sizes.
6873.3.4. Other Algorithms
689 Other algorithms MAY be defined in the future. Verifiers MUST ignore
690 any signatures using algorithms that they do not implement.
694 Empirical evidence demonstrates that some mail servers and relay
695 systems modify email in transit, potentially invalidating a
696 signature. There are two competing perspectives on such
697 modifications. For most signers, mild modification of email is
698 immaterial to the authentication status of the email. For such
699 signers, a canonicalization algorithm that survives modest in-transit
700 modification is preferred.
702 Other signers demand that any modification of the email, however
703 minor, result in a signature verification failure. These signers
704 prefer a canonicalization algorithm that does not tolerate in-transit
705 modification of the signed email.
707 Some signers may be willing to accept modifications to header fields
708 that are within the bounds of email standards such as [RFC2822], but
709 are unwilling to accept any modification to the body of messages.
711 To satisfy all requirements, two canonicalization algorithms are
712 defined for each of the header and the body: a "simple" algorithm
713 that tolerates almost no modification and a "relaxed" algorithm that
714 tolerates common modifications such as whitespace replacement and
715 header field line rewrapping. A signer MAY specify either algorithm
716 for header or body when signing an email. If no canonicalization
717 algorithm is specified by the signer, the "simple" algorithm defaults
718 for both header and body. Verifiers MUST implement both
719 canonicalization algorithms. Note that the header and body may use
720 different canonicalization algorithms. Further canonicalization
721 algorithms MAY be defined in the future; verifiers MUST ignore any
722 signatures that use unrecognized canonicalization algorithms.
724 Canonicalization simply prepares the email for presentation to the
725 signing or verification algorithm. It MUST NOT change the
730Allman, et al. Standards Track [Page 13]
732RFC 4871 DKIM Signatures May 2007
735 transmitted data in any way. Canonicalization of header fields and
736 body are described below.
738 NOTE: This section assumes that the message is already in "network
739 normal" format (text is ASCII encoded, lines are separated with CRLF
740 characters, etc.). See also Section 5.3 for information about
741 normalizing the message.
7433.4.1. The "simple" Header Canonicalization Algorithm
745 The "simple" header canonicalization algorithm does not change header
746 fields in any way. Header fields MUST be presented to the signing or
747 verification algorithm exactly as they are in the message being
748 signed or verified. In particular, header field names MUST NOT be
749 case folded and whitespace MUST NOT be changed.
7513.4.2. The "relaxed" Header Canonicalization Algorithm
753 The "relaxed" header canonicalization algorithm MUST apply the
754 following steps in order:
756 o Convert all header field names (not the header field values) to
757 lowercase. For example, convert "SUBJect: AbC" to "subject: AbC".
759 o Unfold all header field continuation lines as described in
760 [RFC2822]; in particular, lines with terminators embedded in
761 continued header field values (that is, CRLF sequences followed by
762 WSP) MUST be interpreted without the CRLF. Implementations MUST
763 NOT remove the CRLF at the end of the header field value.
765 o Convert all sequences of one or more WSP characters to a single SP
766 character. WSP characters here include those before and after a
767 line folding boundary.
769 o Delete all WSP characters at the end of each unfolded header field
772 o Delete any WSP characters remaining before and after the colon
773 separating the header field name from the header field value. The
774 colon separator MUST be retained.
7763.4.3. The "simple" Body Canonicalization Algorithm
778 The "simple" body canonicalization algorithm ignores all empty lines
779 at the end of the message body. An empty line is a line of zero
780 length after removal of the line terminator. If there is no body or
781 no trailing CRLF on the message body, a CRLF is added. It makes no
786Allman, et al. Standards Track [Page 14]
788RFC 4871 DKIM Signatures May 2007
791 other changes to the message body. In more formal terms, the
792 "simple" body canonicalization algorithm converts "0*CRLF" at the end
793 of the body to a single "CRLF".
795 Note that a completely empty or missing body is canonicalized as a
796 single "CRLF"; that is, the canonicalized length will be 2 octets.
7983.4.4. The "relaxed" Body Canonicalization Algorithm
800 The "relaxed" body canonicalization algorithm:
802 o Ignores all whitespace at the end of lines. Implementations MUST
803 NOT remove the CRLF at the end of the line.
805 o Reduces all sequences of WSP within a line to a single SP
808 o Ignores all empty lines at the end of the message body. "Empty
809 line" is defined in Section 3.4.3.
811 INFORMATIVE NOTE: It should be noted that the relaxed body
812 canonicalization algorithm may enable certain types of extremely
813 crude "ASCII Art" attacks where a message may be conveyed by
814 adjusting the spacing between words. If this is a concern, the
815 "simple" body canonicalization algorithm should be used instead.
8173.4.5. Body Length Limits
819 A body length count MAY be specified to limit the signature
820 calculation to an initial prefix of the body text, measured in
821 octets. If the body length count is not specified, the entire
822 message body is signed.
824 INFORMATIVE RATIONALE: This capability is provided because it is
825 very common for mailing lists to add trailers to messages (e.g.,
826 instructions how to get off the list). Until those messages are
827 also signed, the body length count is a useful tool for the
828 verifier since it may as a matter of policy accept messages having
829 valid signatures with extraneous data.
831 INFORMATIVE IMPLEMENTATION NOTE: Using body length limits enables
832 an attack in which an attacker modifies a message to include
833 content that solely benefits the attacker. It is possible for the
834 appended content to completely replace the original content in the
835 end recipient's eyes and to defeat duplicate message detection
836 algorithms. To avoid this attack, signers should be wary of using
842Allman, et al. Standards Track [Page 15]
844RFC 4871 DKIM Signatures May 2007
847 this tag, and verifiers might wish to ignore the tag or remove
848 text that appears after the specified content length, perhaps
849 based on other criteria.
851 The body length count allows the signer of a message to permit data
852 to be appended to the end of the body of a signed message. The body
853 length count MUST be calculated following the canonicalization
854 algorithm; for example, any whitespace ignored by a canonicalization
855 algorithm is not included as part of the body length count. Signers
856 of MIME messages that include a body length count SHOULD be sure that
857 the length extends to the closing MIME boundary string.
859 INFORMATIVE IMPLEMENTATION NOTE: A signer wishing to ensure that
860 the only acceptable modifications are to add to the MIME postlude
861 would use a body length count encompassing the entire final MIME
862 boundary string, including the final "--CRLF". A signer wishing
863 to allow additional MIME parts but not modification of existing
864 parts would use a body length count extending through the final
865 MIME boundary string, omitting the final "--CRLF". Note that this
866 only works for some MIME types, e.g., multipart/mixed but not
869 A body length count of zero means that the body is completely
872 Signers wishing to ensure that no modification of any sort can occur
873 should specify the "simple" canonicalization algorithm for both
874 header and body and omit the body length count.
8763.4.6. Canonicalization Examples (INFORMATIVE)
878 In the following examples, actual whitespace is used only for
879 clarity. The actual input and output text is designated using
880 bracketed descriptors: "<SP>" for a space character, "<HTAB>" for a
881 tab character, and "<CRLF>" for a carriage-return/line-feed sequence.
882 For example, "X <SP> Y" and "X<SP>Y" represent the same three
885 Example 1: A message reading:
888 B <SP> : <SP> Y <HTAB><CRLF>
889 <HTAB> Z <SP><SP><CRLF>
892 D <SP><HTAB><SP> E <CRLF>
898Allman, et al. Standards Track [Page 16]
900RFC 4871 DKIM Signatures May 2007
903 when canonicalized using relaxed canonicalization for both header and
904 body results in a header reading:
914 Example 2: The same message canonicalized using simple
915 canonicalization for both header and body results in a header
919 B <SP> : <SP> Y <HTAB><CRLF>
920 <HTAB> Z <SP><SP><CRLF>
925 D <SP><HTAB><SP> E <CRLF>
927 Example 3: When processed using relaxed header canonicalization and
928 simple body canonicalization, the canonicalized version has a header
937 D <SP><HTAB><SP> E <CRLF>
9393.5. The DKIM-Signature Header Field
941 The signature of the email is stored in the DKIM-Signature header
942 field. This header field contains all of the signature and key-
943 fetching data. The DKIM-Signature value is a tag-list as described
946 The DKIM-Signature header field SHOULD be treated as though it were a
947 trace header field as defined in Section 3.6 of [RFC2822], and hence
948 SHOULD NOT be reordered and SHOULD be prepended to the message.
954Allman, et al. Standards Track [Page 17]
956RFC 4871 DKIM Signatures May 2007
959 The DKIM-Signature header field being created or verified is always
960 included in the signature calculation, after the rest of the header
961 fields being signed; however, when calculating or verifying the
962 signature, the value of the "b=" tag (signature value) of that DKIM-
963 Signature header field MUST be treated as though it were an empty
964 string. Unknown tags in the DKIM-Signature header field MUST be
965 included in the signature calculation but MUST be otherwise ignored
966 by verifiers. Other DKIM-Signature header fields that are included
967 in the signature should be treated as normal header fields; in
968 particular, the "b=" tag is not treated specially.
970 The encodings for each field type are listed below. Tags described
971 as qp-section are encoded as described in Section 6.7 of MIME Part
972 One [RFC2045], with the additional conversion of semicolon characters
973 to "=3B"; intuitively, this is one line of quoted-printable encoded
974 text. The dkim-quoted-printable syntax is defined in Section 2.6.
976 Tags on the DKIM-Signature header field along with their type and
977 requirement status are shown below. Unrecognized tags MUST be
980 v= Version (MUST be included). This tag defines the version of this
981 specification that applies to the signature record. It MUST have
982 the value "1". Note that verifiers must do a string comparison
983 on this value; for example, "1" is not the same as "1.0".
987 sig-v-tag = %x76 [FWS] "=" [FWS] "1"
989 INFORMATIVE NOTE: DKIM-Signature version numbers are expected
990 to increase arithmetically as new versions of this
991 specification are released.
993 a= The algorithm used to generate the signature (plain-text;
994 REQUIRED). Verifiers MUST support "rsa-sha1" and "rsa-sha256";
995 signers SHOULD sign using "rsa-sha256". See Section 3.3 for a
996 description of algorithms.
1000 sig-a-tag = %x61 [FWS] "=" [FWS] sig-a-tag-alg
1001 sig-a-tag-alg = sig-a-tag-k "-" sig-a-tag-h
1002 sig-a-tag-k = "rsa" / x-sig-a-tag-k
1003 sig-a-tag-h = "sha1" / "sha256" / x-sig-a-tag-h
1004 x-sig-a-tag-k = ALPHA *(ALPHA / DIGIT) ; for later extension
1005 x-sig-a-tag-h = ALPHA *(ALPHA / DIGIT) ; for later extension
1010Allman, et al. Standards Track [Page 18]
1012RFC 4871 DKIM Signatures May 2007
1015 b= The signature data (base64; REQUIRED). Whitespace is ignored in
1016 this value and MUST be ignored when reassembling the original
1017 signature. In particular, the signing process can safely insert
1018 FWS in this value in arbitrary places to conform to line-length
1019 limits. See Signer Actions (Section 5) for how the signature is
1024 sig-b-tag = %x62 [FWS] "=" [FWS] sig-b-tag-data
1025 sig-b-tag-data = base64string
1027 bh= The hash of the canonicalized body part of the message as limited
1028 by the "l=" tag (base64; REQUIRED). Whitespace is ignored in
1029 this value and MUST be ignored when reassembling the original
1030 signature. In particular, the signing process can safely insert
1031 FWS in this value in arbitrary places to conform to line-length
1032 limits. See Section 3.7 for how the body hash is computed.
1036 sig-bh-tag = %x62 %x68 [FWS] "=" [FWS] sig-bh-tag-data
1037 sig-bh-tag-data = base64string
1039 c= Message canonicalization (plain-text; OPTIONAL, default is
1040 "simple/simple"). This tag informs the verifier of the type of
1041 canonicalization used to prepare the message for signing. It
1042 consists of two names separated by a "slash" (%d47) character,
1043 corresponding to the header and body canonicalization algorithms
1044 respectively. These algorithms are described in Section 3.4. If
1045 only one algorithm is named, that algorithm is used for the
1046 header and "simple" is used for the body. For example,
1047 "c=relaxed" is treated the same as "c=relaxed/simple".
1051 sig-c-tag = %x63 [FWS] "=" [FWS] sig-c-tag-alg
1053 sig-c-tag-alg = "simple" / "relaxed" / x-sig-c-tag-alg
1054 x-sig-c-tag-alg = hyphenated-word ; for later extension
1056 d= The domain of the signing entity (plain-text; REQUIRED). This is
1057 the domain that will be queried for the public key. This domain
1058 MUST be the same as or a parent domain of the "i=" tag (the
1059 signing identity, as described below), or it MUST meet the
1060 requirements for parent domain signing described in Section 3.8.
1061 When presented with a signature that does not meet these
1062 requirement, verifiers MUST consider the signature invalid.
1066Allman, et al. Standards Track [Page 19]
1068RFC 4871 DKIM Signatures May 2007
1071 Internationalized domain names MUST be encoded as described in
1076 sig-d-tag = %x64 [FWS] "=" [FWS] domain-name
1077 domain-name = sub-domain 1*("." sub-domain)
1078 ; from RFC 2821 Domain, but excluding address-literal
1080 h= Signed header fields (plain-text, but see description; REQUIRED).
1081 A colon-separated list of header field names that identify the
1082 header fields presented to the signing algorithm. The field MUST
1083 contain the complete list of header fields in the order presented
1084 to the signing algorithm. The field MAY contain names of header
1085 fields that do not exist when signed; nonexistent header fields
1086 do not contribute to the signature computation (that is, they are
1087 treated as the null input, including the header field name, the
1088 separating colon, the header field value, and any CRLF
1089 terminator). The field MUST NOT include the DKIM-Signature
1090 header field that is being created or verified, but may include
1091 others. Folding whitespace (FWS) MAY be included on either side
1092 of the colon separator. Header field names MUST be compared
1093 against actual header field names in a case-insensitive manner.
1094 This list MUST NOT be empty. See Section 5.4 for a discussion of
1095 choosing header fields to sign.
1099 sig-h-tag = %x68 [FWS] "=" [FWS] hdr-name
1100 0*( *FWS ":" *FWS hdr-name )
1101 hdr-name = field-name
1103 INFORMATIVE EXPLANATION: By "signing" header fields that do not
1104 actually exist, a signer can prevent insertion of those
1105 header fields before verification. However, since a signer
1106 cannot possibly know what header fields might be created in
1107 the future, and that some MUAs might present header fields
1108 that are embedded inside a message (e.g., as a message/rfc822
1109 content type), the security of this solution is not total.
1111 INFORMATIVE EXPLANATION: The exclusion of the header field name
1112 and colon as well as the header field value for non-existent
1113 header fields prevents an attacker from inserting an actual
1114 header field with a null value.
1122Allman, et al. Standards Track [Page 20]
1124RFC 4871 DKIM Signatures May 2007
1127 i= Identity of the user or agent (e.g., a mailing list manager) on
1128 behalf of which this message is signed (dkim-quoted-printable;
1129 OPTIONAL, default is an empty Local-part followed by an "@"
1130 followed by the domain from the "d=" tag). The syntax is a
1131 standard email address where the Local-part MAY be omitted. The
1132 domain part of the address MUST be the same as or a subdomain of
1133 the value of the "d=" tag.
1135 Internationalized domain names MUST be converted using the steps
1136 listed in Section 4 of [RFC3490] using the "ToASCII" function.
1140 sig-i-tag = %x69 [FWS] "=" [FWS] [ Local-part ] "@" domain-name
1142 INFORMATIVE NOTE: The Local-part of the "i=" tag is optional
1143 because in some cases a signer may not be able to establish a
1144 verified individual identity. In such cases, the signer may
1145 wish to assert that although it is willing to go as far as
1146 signing for the domain, it is unable or unwilling to commit
1147 to an individual user name within their domain. It can do so
1148 by including the domain part but not the Local-part of the
1151 INFORMATIVE DISCUSSION: This document does not require the value
1152 of the "i=" tag to match the identity in any message header
1153 fields. This is considered to be a verifier policy issue.
1154 Constraints between the value of the "i=" tag and other
1155 identities in other header fields seek to apply basic
1156 authentication into the semantics of trust associated with a
1157 role such as content author. Trust is a broad and complex
1158 topic and trust mechanisms are subject to highly creative
1159 attacks. The real-world efficacy of any but the most basic
1160 bindings between the "i=" value and other identities is not
1161 well established, nor is its vulnerability to subversion by
1162 an attacker. Hence reliance on the use of these options
1163 should be strictly limited. In particular, it is not at all
1164 clear to what extent a typical end-user recipient can rely on
1165 any assurances that might be made by successful use of the
1168 l= Body length count (plain-text unsigned decimal integer; OPTIONAL,
1169 default is entire body). This tag informs the verifier of the
1170 number of octets in the body of the email after canonicalization
1171 included in the cryptographic hash, starting from 0 immediately
1172 following the CRLF preceding the body. This value MUST NOT be
1173 larger than the actual number of octets in the canonicalized
1178Allman, et al. Standards Track [Page 21]
1180RFC 4871 DKIM Signatures May 2007
1183 INFORMATIVE IMPLEMENTATION WARNING: Use of the "l=" tag might
1184 allow display of fraudulent content without appropriate
1185 warning to end users. The "l=" tag is intended for
1186 increasing signature robustness when sending to mailing lists
1187 that both modify their content and do not sign their
1188 messages. However, using the "l=" tag enables attacks in
1189 which an intermediary with malicious intent modifies a
1190 message to include content that solely benefits the attacker.
1191 It is possible for the appended content to completely replace
1192 the original content in the end recipient's eyes and to
1193 defeat duplicate message detection algorithms. Examples are
1194 described in Security Considerations (Section 8). To avoid
1195 this attack, signers should be extremely wary of using this
1196 tag, and verifiers might wish to ignore the tag or remove
1197 text that appears after the specified content length.
1199 INFORMATIVE NOTE: The value of the "l=" tag is constrained to 76
1200 decimal digits. This constraint is not intended to predict
1201 the size of future messages or to require implementations to
1202 use an integer representation large enough to represent the
1203 maximum possible value, but is intended to remind the
1204 implementer to check the length of this and all other tags
1205 during verification and to test for integer overflow when
1206 decoding the value. Implementers may need to limit the
1207 actual value expressed to a value smaller than 10^76, e.g.,
1208 to allow a message to fit within the available storage space.
1212 sig-l-tag = %x6c [FWS] "=" [FWS] 1*76DIGIT
1214 q= A colon-separated list of query methods used to retrieve the
1215 public key (plain-text; OPTIONAL, default is "dns/txt"). Each
1216 query method is of the form "type[/options]", where the syntax
1217 and semantics of the options depend on the type and specified
1218 options. If there are multiple query mechanisms listed, the
1219 choice of query mechanism MUST NOT change the interpretation of
1220 the signature. Implementations MUST use the recognized query
1221 mechanisms in the order presented.
1223 Currently, the only valid value is "dns/txt", which defines the DNS
1224 TXT record lookup algorithm described elsewhere in this document.
1225 The only option defined for the "dns" query type is "txt", which
1226 MUST be included. Verifiers and signers MUST support "dns/txt".
1234Allman, et al. Standards Track [Page 22]
1236RFC 4871 DKIM Signatures May 2007
1241 sig-q-tag = %x71 [FWS] "=" [FWS] sig-q-tag-method
1242 *([FWS] ":" [FWS] sig-q-tag-method)
1243 sig-q-tag-method = "dns/txt" / x-sig-q-tag-type
1244 ["/" x-sig-q-tag-args]
1245 x-sig-q-tag-type = hyphenated-word ; for future extension
1246 x-sig-q-tag-args = qp-hdr-value
1248 s= The selector subdividing the namespace for the "d=" (domain) tag
1249 (plain-text; REQUIRED).
1253 sig-s-tag = %x73 [FWS] "=" [FWS] selector
1255 t= Signature Timestamp (plain-text unsigned decimal integer;
1256 RECOMMENDED, default is an unknown creation time). The time that
1257 this signature was created. The format is the number of seconds
1258 since 00:00:00 on January 1, 1970 in the UTC time zone. The
1259 value is expressed as an unsigned integer in decimal ASCII. This
1260 value is not constrained to fit into a 31- or 32-bit integer.
1261 Implementations SHOULD be prepared to handle values up to at
1262 least 10^12 (until approximately AD 200,000; this fits into 40
1263 bits). To avoid denial-of-service attacks, implementations MAY
1264 consider any value longer than 12 digits to be infinite. Leap
1265 seconds are not counted. Implementations MAY ignore signatures
1266 that have a timestamp in the future.
1270 sig-t-tag = %x74 [FWS] "=" [FWS] 1*12DIGIT
1272 x= Signature Expiration (plain-text unsigned decimal integer;
1273 RECOMMENDED, default is no expiration). The format is the same
1274 as in the "t=" tag, represented as an absolute date, not as a
1275 time delta from the signing timestamp. The value is expressed as
1276 an unsigned integer in decimal ASCII, with the same constraints
1277 on the value in the "t=" tag. Signatures MAY be considered
1278 invalid if the verification time at the verifier is past the
1279 expiration date. The verification time should be the time that
1280 the message was first received at the administrative domain of
1281 the verifier if that time is reliably available; otherwise the
1282 current time should be used. The value of the "x=" tag MUST be
1283 greater than the value of the "t=" tag if both are present.
1290Allman, et al. Standards Track [Page 23]
1292RFC 4871 DKIM Signatures May 2007
1295 INFORMATIVE NOTE: The "x=" tag is not intended as an anti-replay
1300 sig-x-tag = %x78 [FWS] "=" [FWS] 1*12DIGIT
1302 z= Copied header fields (dkim-quoted-printable, but see description;
1303 OPTIONAL, default is null). A vertical-bar-separated list of
1304 selected header fields present when the message was signed,
1305 including both the field name and value. It is not required to
1306 include all header fields present at the time of signing. This
1307 field need not contain the same header fields listed in the "h="
1308 tag. The header field text itself must encode the vertical bar
1309 ("|", %x7C) character (i.e., vertical bars in the "z=" text are
1310 metacharacters, and any actual vertical bar characters in a
1311 copied header field must be encoded). Note that all whitespace
1312 must be encoded, including whitespace between the colon and the
1313 header field value. After encoding, FWS MAY be added at
1314 arbitrary locations in order to avoid excessively long lines;
1315 such whitespace is NOT part of the value of the header field, and
1316 MUST be removed before decoding.
1318 The header fields referenced by the "h=" tag refer to the fields in
1319 the RFC 2822 header of the message, not to any copied fields in
1320 the "z=" tag. Copied header field values are for diagnostic use.
1322 Header fields with characters requiring conversion (perhaps from
1323 legacy MTAs that are not [RFC2822] compliant) SHOULD be converted
1324 as described in MIME Part Three [RFC2047].
1327 sig-z-tag = %x7A [FWS] "=" [FWS] sig-z-tag-copy
1328 *( [FWS] "|" sig-z-tag-copy )
1329 sig-z-tag-copy = hdr-name ":" qp-hdr-value
1330 qp-hdr-value = dkim-quoted-printable ; with "|" encoded
1332 INFORMATIVE EXAMPLE of a signature header field spread across
1333 multiple continuation lines:
1346Allman, et al. Standards Track [Page 24]
1348RFC 4871 DKIM Signatures May 2007
1351 DKIM-Signature: a=rsa-sha256; d=example.net; s=brisbane;
1352 c=simple; q=dns/txt; i=@eng.example.net;
1353 t=1117574938; x=1118006938;
1354 h=from:to:subject:date;
1355 z=From:foo@eng.example.net|To:joe@example.com|
1356 Subject:demo=20run|Date:July=205,=202005=203:44:08=20PM=20-0700;
1357 bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=;
1358 b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ
13613.6. Key Management and Representation
1363 Signature applications require some level of assurance that the
1364 verification public key is associated with the claimed signer. Many
1365 applications achieve this by using public key certificates issued by
1366 a trusted third party. However, DKIM can achieve a sufficient level
1367 of security, with significantly enhanced scalability, by simply
1368 having the verifier query the purported signer's DNS entry (or some
1369 security-equivalent) in order to retrieve the public key.
1371 DKIM keys can potentially be stored in multiple types of key servers
1372 and in multiple formats. The storage and format of keys are
1373 irrelevant to the remainder of the DKIM algorithm.
1375 Parameters to the key lookup algorithm are the type of the lookup
1376 (the "q=" tag), the domain of the signer (the "d=" tag of the DKIM-
1377 Signature header field), and the selector (the "s=" tag).
1379 public_key = dkim_find_key(q_val, d_val, s_val)
1381 This document defines a single binding, using DNS TXT records to
1382 distribute the keys. Other bindings may be defined in the future.
13843.6.1. Textual Representation
1386 It is expected that many key servers will choose to present the keys
1387 in an otherwise unstructured text format (for example, an XML form
1388 would not be considered to be unstructured text for this purpose).
1389 The following definition MUST be used for any DKIM key represented in
1390 an otherwise unstructured textual form.
1392 The overall syntax is a tag-list as described in Section 3.2. The
1393 current valid tags are described below. Other tags MAY be present
1394 and MUST be ignored by any implementation that does not understand
1402Allman, et al. Standards Track [Page 25]
1404RFC 4871 DKIM Signatures May 2007
1407 v= Version of the DKIM key record (plain-text; RECOMMENDED, default
1408 is "DKIM1"). If specified, this tag MUST be set to "DKIM1"
1409 (without the quotes). This tag MUST be the first tag in the
1410 record. Records beginning with a "v=" tag with any other value
1411 MUST be discarded. Note that verifiers must do a string
1412 comparison on this value; for example, "DKIM1" is not the same as
1417 key-v-tag = %x76 [FWS] "=" [FWS] "DKIM1"
1419 g= Granularity of the key (plain-text; OPTIONAL, default is "*").
1420 This value MUST match the Local-part of the "i=" tag of the DKIM-
1421 Signature header field (or its default value of the empty string
1422 if "i=" is not specified), with a single, optional "*" character
1423 matching a sequence of zero or more arbitrary characters
1424 ("wildcarding"). An email with a signing address that does not
1425 match the value of this tag constitutes a failed verification.
1426 The intent of this tag is to constrain which signing address can
1427 legitimately use this selector, for example, when delegating a
1428 key to a third party that should only be used for special
1429 purposes. Wildcarding allows matching for addresses such as
1430 "user+*" or "*-offer". An empty "g=" value never matches any
1435 key-g-tag = %x67 [FWS] "=" [FWS] key-g-tag-lpart
1436 key-g-tag-lpart = [dot-atom-text] ["*" [dot-atom-text] ]
1438 h= Acceptable hash algorithms (plain-text; OPTIONAL, defaults to
1439 allowing all algorithms). A colon-separated list of hash
1440 algorithms that might be used. Signers and Verifiers MUST
1441 support the "sha256" hash algorithm. Verifiers MUST also support
1442 the "sha1" hash algorithm.
1446 key-h-tag = %x68 [FWS] "=" [FWS] key-h-tag-alg
1447 0*( [FWS] ":" [FWS] key-h-tag-alg )
1448 key-h-tag-alg = "sha1" / "sha256" / x-key-h-tag-alg
1449 x-key-h-tag-alg = hyphenated-word ; for future extension
1458Allman, et al. Standards Track [Page 26]
1460RFC 4871 DKIM Signatures May 2007
1463 k= Key type (plain-text; OPTIONAL, default is "rsa"). Signers and
1464 verifiers MUST support the "rsa" key type. The "rsa" key type
1465 indicates that an ASN.1 DER-encoded [ITU.X660.1997] RSAPublicKey
1466 [RFC3447] (see Sections 3.1 and A.1.1) is being used in the "p="
1467 tag. (Note: the "p=" tag further encodes the value using the
1472 key-k-tag = %x76 [FWS] "=" [FWS] key-k-tag-type
1473 key-k-tag-type = "rsa" / x-key-k-tag-type
1474 x-key-k-tag-type = hyphenated-word ; for future extension
1476 n= Notes that might be of interest to a human (qp-section; OPTIONAL,
1477 default is empty). No interpretation is made by any program.
1478 This tag should be used sparingly in any key server mechanism
1479 that has space limitations (notably DNS). This is intended for
1480 use by administrators, not end users.
1484 key-n-tag = %x6e [FWS] "=" [FWS] qp-section
1486 p= Public-key data (base64; REQUIRED). An empty value means that
1487 this public key has been revoked. The syntax and semantics of
1488 this tag value before being encoded in base64 are defined by the
1491 INFORMATIVE RATIONALE: If a private key has been compromised
1492 or otherwise disabled (e.g., an outsourcing contract has been
1493 terminated), a signer might want to explicitly state that it
1494 knows about the selector, but all messages using that
1495 selector should fail verification. Verifiers should ignore
1496 any DKIM-Signature header fields with a selector referencing
1501 key-p-tag = %x70 [FWS] "=" [ [FWS] base64string ]
1503 INFORMATIVE NOTE: A base64string is permitted to include white
1504 space (FWS) at arbitrary places; however, any CRLFs must be
1505 followed by at least one WSP character. Implementors and
1506 administrators are cautioned to ensure that selector TXT
1507 records conform to this specification.
1514Allman, et al. Standards Track [Page 27]
1516RFC 4871 DKIM Signatures May 2007
1519 s= Service Type (plain-text; OPTIONAL; default is "*"). A colon-
1520 separated list of service types to which this record applies.
1521 Verifiers for a given service type MUST ignore this record if the
1522 appropriate type is not listed. Currently defined service types
1525 * matches all service types
1527 email electronic mail (not necessarily limited to SMTP)
1529 This tag is intended to constrain the use of keys for other
1530 purposes, should use of DKIM be defined by other services in the
1535 key-s-tag = %x73 [FWS] "=" [FWS] key-s-tag-type
1536 0*( [FWS] ":" [FWS] key-s-tag-type )
1537 key-s-tag-type = "email" / "*" / x-key-s-tag-type
1538 x-key-s-tag-type = hyphenated-word ; for future extension
1540 t= Flags, represented as a colon-separated list of names (plain-
1541 text; OPTIONAL, default is no flags set). The defined flags are
1544 y This domain is testing DKIM. Verifiers MUST NOT treat
1545 messages from signers in testing mode differently from
1546 unsigned email, even should the signature fail to verify.
1547 Verifiers MAY wish to track testing mode results to assist
1550 s Any DKIM-Signature header fields using the "i=" tag MUST have
1551 the same domain value on the right-hand side of the "@" in
1552 the "i=" tag and the value of the "d=" tag. That is, the
1553 "i=" domain MUST NOT be a subdomain of "d=". Use of this
1554 flag is RECOMMENDED unless subdomaining is required.
1558 key-t-tag = %x74 [FWS] "=" [FWS] key-t-tag-flag
1559 0*( [FWS] ":" [FWS] key-t-tag-flag )
1560 key-t-tag-flag = "y" / "s" / x-key-t-tag-flag
1561 x-key-t-tag-flag = hyphenated-word ; for future extension
1563 Unrecognized flags MUST be ignored.
1570Allman, et al. Standards Track [Page 28]
1572RFC 4871 DKIM Signatures May 2007
1577 A binding using DNS TXT records as a key service is hereby defined.
1578 All implementations MUST support this binding.
1582 All DKIM keys are stored in a subdomain named "_domainkey". Given a
1583 DKIM-Signature field with a "d=" tag of "example.com" and an "s=" tag
1584 of "foo.bar", the DNS query will be for
1585 "foo.bar._domainkey.example.com".
1587 INFORMATIVE OPERATIONAL NOTE: Wildcard DNS records (e.g.,
1588 *.bar._domainkey.example.com) do not make sense in this context
1589 and should not be used. Note also that wildcards within domains
1590 (e.g., s._domainkey.*.example.com) are not supported by the DNS.
15923.6.2.2. Resource Record Types for Key Storage
1594 The DNS Resource Record type used is specified by an option to the
1595 query-type ("q=") tag. The only option defined in this base
1596 specification is "txt", indicating the use of a TXT Resource Record
1597 (RR). A later extension of this standard may define another RR type.
1599 Strings in a TXT RR MUST be concatenated together before use with no
1600 intervening whitespace. TXT RRs MUST be unique for a particular
1601 selector name; that is, if there are multiple records in an RRset,
1602 the results are undefined.
1604 TXT RRs are encoded as described in Section 3.6.1.
16063.7. Computing the Message Hashes
1608 Both signing and verifying message signatures start with a step of
1609 computing two cryptographic hashes over the message. Signers will
1610 choose the parameters of the signature as described in Signer Actions
1611 (Section 5); verifiers will use the parameters specified in the DKIM-
1612 Signature header field being verified. In the following discussion,
1613 the names of the tags in the DKIM-Signature header field that either
1614 exists (when verifying) or will be created (when signing) are used.
1615 Note that canonicalization (Section 3.4) is only used to prepare the
1616 email for signing or verifying; it does not affect the transmitted
1619 The signer/verifier MUST compute two hashes, one over the body of the
1620 message and one over the selected header fields of the message.
1626Allman, et al. Standards Track [Page 29]
1628RFC 4871 DKIM Signatures May 2007
1631 Signers MUST compute them in the order shown. Verifiers MAY compute
1632 them in any order convenient to the verifier, provided that the
1633 result is semantically identical to the semantics that would be the
1634 case had they been computed in this order.
1636 In hash step 1, the signer/verifier MUST hash the message body,
1637 canonicalized using the body canonicalization algorithm specified in
1638 the "c=" tag and then truncated to the length specified in the "l="
1639 tag. That hash value is then converted to base64 form and inserted
1640 into (signers) or compared to (verifiers) the "bh=" tag of the DKIM-
1641 Signature header field.
1643 In hash step 2, the signer/verifier MUST pass the following to the
1644 hash algorithm in the indicated order.
1646 1. The header fields specified by the "h=" tag, in the order
1647 specified in that tag, and canonicalized using the header
1648 canonicalization algorithm specified in the "c=" tag. Each
1649 header field MUST be terminated with a single CRLF.
1651 2. The DKIM-Signature header field that exists (verifying) or will
1652 be inserted (signing) in the message, with the value of the "b="
1653 tag deleted (i.e., treated as the empty string), canonicalized
1654 using the header canonicalization algorithm specified in the "c="
1655 tag, and without a trailing CRLF.
1657 All tags and their values in the DKIM-Signature header field are
1658 included in the cryptographic hash with the sole exception of the
1659 value portion of the "b=" (signature) tag, which MUST be treated as
1660 the null string. All tags MUST be included even if they might not be
1661 understood by the verifier. The header field MUST be presented to
1662 the hash algorithm after the body of the message rather than with the
1663 rest of the header fields and MUST be canonicalized as specified in
1664 the "c=" (canonicalization) tag. The DKIM-Signature header field
1665 MUST NOT be included in its own h= tag, although other DKIM-Signature
1666 header fields MAY be signed (see Section 4).
1668 When calculating the hash on messages that will be transmitted using
1669 base64 or quoted-printable encoding, signers MUST compute the hash
1670 after the encoding. Likewise, the verifier MUST incorporate the
1671 values into the hash before decoding the base64 or quoted-printable
1672 text. However, the hash MUST be computed before transport level
1673 encodings such as SMTP "dot-stuffing" (the modification of lines
1674 beginning with a "." to avoid confusion with the SMTP end-of-message
1675 marker, as specified in [RFC2821]).
1677 With the exception of the canonicalization procedure described in
1678 Section 3.4, the DKIM signing process treats the body of messages as
1682Allman, et al. Standards Track [Page 30]
1684RFC 4871 DKIM Signatures May 2007
1687 simply a string of octets. DKIM messages MAY be either in plain-text
1688 or in MIME format; no special treatment is afforded to MIME content.
1689 Message attachments in MIME format MUST be included in the content
1692 More formally, the algorithm for the signature is as follows:
1693 body-hash = hash-alg(canon_body)
1694 header-hash = hash-alg(canon_header || DKIM-SIG)
1695 signature = sig-alg(header-hash, key)
1697 where "sig-alg" is the signature algorithm specified by the "a=" tag,
1698 "hash-alg" is the hash algorithm specified by the "a=" tag,
1699 "canon_header" and "canon_body" are the canonicalized message header
1700 and body (respectively) as defined in Section 3.4 (excluding the
1701 DKIM-Signature header field), and "DKIM-SIG" is the canonicalized
1702 DKIM-Signature header field sans the signature value itself, but with
1703 "body-hash" included as the "bh=" tag.
1705 INFORMATIVE IMPLEMENTERS' NOTE: Many digital signature APIs
1706 provide both hashing and application of the RSA private key using
1707 a single "sign()" primitive. When using such an API, the last two
1708 steps in the algorithm would probably be combined into a single
1709 call that would perform both the "hash-alg" and the "sig-alg".
17113.8. Signing by Parent Domains
1713 In some circumstances, it is desirable for a domain to apply a
1714 signature on behalf of any of its subdomains without the need to
1715 maintain separate selectors (key records) in each subdomain. By
1716 default, private keys corresponding to key records can be used to
1717 sign messages for any subdomain of the domain in which they reside;
1718 e.g., a key record for the domain example.com can be used to verify
1719 messages where the signing identity ("i=" tag of the signature) is
1720 sub.example.com, or even sub1.sub2.example.com. In order to limit
1721 the capability of such keys when this is not intended, the "s" flag
1722 may be set in the "t=" tag of the key record to constrain the
1723 validity of the record to exactly the domain of the signing identity.
1724 If the referenced key record contains the "s" flag as part of the
1725 "t=" tag, the domain of the signing identity ("i=" flag) MUST be the
1726 same as that of the d= domain. If this flag is absent, the domain of
1727 the signing identity MUST be the same as, or a subdomain of, the d=
1728 domain. Key records that are not intended for use with subdomains
1729 SHOULD specify the "s" flag in the "t=" tag.
1738Allman, et al. Standards Track [Page 31]
1740RFC 4871 DKIM Signatures May 2007
17434. Semantics of Multiple Signatures
17454.1. Example Scenarios
1747 There are many reasons why a message might have multiple signatures.
1748 For example, a given signer might sign multiple times, perhaps with
1749 different hashing or signing algorithms during a transition phase.
1751 INFORMATIVE EXAMPLE: Suppose SHA-256 is in the future found to be
1752 insufficiently strong, and DKIM usage transitions to SHA-1024. A
1753 signer might immediately sign using the newer algorithm, but
1754 continue to sign using the older algorithm for interoperability
1755 with verifiers that had not yet upgraded. The signer would do
1756 this by adding two DKIM-Signature header fields, one using each
1757 algorithm. Older verifiers that did not recognize SHA-1024 as an
1758 acceptable algorithm would skip that signature and use the older
1759 algorithm; newer verifiers could use either signature at their
1760 option, and all other things being equal might not even attempt to
1761 verify the other signature.
1763 Similarly, a signer might sign a message including all headers and no
1764 "l=" tag (to satisfy strict verifiers) and a second time with a
1765 limited set of headers and an "l=" tag (in anticipation of possible
1766 message modifications in route to other verifiers). Verifiers could
1767 then choose which signature they preferred.
1769 INFORMATIVE EXAMPLE: A verifier might receive a message with two
1770 signatures, one covering more of the message than the other. If
1771 the signature covering more of the message verified, then the
1772 verifier could make one set of policy decisions; if that signature
1773 failed but the signature covering less of the message verified,
1774 the verifier might make a different set of policy decisions.
1776 Of course, a message might also have multiple signatures because it
1777 passed through multiple signers. A common case is expected to be
1778 that of a signed message that passes through a mailing list that also
1779 signs all messages. Assuming both of those signatures verify, a
1780 recipient might choose to accept the message if either of those
1781 signatures were known to come from trusted sources.
1783 INFORMATIVE EXAMPLE: Recipients might choose to whitelist mailing
1784 lists to which they have subscribed and that have acceptable anti-
1785 abuse policies so as to accept messages sent to that list even
1786 from unknown authors. They might also subscribe to less trusted
1787 mailing lists (e.g., those without anti-abuse protection) and be
1788 willing to accept all messages from specific authors, but insist
1789 on doing additional abuse scanning for other messages.
1794Allman, et al. Standards Track [Page 32]
1796RFC 4871 DKIM Signatures May 2007
1799 Another related example of multiple signers might be forwarding
1800 services, such as those commonly associated with academic alumni
1803 INFORMATIVE EXAMPLE: A recipient might have an address at
1804 members.example.org, a site that has anti-abuse protection that is
1805 somewhat less effective than the recipient would prefer. Such a
1806 recipient might have specific authors whose messages would be
1807 trusted absolutely, but messages from unknown authors that had
1808 passed the forwarder's scrutiny would have only medium trust.
1812 A signer that is adding a signature to a message merely creates a new
1813 DKIM-Signature header, using the usual semantics of the h= option. A
1814 signer MAY sign previously existing DKIM-Signature header fields
1815 using the method described in Section 5.4 to sign trace header
1818 INFORMATIVE NOTE: Signers should be cognizant that signing DKIM-
1819 Signature header fields may result in signature failures with
1820 intermediaries that do not recognize that DKIM-Signature header
1821 fields are trace header fields and unwittingly reorder them, thus
1822 breaking such signatures. For this reason, signing existing DKIM-
1823 Signature header fields is unadvised, albeit legal.
1825 INFORMATIVE NOTE: If a header field with multiple instances is
1826 signed, those header fields are always signed from the bottom up.
1827 Thus, it is not possible to sign only specific DKIM-Signature
1828 header fields. For example, if the message being signed already
1829 contains three DKIM-Signature header fields A, B, and C, it is
1830 possible to sign all of them, B and C only, or C only, but not A
1831 only, B only, A and B only, or A and C only.
1833 A signer MAY add more than one DKIM-Signature header field using
1834 different parameters. For example, during a transition period a
1835 signer might want to produce signatures using two different hash
1838 Signers SHOULD NOT remove any DKIM-Signature header fields from
1839 messages they are signing, even if they know that the signatures
1842 When evaluating a message with multiple signatures, a verifier SHOULD
1843 evaluate signatures independently and on their own merits. For
1844 example, a verifier that by policy chooses not to accept signatures
1845 with deprecated cryptographic algorithms would consider such
1846 signatures invalid. Verifiers MAY process signatures in any order of
1850Allman, et al. Standards Track [Page 33]
1852RFC 4871 DKIM Signatures May 2007
1855 their choice; for example, some verifiers might choose to process
1856 signatures corresponding to the From field in the message header
1857 before other signatures. See Section 6.1 for more information about
1860 INFORMATIVE IMPLEMENTATION NOTE: Verifier attempts to correlate
1861 valid signatures with invalid signatures in an attempt to guess
1862 why a signature failed are ill-advised. In particular, there is
1863 no general way that a verifier can determine that an invalid
1864 signature was ever valid.
1866 Verifiers SHOULD ignore failed signatures as though they were not
1867 present in the message. Verifiers SHOULD continue to check
1868 signatures until a signature successfully verifies to the
1869 satisfaction of the verifier. To limit potential denial-of-service
1870 attacks, verifiers MAY limit the total number of signatures they will
1875 The following steps are performed in order by signers.
18775.1. Determine Whether the Email Should Be Signed and by Whom
1879 A signer can obviously only sign email for domains for which it has a
1880 private key and the necessary knowledge of the corresponding public
1881 key and selector information. However, there are a number of other
1882 reasons beyond the lack of a private key why a signer could choose
1883 not to sign an email.
1885 INFORMATIVE NOTE: Signing modules may be incorporated into any
1886 portion of the mail system as deemed appropriate, including an
1887 MUA, a SUBMISSION server, or an MTA. Wherever implemented,
1888 signers should beware of signing (and thereby asserting
1889 responsibility for) messages that may be problematic. In
1890 particular, within a trusted enclave the signing address might be
1891 derived from the header according to local policy; SUBMISSION
1892 servers might only sign messages from users that are properly
1893 authenticated and authorized.
1895 INFORMATIVE IMPLEMENTER ADVICE: SUBMISSION servers should not sign
1896 Received header fields if the outgoing gateway MTA obfuscates
1897 Received header fields, for example, to hide the details of
1900 If an email cannot be signed for some reason, it is a local policy
1901 decision as to what to do with that email.
1906Allman, et al. Standards Track [Page 34]
1908RFC 4871 DKIM Signatures May 2007
19115.2. Select a Private Key and Corresponding Selector Information
1913 This specification does not define the basis by which a signer should
1914 choose which private key and selector information to use. Currently,
1915 all selectors are equal as far as this specification is concerned, so
1916 the decision should largely be a matter of administrative
1917 convenience. Distribution and management of private keys is also
1918 outside the scope of this document.
1920 INFORMATIVE OPERATIONS ADVICE: A signer should not sign with a
1921 private key when the selector containing the corresponding public
1922 key is expected to be revoked or removed before the verifier has
1923 an opportunity to validate the signature. The signer should
1924 anticipate that verifiers may choose to defer validation, perhaps
1925 until the message is actually read by the final recipient. In
1926 particular, when rotating to a new key pair, signing should
1927 immediately commence with the new private key and the old public
1928 key should be retained for a reasonable validation interval before
1929 being removed from the key server.
19315.3. Normalize the Message to Prevent Transport Conversions
1933 Some messages, particularly those using 8-bit characters, are subject
1934 to modification during transit, notably conversion to 7-bit form.
1935 Such conversions will break DKIM signatures. In order to minimize
1936 the chances of such breakage, signers SHOULD convert the message to a
1937 suitable MIME content transfer encoding such as quoted-printable or
1938 base64 as described in MIME Part One [RFC2045] before signing. Such
1939 conversion is outside the scope of DKIM; the actual message SHOULD be
1940 converted to 7-bit MIME by an MUA or MSA prior to presentation to the
1943 If the message is submitted to the signer with any local encoding
1944 that will be modified before transmission, that modification to
1945 canonical [RFC2822] form MUST be done before signing. In particular,
1946 bare CR or LF characters (used by some systems as a local line
1947 separator convention) MUST be converted to the SMTP-standard CRLF
1948 sequence before the message is signed. Any conversion of this sort
1949 SHOULD be applied to the message actually sent to the recipient(s),
1950 not just to the version presented to the signing algorithm.
1952 More generally, the signer MUST sign the message as it is expected to
1953 be received by the verifier rather than in some local or internal
1962Allman, et al. Standards Track [Page 35]
1964RFC 4871 DKIM Signatures May 2007
19675.4. Determine the Header Fields to Sign
1969 The From header field MUST be signed (that is, included in the "h="
1970 tag of the resulting DKIM-Signature header field). Signers SHOULD
1971 NOT sign an existing header field likely to be legitimately modified
1972 or removed in transit. In particular, [RFC2821] explicitly permits
1973 modification or removal of the Return-Path header field in transit.
1974 Signers MAY include any other header fields present at the time of
1975 signing at the discretion of the signer.
1977 INFORMATIVE OPERATIONS NOTE: The choice of which header fields to
1978 sign is non-obvious. One strategy is to sign all existing, non-
1979 repeatable header fields. An alternative strategy is to sign only
1980 header fields that are likely to be displayed to or otherwise be
1981 likely to affect the processing of the message at the receiver. A
1982 third strategy is to sign only "well known" headers. Note that
1983 verifiers may treat unsigned header fields with extreme
1984 skepticism, including refusing to display them to the end user or
1985 even ignoring the signature if it does not cover certain header
1986 fields. For this reason, signing fields present in the message
1987 such as Date, Subject, Reply-To, Sender, and all MIME header
1988 fields are highly advised.
1990 The DKIM-Signature header field is always implicitly signed and MUST
1991 NOT be included in the "h=" tag except to indicate that other
1992 preexisting signatures are also signed.
1994 Signers MAY claim to have signed header fields that do not exist
1995 (that is, signers MAY include the header field name in the "h=" tag
1996 even if that header field does not exist in the message). When
1997 computing the signature, the non-existing header field MUST be
1998 treated as the null string (including the header field name, header
1999 field value, all punctuation, and the trailing CRLF).
2001 INFORMATIVE RATIONALE: This allows signers to explicitly assert
2002 the absence of a header field; if that header field is added later
2003 the signature will fail.
2005 INFORMATIVE NOTE: A header field name need only be listed once
2006 more than the actual number of that header field in a message at
2007 the time of signing in order to prevent any further additions.
2008 For example, if there is a single Comments header field at the
2009 time of signing, listing Comments twice in the "h=" tag is
2010 sufficient to prevent any number of Comments header fields from
2011 being appended; it is not necessary (but is legal) to list
2012 Comments three or more times in the "h=" tag.
2018Allman, et al. Standards Track [Page 36]
2020RFC 4871 DKIM Signatures May 2007
2023 Signers choosing to sign an existing header field that occurs more
2024 than once in the message (such as Received) MUST sign the physically
2025 last instance of that header field in the header block. Signers
2026 wishing to sign multiple instances of such a header field MUST
2027 include the header field name multiple times in the h= tag of the
2028 DKIM-Signature header field, and MUST sign such header fields in
2029 order from the bottom of the header field block to the top. The
2030 signer MAY include more instances of a header field name in h= than
2031 there are actual corresponding header fields to indicate that
2032 additional header fields of that name SHOULD NOT be added.
2034 INFORMATIVE EXAMPLE:
2036 If the signer wishes to sign two existing Received header fields,
2037 and the existing header contains:
2043 then the resulting DKIM-Signature header field should read:
2045 DKIM-Signature: ... h=Received : Received : ...
2047 and Received header fields <C> and <B> will be signed in that
2050 Signers should be careful of signing header fields that might have
2051 additional instances added later in the delivery process, since such
2052 header fields might be inserted after the signed instance or
2053 otherwise reordered. Trace header fields (such as Received) and
2054 Resent-* blocks are the only fields prohibited by [RFC2822] from
2055 being reordered. In particular, since DKIM-Signature header fields
2056 may be reordered by some intermediate MTAs, signing existing DKIM-
2057 Signature header fields is error-prone.
2059 INFORMATIVE ADMONITION: Despite the fact that [RFC2822] permits
2060 header fields to be reordered (with the exception of Received
2061 header fields), reordering of signed header fields with multiple
2062 instances by intermediate MTAs will cause DKIM signatures to be
2063 broken; such anti-social behavior should be avoided.
2065 INFORMATIVE IMPLEMENTER'S NOTE: Although not required by this
2066 specification, all end-user visible header fields should be signed
2067 to avoid possible "indirect spamming". For example, if the
2068 Subject header field is not signed, a spammer can resend a
2069 previously signed mail, replacing the legitimate subject with a
2074Allman, et al. Standards Track [Page 37]
2076RFC 4871 DKIM Signatures May 2007
20795.5. Recommended Signature Content
2081 In order to maximize compatibility with a variety of verifiers, it is
2082 recommended that signers follow the practices outlined in this
2083 section when signing a message. However, these are generic
2084 recommendations applying to the general case; specific senders may
2085 wish to modify these guidelines as required by their unique
2086 situations. Verifiers MUST be capable of verifying signatures even
2087 if one or more of the recommended header fields is not signed (with
2088 the exception of From, which must always be signed) or if one or more
2089 of the disrecommended header fields is signed. Note that verifiers
2090 do have the option of ignoring signatures that do not cover a
2091 sufficient portion of the header or body, just as they may ignore
2092 signatures from an identity they do not trust.
2094 The following header fields SHOULD be included in the signature, if
2095 they are present in the message being signed:
2097 o From (REQUIRED in all signatures)
2109 o Content-Type, Content-Transfer-Encoding, Content-ID, Content-
2112 o Resent-Date, Resent-From, Resent-Sender, Resent-To, Resent-Cc,
2115 o In-Reply-To, References
2117 o List-Id, List-Help, List-Unsubscribe, List-Subscribe, List-Post,
2118 List-Owner, List-Archive
2120 The following header fields SHOULD NOT be included in the signature:
2126 o Comments, Keywords
2130Allman, et al. Standards Track [Page 38]
2132RFC 4871 DKIM Signatures May 2007
2139 Optional header fields (those not mentioned above) normally SHOULD
2140 NOT be included in the signature, because of the potential for
2141 additional header fields of the same name to be legitimately added or
2142 reordered prior to verification. There are likely to be legitimate
2143 exceptions to this rule, because of the wide variety of application-
2144 specific header fields that may be applied to a message, some of
2145 which are unlikely to be duplicated, modified, or reordered.
2147 Signers SHOULD choose canonicalization algorithms based on the types
2148 of messages they process and their aversion to risk. For example,
2149 e-commerce sites sending primarily purchase receipts, which are not
2150 expected to be processed by mailing lists or other software likely to
2151 modify messages, will generally prefer "simple" canonicalization.
2152 Sites sending primarily person-to-person email will likely prefer to
2153 be more resilient to modification during transport by using "relaxed"
2156 Signers SHOULD NOT use "l=" unless they intend to accommodate
2157 intermediate mail processors that append text to a message. For
2158 example, many mailing list processors append "unsubscribe"
2159 information to message bodies. If signers use "l=", they SHOULD
2160 include the entire message body existing at the time of signing in
2161 computing the count. In particular, signers SHOULD NOT specify a
2162 body length of 0 since this may be interpreted as a meaningless
2163 signature by some verifiers.
21655.6. Compute the Message Hash and Signature
2167 The signer MUST compute the message hash as described in Section 3.7
2168 and then sign it using the selected public-key algorithm. This will
2169 result in a DKIM-Signature header field that will include the body
2170 hash and a signature of the header hash, where that header includes
2171 the DKIM-Signature header field itself.
2173 Entities such as mailing list managers that implement DKIM and that
2174 modify the message or a header field (for example, inserting
2175 unsubscribe information) before retransmitting the message SHOULD
2176 check any existing signature on input and MUST make such
2177 modifications before re-signing the message.
2179 The signer MAY elect to limit the number of bytes of the body that
2180 will be included in the hash and hence signed. The length actually
2181 hashed should be inserted in the "l=" tag of the DKIM-Signature
2186Allman, et al. Standards Track [Page 39]
2188RFC 4871 DKIM Signatures May 2007
21915.7. Insert the DKIM-Signature Header Field
2193 Finally, the signer MUST insert the DKIM-Signature header field
2194 created in the previous step prior to transmitting the email. The
2195 DKIM-Signature header field MUST be the same as used to compute the
2196 hash as described above, except that the value of the "b=" tag MUST
2197 be the appropriately signed hash computed in the previous step,
2198 signed using the algorithm specified in the "a=" tag of the DKIM-
2199 Signature header field and using the private key corresponding to the
2200 selector given in the "s=" tag of the DKIM-Signature header field, as
2201 chosen above in Section 5.2
2203 The DKIM-Signature header field MUST be inserted before any other
2204 DKIM-Signature fields in the header block.
2206 INFORMATIVE IMPLEMENTATION NOTE: The easiest way to achieve this
2207 is to insert the DKIM-Signature header field at the beginning of
2208 the header block. In particular, it may be placed before any
2209 existing Received header fields. This is consistent with treating
2210 DKIM-Signature as a trace header field.
2214 Since a signer MAY remove or revoke a public key at any time, it is
2215 recommended that verification occur in a timely manner. In many
2216 configurations, the most timely place is during acceptance by the
2217 border MTA or shortly thereafter. In particular, deferring
2218 verification until the message is accessed by the end user is
2221 A border or intermediate MTA MAY verify the message signature(s). An
2222 MTA who has performed verification MAY communicate the result of that
2223 verification by adding a verification header field to incoming
2224 messages. This considerably simplifies things for the user, who can
2225 now use an existing mail user agent. Most MUAs have the ability to
2226 filter messages based on message header fields or content; these
2227 filters would be used to implement whatever policy the user wishes
2228 with respect to unsigned mail.
2230 A verifying MTA MAY implement a policy with respect to unverifiable
2231 mail, regardless of whether or not it applies the verification header
2232 field to signed messages.
2234 Verifiers MUST produce a result that is semantically equivalent to
2235 applying the following steps in the order listed. In practice,
2236 several of these steps can be performed in parallel in order to
2237 improve performance.
2242Allman, et al. Standards Track [Page 40]
2244RFC 4871 DKIM Signatures May 2007
22476.1. Extract Signatures from the Message
2249 The order in which verifiers try DKIM-Signature header fields is not
2250 defined; verifiers MAY try signatures in any order they like. For
2251 example, one implementation might try the signatures in textual
2252 order, whereas another might try signatures by identities that match
2253 the contents of the From header field before trying other signatures.
2254 Verifiers MUST NOT attribute ultimate meaning to the order of
2255 multiple DKIM-Signature header fields. In particular, there is
2256 reason to believe that some relays will reorder the header fields in
2257 potentially arbitrary ways.
2259 INFORMATIVE IMPLEMENTATION NOTE: Verifiers might use the order as
2260 a clue to signing order in the absence of any other information.
2261 However, other clues as to the semantics of multiple signatures
2262 (such as correlating the signing host with Received header fields)
2263 may also be considered.
2265 A verifier SHOULD NOT treat a message that has one or more bad
2266 signatures and no good signatures differently from a message with no
2267 signature at all; such treatment is a matter of local policy and is
2268 beyond the scope of this document.
2270 When a signature successfully verifies, a verifier will either stop
2271 processing or attempt to verify any other signatures, at the
2272 discretion of the implementation. A verifier MAY limit the number of
2273 signatures it tries to avoid denial-of-service attacks.
2275 INFORMATIVE NOTE: An attacker could send messages with large
2276 numbers of faulty signatures, each of which would require a DNS
2277 lookup and corresponding CPU time to verify the message. This
2278 could be an attack on the domain that receives the message, by
2279 slowing down the verifier by requiring it to do a large number of
2280 DNS lookups and/or signature verifications. It could also be an
2281 attack against the domains listed in the signatures, essentially
2282 by enlisting innocent verifiers in launching an attack against the
2283 DNS servers of the actual victim.
2285 In the following description, text reading "return status
2286 (explanation)" (where "status" is one of "PERMFAIL" or "TEMPFAIL")
2287 means that the verifier MUST immediately cease processing that
2288 signature. The verifier SHOULD proceed to the next signature, if any
2289 is present, and completely ignore the bad signature. If the status
2290 is "PERMFAIL", the signature failed and should not be reconsidered.
2291 If the status is "TEMPFAIL", the signature could not be verified at
2292 this time but may be tried again later. A verifier MAY either defer
2293 the message for later processing, perhaps by queueing it locally or
2294 issuing a 451/4.7.5 SMTP reply, or try another signature; if no good
2298Allman, et al. Standards Track [Page 41]
2300RFC 4871 DKIM Signatures May 2007
2303 signature is found and any of the signatures resulted in a TEMPFAIL
2304 status, the verifier MAY save the message for later processing. The
2305 "(explanation)" is not normative text; it is provided solely for
2308 Verifiers SHOULD ignore any DKIM-Signature header fields where the
2309 signature does not validate. Verifiers that are prepared to validate
2310 multiple signature header fields SHOULD proceed to the next signature
2311 header field, should it exist. However, verifiers MAY make note of
2312 the fact that an invalid signature was present for consideration at a
2315 INFORMATIVE NOTE: The rationale of this requirement is to permit
2316 messages that have invalid signatures but also a valid signature
2317 to work. For example, a mailing list exploder might opt to leave
2318 the original submitter signature in place even though the exploder
2319 knows that it is modifying the message in some way that will break
2320 that signature, and the exploder inserts its own signature. In
2321 this case, the message should succeed even in the presence of the
2322 known-broken signature.
2324 For each signature to be validated, the following steps should be
2325 performed in such a manner as to produce a result that is
2326 semantically equivalent to performing them in the indicated order.
23286.1.1. Validate the Signature Header Field
2330 Implementers MUST meticulously validate the format and values in the
2331 DKIM-Signature header field; any inconsistency or unexpected values
2332 MUST cause the header field to be completely ignored and the verifier
2333 to return PERMFAIL (signature syntax error). Being "liberal in what
2334 you accept" is definitely a bad strategy in this security context.
2335 Note however that this does not include the existence of unknown tags
2336 in a DKIM-Signature header field, which are explicitly permitted.
2338 Verifiers MUST ignore DKIM-Signature header fields with a "v=" tag
2339 that is inconsistent with this specification and return PERMFAIL
2340 (incompatible version).
2342 INFORMATIVE IMPLEMENTATION NOTE: An implementation may, of course,
2343 choose to also verify signatures generated by older versions of
2346 If any tag listed as "required" in Section 3.5 is omitted from the
2347 DKIM-Signature header field, the verifier MUST ignore the DKIM-
2348 Signature header field and return PERMFAIL (signature missing
2354Allman, et al. Standards Track [Page 42]
2356RFC 4871 DKIM Signatures May 2007
2359 INFORMATIONAL NOTE: The tags listed as required in Section 3.5 are
2360 "v=", "a=", "b=", "bh=", "d=", "h=", and "s=". Should there be a
2361 conflict between this note and Section 3.5, Section 3.5 is
2364 If the DKIM-Signature header field does not contain the "i=" tag, the
2365 verifier MUST behave as though the value of that tag were "@d", where
2366 "d" is the value from the "d=" tag.
2368 Verifiers MUST confirm that the domain specified in the "d=" tag is
2369 the same as or a parent domain of the domain part of the "i=" tag.
2370 If not, the DKIM-Signature header field MUST be ignored and the
2371 verifier should return PERMFAIL (domain mismatch).
2373 If the "h=" tag does not include the From header field, the verifier
2374 MUST ignore the DKIM-Signature header field and return PERMFAIL (From
2377 Verifiers MAY ignore the DKIM-Signature header field and return
2378 PERMFAIL (signature expired) if it contains an "x=" tag and the
2379 signature has expired.
2381 Verifiers MAY ignore the DKIM-Signature header field if the domain
2382 used by the signer in the "d=" tag is not associated with a valid
2383 signing entity. For example, signatures with "d=" values such as
2384 "com" and "co.uk" may be ignored. The list of unacceptable domains
2385 SHOULD be configurable.
2387 Verifiers MAY ignore the DKIM-Signature header field and return
2388 PERMFAIL (unacceptable signature header) for any other reason, for
2389 example, if the signature does not sign header fields that the
2390 verifier views to be essential. As a case in point, if MIME header
2391 fields are not signed, certain attacks may be possible that the
2392 verifier would prefer to avoid.
23946.1.2. Get the Public Key
2396 The public key for a signature is needed to complete the verification
2397 process. The process of retrieving the public key depends on the
2398 query type as defined by the "q=" tag in the DKIM-Signature header
2399 field. Obviously, a public key need only be retrieved if the process
2400 of extracting the signature information is completely successful.
2401 Details of key management and representation are described in
2402 Section 3.6. The verifier MUST validate the key record and MUST
2403 ignore any public key records that are malformed.
2405 When validating a message, a verifier MUST perform the following
2406 steps in a manner that is semantically the same as performing them in
2410Allman, et al. Standards Track [Page 43]
2412RFC 4871 DKIM Signatures May 2007
2415 the order indicated (in some cases, the implementation may
2416 parallelize or reorder these steps, as long as the semantics remain
2419 1. Retrieve the public key as described in Section 3.6 using the
2420 algorithm in the "q=" tag, the domain from the "d=" tag, and the
2421 selector from the "s=" tag.
2423 2. If the query for the public key fails to respond, the verifier
2424 MAY defer acceptance of this email and return TEMPFAIL (key
2425 unavailable). If verification is occurring during the incoming
2426 SMTP session, this MAY be achieved with a 451/4.7.5 SMTP reply
2427 code. Alternatively, the verifier MAY store the message in the
2428 local queue for later trial or ignore the signature. Note that
2429 storing a message in the local queue is subject to denial-of-
2432 3. If the query for the public key fails because the corresponding
2433 key record does not exist, the verifier MUST immediately return
2434 PERMFAIL (no key for signature).
2436 4. If the query for the public key returns multiple key records, the
2437 verifier may choose one of the key records or may cycle through
2438 the key records performing the remainder of these steps on each
2439 record at the discretion of the implementer. The order of the
2440 key records is unspecified. If the verifier chooses to cycle
2441 through the key records, then the "return ..." wording in the
2442 remainder of this section means "try the next key record, if any;
2443 if none, return to try another signature in the usual way".
2445 5. If the result returned from the query does not adhere to the
2446 format defined in this specification, the verifier MUST ignore
2447 the key record and return PERMFAIL (key syntax error). Verifiers
2448 are urged to validate the syntax of key records carefully to
2449 avoid attempted attacks. In particular, the verifier MUST ignore
2450 keys with a version code ("v=" tag) that they do not implement.
2452 6. If the "g=" tag in the public key does not match the Local-part
2453 of the "i=" tag in the message signature header field, the
2454 verifier MUST ignore the key record and return PERMFAIL
2455 (inapplicable key). If the Local-part of the "i=" tag on the
2456 message signature is not present, the "g=" tag must be "*" (valid
2457 for all addresses in the domain) or the entire g= tag must be
2458 omitted (which defaults to "g=*"), otherwise the verifier MUST
2459 ignore the key record and return PERMFAIL (inapplicable key).
2460 Other than this test, verifiers SHOULD NOT treat a message signed
2461 with a key record having a "g=" tag any differently than one
2462 without; in particular, verifiers SHOULD NOT prefer messages that
2466Allman, et al. Standards Track [Page 44]
2468RFC 4871 DKIM Signatures May 2007
2471 seem to have an individual signature by virtue of a "g=" tag
2472 versus a domain signature.
2474 7. If the "h=" tag exists in the public key record and the hash
2475 algorithm implied by the a= tag in the DKIM-Signature header
2476 field is not included in the contents of the "h=" tag, the
2477 verifier MUST ignore the key record and return PERMFAIL
2478 (inappropriate hash algorithm).
2480 8. If the public key data (the "p=" tag) is empty, then this key has
2481 been revoked and the verifier MUST treat this as a failed
2482 signature check and return PERMFAIL (key revoked). There is no
2483 defined semantic difference between a key that has been revoked
2484 and a key record that has been removed.
2486 9. If the public key data is not suitable for use with the algorithm
2487 and key types defined by the "a=" and "k=" tags in the DKIM-
2488 Signature header field, the verifier MUST immediately return
2489 PERMFAIL (inappropriate key algorithm).
24916.1.3. Compute the Verification
2493 Given a signer and a public key, verifying a signature consists of
2494 actions semantically equivalent to the following steps.
2496 1. Based on the algorithm defined in the "c=" tag, the body length
2497 specified in the "l=" tag, and the header field names in the "h="
2498 tag, prepare a canonicalized version of the message as is
2499 described in Section 3.7 (note that this version does not
2500 actually need to be instantiated). When matching header field
2501 names in the "h=" tag against the actual message header field,
2502 comparisons MUST be case-insensitive.
2504 2. Based on the algorithm indicated in the "a=" tag, compute the
2505 message hashes from the canonical copy as described in
2508 3. Verify that the hash of the canonicalized message body computed
2509 in the previous step matches the hash value conveyed in the "bh="
2510 tag. If the hash does not match, the verifier SHOULD ignore the
2511 signature and return PERMFAIL (body hash did not verify).
2513 4. Using the signature conveyed in the "b=" tag, verify the
2514 signature against the header hash using the mechanism appropriate
2515 for the public key algorithm described in the "a=" tag. If the
2516 signature does not validate, the verifier SHOULD ignore the
2517 signature and return PERMFAIL (signature did not verify).
2522Allman, et al. Standards Track [Page 45]
2524RFC 4871 DKIM Signatures May 2007
2527 5. Otherwise, the signature has correctly verified.
2529 INFORMATIVE IMPLEMENTER'S NOTE: Implementations might wish to
2530 initiate the public-key query in parallel with calculating the
2531 hash as the public key is not needed until the final decryption is
2532 calculated. Implementations may also verify the signature on the
2533 message header before validating that the message hash listed in
2534 the "bh=" tag in the DKIM-Signature header field matches that of
2535 the actual message body; however, if the body hash does not match,
2536 the entire signature must be considered to have failed.
2538 A body length specified in the "l=" tag of the signature limits the
2539 number of bytes of the body passed to the verification algorithm.
2540 All data beyond that limit is not validated by DKIM. Hence,
2541 verifiers might treat a message that contains bytes beyond the
2542 indicated body length with suspicion, such as by truncating the
2543 message at the indicated body length, declaring the signature invalid
2544 (e.g., by returning PERMFAIL (unsigned content)), or conveying the
2545 partial verification to the policy module.
2547 INFORMATIVE IMPLEMENTATION NOTE: Verifiers that truncate the body
2548 at the indicated body length might pass on a malformed MIME
2549 message if the signer used the "N-4" trick (omitting the final
2550 "--CRLF") described in the informative note in Section 3.4.5.
2551 Such verifiers may wish to check for this case and include a
2552 trailing "--CRLF" to avoid breaking the MIME structure. A simple
2553 way to achieve this might be to append "--CRLF" to any "multipart"
2554 message with a body length; if the MIME structure is already
2555 correctly formed, this will appear in the postlude and will not be
2556 displayed to the end user.
25586.2. Communicate Verification Results
2560 Verifiers wishing to communicate the results of verification to other
2561 parts of the mail system may do so in whatever manner they see fit.
2562 For example, implementations might choose to add an email header
2563 field to the message before passing it on. Any such header field
2564 SHOULD be inserted before any existing DKIM-Signature or preexisting
2565 authentication status header fields in the header field block.
2567 INFORMATIVE ADVICE to MUA filter writers: Patterns intended to
2568 search for results header fields to visibly mark authenticated
2569 mail for end users should verify that such header field was added
2570 by the appropriate verifying domain and that the verified identity
2571 matches the author identity that will be displayed by the MUA. In
2572 particular, MUA filters should not be influenced by bogus results
2578Allman, et al. Standards Track [Page 46]
2580RFC 4871 DKIM Signatures May 2007
2583 header fields added by attackers. To circumvent this attack,
2584 verifiers may wish to delete existing results header fields after
2585 verification and before adding a new header field.
25876.3. Interpret Results/Apply Local Policy
2589 It is beyond the scope of this specification to describe what actions
2590 a verifier system should make, but an authenticated email presents an
2591 opportunity to a receiving system that unauthenticated email cannot.
2592 Specifically, an authenticated email creates a predictable identifier
2593 by which other decisions can reliably be managed, such as trust and
2594 reputation. Conversely, unauthenticated email lacks a reliable
2595 identifier that can be used to assign trust and reputation. It is
2596 reasonable to treat unauthenticated email as lacking any trust and
2597 having no positive reputation.
2599 In general, verifiers SHOULD NOT reject messages solely on the basis
2600 of a lack of signature or an unverifiable signature; such rejection
2601 would cause severe interoperability problems. However, if the
2602 verifier does opt to reject such messages (for example, when
2603 communicating with a peer who, by prior agreement, agrees to only
2604 send signed messages), and the verifier runs synchronously with the
2605 SMTP session and a signature is missing or does not verify, the MTA
2606 SHOULD use a 550/5.7.x reply code.
2608 If it is not possible to fetch the public key, perhaps because the
2609 key server is not available, a temporary failure message MAY be
2610 generated using a 451/4.7.5 reply code, such as:
2612 451 4.7.5 Unable to verify signature - key server unavailable
2614 Temporary failures such as inability to access the key server or
2615 other external service are the only conditions that SHOULD use a 4xx
2616 SMTP reply code. In particular, cryptographic signature verification
2617 failures MUST NOT return 4xx SMTP replies.
2619 Once the signature has been verified, that information MUST be
2620 conveyed to higher-level systems (such as explicit allow/whitelists
2621 and reputation systems) and/or to the end user. If the message is
2622 signed on behalf of any address other than that in the From: header
2623 field, the mail system SHOULD take pains to ensure that the actual
2624 signing identity is clear to the reader.
2626 The verifier MAY treat unsigned header fields with extreme
2627 skepticism, including marking them as untrusted or even deleting them
2628 before display to the end user.
2634Allman, et al. Standards Track [Page 47]
2636RFC 4871 DKIM Signatures May 2007
2639 While the symptoms of a failed verification are obvious -- the
2640 signature doesn't verify -- establishing the exact cause can be more
2641 difficult. If a selector cannot be found, is that because the
2642 selector has been removed, or was the value changed somehow in
2643 transit? If the signature line is missing, is that because it was
2644 never there, or was it removed by an overzealous filter? For
2645 diagnostic purposes, the exact reason why the verification fails
2646 SHOULD be made available to the policy module and possibly recorded
2647 in the system logs. If the email cannot be verified, then it SHOULD
2648 be rendered the same as all unverified email regardless of whether or
2649 not it looks like it was signed.
26517. IANA Considerations
2653 DKIM introduces some new namespaces that have been registered with
2654 IANA. In all cases, new values are assigned only for values that
2655 have been documented in a published RFC that has IETF Consensus
26587.1. DKIM-Signature Tag Specifications
2660 A DKIM-Signature provides for a list of tag specifications. IANA has
2661 established the DKIM-Signature Tag Specification Registry for tag
2662 specifications that can be used in DKIM-Signature fields.
2664 The initial entries in the registry comprise:
2666 +------+-----------------+
2667 | TYPE | REFERENCE |
2668 +------+-----------------+
2669 | v | (this document) |
2670 | a | (this document) |
2671 | b | (this document) |
2672 | bh | (this document) |
2673 | c | (this document) |
2674 | d | (this document) |
2675 | h | (this document) |
2676 | i | (this document) |
2677 | l | (this document) |
2678 | q | (this document) |
2679 | s | (this document) |
2680 | t | (this document) |
2681 | x | (this document) |
2682 | z | (this document) |
2683 +------+-----------------+
2685 DKIM-Signature Tag Specification Registry Initial Values
2690Allman, et al. Standards Track [Page 48]
2692RFC 4871 DKIM Signatures May 2007
26957.2. DKIM-Signature Query Method Registry
2697 The "q=" tag-spec (specified in Section 3.5) provides for a list of
2700 IANA has established the DKIM-Signature Query Method Registry for
2701 mechanisms that can be used to retrieve the key that will permit
2702 validation processing of a message signed using DKIM.
2704 The initial entry in the registry comprises:
2706 +------+--------+-----------------+
2707 | TYPE | OPTION | REFERENCE |
2708 +------+--------+-----------------+
2709 | dns | txt | (this document) |
2710 +------+--------+-----------------+
2712 DKIM-Signature Query Method Registry Initial Values
27147.3. DKIM-Signature Canonicalization Registry
2716 The "c=" tag-spec (specified in Section 3.5) provides for a specifier
2717 for canonicalization algorithms for the header and body of the
2720 IANA has established the DKIM-Signature Canonicalization Algorithm
2721 Registry for algorithms for converting a message into a canonical
2722 form before signing or verifying using DKIM.
2724 The initial entries in the header registry comprise:
2726 +---------+-----------------+
2727 | TYPE | REFERENCE |
2728 +---------+-----------------+
2729 | simple | (this document) |
2730 | relaxed | (this document) |
2731 +---------+-----------------+
2733 DKIM-Signature Header Canonicalization Algorithm Registry
2746Allman, et al. Standards Track [Page 49]
2748RFC 4871 DKIM Signatures May 2007
2751 The initial entries in the body registry comprise:
2753 +---------+-----------------+
2754 | TYPE | REFERENCE |
2755 +---------+-----------------+
2756 | simple | (this document) |
2757 | relaxed | (this document) |
2758 +---------+-----------------+
2760 DKIM-Signature Body Canonicalization Algorithm Registry
27637.4. _domainkey DNS TXT Record Tag Specifications
2765 A _domainkey DNS TXT record provides for a list of tag
2766 specifications. IANA has established the DKIM _domainkey DNS TXT Tag
2767 Specification Registry for tag specifications that can be used in DNS
2770 The initial entries in the registry comprise:
2772 +------+-----------------+
2773 | TYPE | REFERENCE |
2774 +------+-----------------+
2775 | v | (this document) |
2776 | g | (this document) |
2777 | h | (this document) |
2778 | k | (this document) |
2779 | n | (this document) |
2780 | p | (this document) |
2781 | s | (this document) |
2782 | t | (this document) |
2783 +------+-----------------+
2785 DKIM _domainkey DNS TXT Record Tag Specification Registry
27887.5. DKIM Key Type Registry
2790 The "k=" <key-k-tag> (specified in Section 3.6.1) and the "a=" <sig-
2791 a-tag-k> (specified in Section 3.5) tags provide for a list of
2792 mechanisms that can be used to decode a DKIM signature.
2794 IANA has established the DKIM Key Type Registry for such mechanisms.
2802Allman, et al. Standards Track [Page 50]
2804RFC 4871 DKIM Signatures May 2007
2807 The initial entry in the registry comprises:
2809 +------+-----------+
2810 | TYPE | REFERENCE |
2811 +------+-----------+
2813 +------+-----------+
2815 DKIM Key Type Initial Values
28177.6. DKIM Hash Algorithms Registry
2819 The "h=" <key-h-tag> (specified in Section 3.6.1) and the "a=" <sig-
2820 a-tag-h> (specified in Section 3.5) tags provide for a list of
2821 mechanisms that can be used to produce a digest of message data.
2823 IANA has established the DKIM Hash Algorithms Registry for such
2826 The initial entries in the registry comprise:
2828 +--------+-------------------+
2829 | TYPE | REFERENCE |
2830 +--------+-------------------+
2831 | sha1 | [FIPS.180-2.2002] |
2832 | sha256 | [FIPS.180-2.2002] |
2833 +--------+-------------------+
2835 DKIM Hash Algorithms Initial Values
28377.7. DKIM Service Types Registry
2839 The "s=" <key-s-tag> tag (specified in Section 3.6.1) provides for a
2840 list of service types to which this selector may apply.
2842 IANA has established the DKIM Service Types Registry for service
2845 The initial entries in the registry comprise:
2847 +-------+-----------------+
2848 | TYPE | REFERENCE |
2849 +-------+-----------------+
2850 | email | (this document) |
2851 | * | (this document) |
2852 +-------+-----------------+
2854 DKIM Service Types Registry Initial Values
2858Allman, et al. Standards Track [Page 51]
2860RFC 4871 DKIM Signatures May 2007
28637.8. DKIM Selector Flags Registry
2865 The "t=" <key-t-tag> tag (specified in Section 3.6.1) provides for a
2866 list of flags to modify interpretation of the selector.
2868 IANA has established the DKIM Selector Flags Registry for additional
2871 The initial entries in the registry comprise:
2873 +------+-----------------+
2874 | TYPE | REFERENCE |
2875 +------+-----------------+
2876 | y | (this document) |
2877 | s | (this document) |
2878 +------+-----------------+
2880 DKIM Selector Flags Registry Initial Values
28827.9. DKIM-Signature Header Field
2884 IANA has added DKIM-Signature to the "Permanent Message Header
2885 Fields" registry (see [RFC3864]) for the "mail" protocol, using this
2886 document as the reference.
28888. Security Considerations
2890 It has been observed that any mechanism that is introduced that
2891 attempts to stem the flow of spam is subject to intensive attack.
2892 DKIM needs to be carefully scrutinized to identify potential attack
2893 vectors and the vulnerability to each. See also [RFC4686].
28958.1. Misuse of Body Length Limits ("l=" Tag)
2897 Body length limits (in the form of the "l=" tag) are subject to
2898 several potential attacks.
29008.1.1. Addition of New MIME Parts to Multipart/*
2902 If the body length limit does not cover a closing MIME multipart
2903 section (including the trailing "--CRLF" portion), then it is
2904 possible for an attacker to intercept a properly signed multipart
2905 message and add a new body part. Depending on the details of the
2906 MIME type and the implementation of the verifying MTA and the
2907 receiving MUA, this could allow an attacker to change the information
2908 displayed to an end user from an apparently trusted source.
2914Allman, et al. Standards Track [Page 52]
2916RFC 4871 DKIM Signatures May 2007
2919 For example, if attackers can append information to a "text/html"
2920 body part, they may be able to exploit a bug in some MUAs that
2921 continue to read after a "</html>" marker, and thus display HTML text
2922 on top of already displayed text. If a message has a
2923 "multipart/alternative" body part, they might be able to add a new
2924 body part that is preferred by the displaying MUA.
29268.1.2. Addition of new HTML content to existing content
2928 Several receiving MUA implementations do not cease display after a
2929 ""</html>"" tag. In particular, this allows attacks involving
2930 overlaying images on top of existing text.
2932 INFORMATIVE EXAMPLE: Appending the following text to an existing,
2933 properly closed message will in many MUAs result in inappropriate
2934 data being rendered on top of existing, correct data:
2935 <div style="position: relative; bottom: 350px; z-index: 2;">
2936 <img src="http://www.ietf.org/images/ietflogo2e.gif"
2937 width=578 height=370>
29408.2. Misappropriated Private Key
2942 If the private key for a user is resident on their computer and is
2943 not protected by an appropriately secure mechanism, it is possible
2944 for malware to send mail as that user and any other user sharing the
2945 same private key. The malware would not, however, be able to
2946 generate signed spoofs of other signers' addresses, which would aid
2947 in identification of the infected user and would limit the
2948 possibilities for certain types of attacks involving socially
2949 engineered messages. This threat applies mainly to MUA-based
2950 implementations; protection of private keys on servers can be easily
2951 achieved through the use of specialized cryptographic hardware.
2953 A larger problem occurs if malware on many users' computers obtains
2954 the private keys for those users and transmits them via a covert
2955 channel to a site where they can be shared. The compromised users
2956 would likely not know of the misappropriation until they receive
2957 "bounce" messages from messages they are purported to have sent.
2958 Many users might not understand the significance of these bounce
2959 messages and would not take action.
2961 One countermeasure is to use a user-entered passphrase to encrypt the
2962 private key, although users tend to choose weak passphrases and often
2963 reuse them for different purposes, possibly allowing an attack
2964 against DKIM to be extended into other domains. Nevertheless, the
2965 decoded private key might be briefly available to compromise by
2966 malware when it is entered, or might be discovered via keystroke
2970Allman, et al. Standards Track [Page 53]
2972RFC 4871 DKIM Signatures May 2007
2975 logging. The added complexity of entering a passphrase each time one
2976 sends a message would also tend to discourage the use of a secure
2979 A somewhat more effective countermeasure is to send messages through
2980 an outgoing MTA that can authenticate the submitter using existing
2981 techniques (e.g., SMTP Authentication), possibly validate the message
2982 itself (e.g., verify that the header is legitimate and that the
2983 content passes a spam content check), and sign the message using a
2984 key appropriate for the submitter address. Such an MTA can also
2985 apply controls on the volume of outgoing mail each user is permitted
2986 to originate in order to further limit the ability of malware to
2987 generate bulk email.
29898.3. Key Server Denial-of-Service Attacks
2991 Since the key servers are distributed (potentially separate for each
2992 domain), the number of servers that would need to be attacked to
2993 defeat this mechanism on an Internet-wide basis is very large.
2994 Nevertheless, key servers for individual domains could be attacked,
2995 impeding the verification of messages from that domain. This is not
2996 significantly different from the ability of an attacker to deny
2997 service to the mail exchangers for a given domain, although it
2998 affects outgoing, not incoming, mail.
3000 A variation on this attack is that if a very large amount of mail
3001 were to be sent using spoofed addresses from a given domain, the key
3002 servers for that domain could be overwhelmed with requests. However,
3003 given the low overhead of verification compared with handling of the
3004 email message itself, such an attack would be difficult to mount.
30068.4. Attacks Against the DNS
3008 Since the DNS is a required binding for key services, specific
3009 attacks against the DNS must be considered.
3011 While the DNS is currently insecure [RFC3833], these security
3012 problems are the motivation behind DNS Security (DNSSEC) [RFC4033],
3013 and all users of the DNS will reap the benefit of that work.
3015 DKIM is only intended as a "sufficient" method of proving
3016 authenticity. It is not intended to provide strong cryptographic
3017 proof about authorship or contents. Other technologies such as
3018 OpenPGP [RFC2440] and S/MIME [RFC3851] address those requirements.
3020 A second security issue related to the DNS revolves around the
3021 increased DNS traffic as a consequence of fetching selector-based
3022 data as well as fetching signing domain policy. Widespread
3026Allman, et al. Standards Track [Page 54]
3028RFC 4871 DKIM Signatures May 2007
3031 deployment of DKIM will result in a significant increase in DNS
3032 queries to the claimed signing domain. In the case of forgeries on a
3033 large scale, DNS servers could see a substantial increase in queries.
3035 A specific DNS security issue that should be considered by DKIM
3036 verifiers is the name chaining attack described in Section 2.3 of the
3037 DNS Threat Analysis [RFC3833]. A DKIM verifier, while verifying a
3038 DKIM-Signature header field, could be prompted to retrieve a key
3039 record of an attacker's choosing. This threat can be minimized by
3040 ensuring that name servers, including recursive name servers, used by
3041 the verifier enforce strict checking of "glue" and other additional
3042 information in DNS responses and are therefore not vulnerable to this
3047 In this attack, a spammer sends a message to be spammed to an
3048 accomplice, which results in the message being signed by the
3049 originating MTA. The accomplice resends the message, including the
3050 original signature, to a large number of recipients, possibly by
3051 sending the message to many compromised machines that act as MTAs.
3052 The messages, not having been modified by the accomplice, have valid
3055 Partial solutions to this problem involve the use of reputation
3056 services to convey the fact that the specific email address is being
3057 used for spam and that messages from that signer are likely to be
3058 spam. This requires a real-time detection mechanism in order to
3059 react quickly enough. However, such measures might be prone to
3060 abuse, if for example an attacker resent a large number of messages
3061 received from a victim in order to make them appear to be a spammer.
3063 Large verifiers might be able to detect unusually large volumes of
3064 mails with the same signature in a short time period. Smaller
3065 verifiers can get substantially the same volume of information via
3066 existing collaborative systems.
30688.6. Limits on Revoking Keys
3070 When a large domain detects undesirable behavior on the part of one
3071 of its users, it might wish to revoke the key used to sign that
3072 user's messages in order to disavow responsibility for messages that
3073 have not yet been verified or that are the subject of a replay
3074 attack. However, the ability of the domain to do so can be limited
3075 if the same key, for scalability reasons, is used to sign messages
3076 for many other users. Mechanisms for explicitly revoking keys on a
3077 per-address basis have been proposed but require further study as to
3078 their utility and the DNS load they represent.
3082Allman, et al. Standards Track [Page 55]
3084RFC 4871 DKIM Signatures May 2007
30878.7. Intentionally Malformed Key Records
3089 It is possible for an attacker to publish key records in DNS that are
3090 intentionally malformed, with the intent of causing a denial-of-
3091 service attack on a non-robust verifier implementation. The attacker
3092 could then cause a verifier to read the malformed key record by
3093 sending a message to one of its users referencing the malformed
3094 record in a (not necessarily valid) signature. Verifiers MUST
3095 thoroughly verify all key records retrieved from the DNS and be
3096 robust against intentionally as well as unintentionally malformed key
30998.8. Intentionally Malformed DKIM-Signature Header Fields
3101 Verifiers MUST be prepared to receive messages with malformed DKIM-
3102 Signature header fields, and thoroughly verify the header field
3103 before depending on any of its contents.
31058.9. Information Leakage
3107 An attacker could determine when a particular signature was verified
3108 by using a per-message selector and then monitoring their DNS traffic
3109 for the key lookup. This would act as the equivalent of a "web bug"
3110 for verification time rather than when the message was read.
31128.10. Remote Timing Attacks
3114 In some cases, it may be possible to extract private keys using a
3115 remote timing attack [BONEH03]. Implementations should consider
3116 obfuscating the timing to prevent such attacks.
31188.11. Reordered Header Fields
3120 Existing standards allow intermediate MTAs to reorder header fields.
3121 If a signer signs two or more header fields of the same name, this
3122 can cause spurious verification errors on otherwise legitimate
3123 messages. In particular, signers that sign any existing DKIM-
3124 Signature fields run the risk of having messages incorrectly fail to
3129 An attacker could create a large RSA signing key with a small
3130 exponent, thus requiring that the verification key have a large
3131 exponent. This will force verifiers to use considerable computing
3132 resources to verify the signature. Verifiers might avoid this attack
3133 by refusing to verify signatures that reference selectors with public
3134 keys having unreasonable exponents.
3138Allman, et al. Standards Track [Page 56]
3140RFC 4871 DKIM Signatures May 2007
3143 In general, an attacker might try to overwhelm a verifier by flooding
3144 it with messages requiring verification. This is similar to other
3145 MTA denial-of-service attacks and should be dealt with in a similar
31488.13. Inappropriate Signing by Parent Domains
3150 The trust relationship described in Section 3.8 could conceivably be
3151 used by a parent domain to sign messages with identities in a
3152 subdomain not administratively related to the parent. For example,
3153 the ".com" registry could create messages with signatures using an
3154 "i=" value in the example.com domain. There is no general solution
3155 to this problem, since the administrative cut could occur anywhere in
3156 the domain name. For example, in the domain "example.podunk.ca.us"
3157 there are three administrative cuts (podunk.ca.us, ca.us, and us),
3158 any of which could create messages with an identity in the full
3161 INFORMATIVE NOTE: This is considered an acceptable risk for the
3162 same reason that it is acceptable for domain delegation. For
3163 example, in the example above any of the domains could potentially
3164 simply delegate "example.podunk.ca.us" to a server of their choice
3165 and completely replace all DNS-served information. Note that a
3166 verifier MAY ignore signatures that come from an unlikely domain
3167 such as ".com", as discussed in Section 6.1.1.
31719.1. Normative References
3173 [FIPS.180-2.2002] U.S. Department of Commerce, "Secure Hash
3174 Standard", FIPS PUB 180-2, August 2002.
3176 [ITU.X660.1997] "Information Technology - ASN.1 encoding rules:
3177 Specification of Basic Encoding Rules (BER),
3178 Canonical Encoding Rules (CER) and Distinguished
3179 Encoding Rules (DER)", ITU-T Recommendation X.660,
3182 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose
3183 Internet Mail Extensions (MIME) Part One: Format
3184 of Internet Message Bodies", RFC 2045,
3187 [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail
3188 Extensions) Part Three: Message header field
3189 Extensions for Non-ASCII Text", RFC 2047,
3194Allman, et al. Standards Track [Page 57]
3196RFC 4871 DKIM Signatures May 2007
3199 [RFC2119] Bradner, S., "Key words for use in RFCs to
3200 Indicate Requirement Levels", BCP 14, RFC 2119,
3203 [RFC2821] Klensin, J., "Simple Mail Transfer Protocol",
3204 RFC 2821, April 2001.
3206 [RFC2822] Resnick, P., "Internet Message Format", RFC 2822,
3209 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key
3210 Cryptography Standards (PKCS) #1: RSA Cryptography
3211 Specifications Version 2.1", RFC 3447,
3214 [RFC3490] Faltstrom, P., Hoffman, P., and A. Costello,
3215 "Internationalizing Domain Names in Applications
3216 (IDNA)", RFC 3490, March 2003.
3218 [RFC4234] Crocker, D., Ed. and P. Overell, "Augmented BNF
3219 for Syntax Specifications: ABNF", RFC 4234,
32229.2. Informative References
3224 [BONEH03] Proc. 12th USENIX Security Symposium, "Remote
3225 Timing Attacks are Practical", 2003.
3227 [RFC1847] Galvin, J., Murphy, S., Crocker, S., and N. Freed,
3228 "Security Multiparts for MIME: Multipart/Signed
3229 and Multipart/Encrypted", RFC 1847, October 1995.
3231 [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for
3232 Writing an IANA Considerations Section in RFCs",
3233 BCP 26, RFC 2434, October 1998.
3235 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R.
3236 Thayer, "OpenPGP Message Format", RFC 2440,
3239 [RFC3766] Orman, H. and P. Hoffman, "Determining Strengths
3240 for Public Keys Used For Exchanging Symmetric
3241 Keys", RFC 3766, April 2004.
3243 [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the
3244 Domain Name System (DNS)", RFC 3833, August 2004.
3250Allman, et al. Standards Track [Page 58]
3252RFC 4871 DKIM Signatures May 2007
3255 [RFC3851] Ramsdell, B., "S/MIME Version 3 Message
3256 Specification", RFC 3851, June 1999.
3258 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul,
3259 "Registration Procedures for Message Header
3260 Fields", BCP 90, September 2004.
3262 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D.,
3263 and S. Rose, "DNS Security Introduction and
3264 Requirements", RFC 4033, March 2005.
3266 [RFC4686] Fenton, J., "Analysis of Threats Motivating
3267 DomainKeys Identified Mail (DKIM)", RFC 4686,
3270 [RFC4870] Delany, M., "Domain-Based Email Authentication
3271 Using Public Keys Advertised in the DNS
3272 (DomainKeys)", RFC 4870, May 2007.
3306Allman, et al. Standards Track [Page 59]
3308RFC 4871 DKIM Signatures May 2007
3311Appendix A. Example of Use (INFORMATIVE)
3313 This section shows the complete flow of an email from submission to
3314 final delivery, demonstrating how the various components fit
3315 together. The key used in this example is shown in Appendix C.
3317A.1. The User Composes an Email
3320 From: Joe SixPack <joe@football.example.com>
3321 To: Suzie Q <suzie@shopping.example.net>
3322 Subject: Is dinner ready?
3323 Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT)
3324 Message-ID: <20030712040037.46341.5F8J@football.example.com>
3328 We lost the game. Are you hungry yet?
3362Allman, et al. Standards Track [Page 60]
3364RFC 4871 DKIM Signatures May 2007
3367A.2. The Email Is Signed
3369 This email is signed by the example.com outbound email server and now
3372 DKIM-Signature: v=1; a=rsa-sha256; s=brisbane; d=example.com;
3373 c=simple/simple; q=dns/txt; i=joe@football.example.com;
3374 h=Received : From : To : Subject : Date : Message-ID;
3375 bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
3376 b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB
3377 4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHut
3378 KVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV
3380 Received: from client1.football.example.com [192.0.2.1]
3381 by submitserver.example.com with SUBMISSION;
3382 Fri, 11 Jul 2003 21:01:54 -0700 (PDT)
3383 From: Joe SixPack <joe@football.example.com>
3384 To: Suzie Q <suzie@shopping.example.net>
3385 Subject: Is dinner ready?
3386 Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT)
3387 Message-ID: <20030712040037.46341.5F8J@football.example.com>
3391 We lost the game. Are you hungry yet?
3395 The signing email server requires access to the private key
3396 associated with the "brisbane" selector to generate this signature.
3398A.3. The Email Signature Is Verified
3400 The signature is normally verified by an inbound SMTP server or
3401 possibly the final delivery agent. However, intervening MTAs can
3402 also perform this verification if they choose to do so. The
3403 verification process uses the domain "example.com" extracted from the
3404 "d=" tag and the selector "brisbane" from the "s=" tag in the DKIM-
3405 Signature header field to form the DNS DKIM query for:
3407 brisbane._domainkey.example.com
3409 Signature verification starts with the physically last Received
3410 header field, the From header field, and so forth, in the order
3411 listed in the "h=" tag. Verification follows with a single CRLF
3412 followed by the body (starting with "Hi."). The email is canonically
3413 prepared for verifying with the "simple" method. The result of the
3414 query and subsequent verification of the signature is stored (in this
3418Allman, et al. Standards Track [Page 61]
3420RFC 4871 DKIM Signatures May 2007
3423 example) in the X-Authentication-Results header field line. After
3424 successful verification, the email looks like this:
3426 X-Authentication-Results: shopping.example.net
3427 header.from=joe@football.example.com; dkim=pass
3428 Received: from mout23.football.example.com (192.168.1.1)
3429 by shopping.example.net with SMTP;
3430 Fri, 11 Jul 2003 21:01:59 -0700 (PDT)
3431 DKIM-Signature: v=1; a=rsa-sha256; s=brisbane; d=example.com;
3432 c=simple/simple; q=dns/txt; i=joe@football.example.com;
3433 h=Received : From : To : Subject : Date : Message-ID;
3434 bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
3435 b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB
3436 4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHut
3437 KVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV
3439 Received: from client1.football.example.com [192.0.2.1]
3440 by submitserver.example.com with SUBMISSION;
3441 Fri, 11 Jul 2003 21:01:54 -0700 (PDT)
3442 From: Joe SixPack <joe@football.example.com>
3443 To: Suzie Q <suzie@shopping.example.net>
3444 Subject: Is dinner ready?
3445 Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT)
3446 Message-ID: <20030712040037.46341.5F8J@football.example.com>
3450 We lost the game. Are you hungry yet?
3454Appendix B. Usage Examples (INFORMATIVE)
3456 DKIM signing and validating can be used in different ways, for
3457 different operational scenarios. This Appendix discusses some common
3460 NOTE: Descriptions in this Appendix are for informational purposes
3461 only. They describe various ways that DKIM can be used, given
3462 particular constraints and needs. In no case are these examples
3463 intended to be taken as providing explanation or guidance
3464 concerning DKIM specification details, when creating an
3474Allman, et al. Standards Track [Page 62]
3476RFC 4871 DKIM Signatures May 2007
3479B.1. Alternate Submission Scenarios
3481 In the most simple scenario, a user's MUA, MSA, and Internet
3482 (boundary) MTA are all within the same administrative environment,
3483 using the same domain name. Therefore, all of the components
3484 involved in submission and initial transfer are related. However, it
3485 is common for two or more of the components to be under independent
3486 administrative control. This creates challenges for choosing and
3487 administering the domain name to use for signing, and for its
3488 relationship to common email identity header fields.
3490B.1.1. Delegated Business Functions
3492 Some organizations assign specific business functions to discrete
3493 groups, inside or outside the organization. The goal, then, is to
3494 authorize that group to sign some mail, but to constrain what
3495 signatures they can generate. DKIM selectors (the "s=" signature
3496 tag) and granularity (the "g=" key tag) facilitate this kind of
3497 restricted authorization. Examples of these outsourced business
3498 functions are legitimate email marketing providers and corporate
3501 Here, the delegated group needs to be able to send messages that are
3502 signed, using the email domain of the client company. At the same
3503 time, the client often is reluctant to register a key for the
3504 provider that grants the ability to send messages for arbitrary
3505 addresses in the domain.
3507 There are multiple ways to administer these usage scenarios. In one
3508 case, the client organization provides all of the public query
3509 service (for example, DNS) administration, and in another it uses DNS
3510 delegation to enable all ongoing administration of the DKIM key
3511 record by the delegated group.
3513 If the client organization retains responsibility for all of the DNS
3514 administration, the outsourcing company can generate a key pair,
3515 supplying the public key to the client company, which then registers
3516 it in the query service, using a unique selector that authorizes a
3517 specific From header field Local-part. For example, a client with
3518 the domain "example.com" could have the selector record specify
3519 "g=winter-promotions" so that this signature is only valid for mail
3520 with a From address of "winter-promotions@example.com". This would
3521 enable the provider to send messages using that specific address and
3522 have them verify properly. The client company retains control over
3523 the email address because it retains the ability to revoke the key at
3530Allman, et al. Standards Track [Page 63]
3532RFC 4871 DKIM Signatures May 2007
3535 If the client wants the delegated group to do the DNS administration,
3536 it can have the domain name that is specified with the selector point
3537 to the provider's DNS server. The provider then creates and
3538 maintains all of the DKIM signature information for that selector.
3539 Hence, the client cannot provide constraints on the Local-part of
3540 addresses that get signed, but it can revoke the provider's signing
3541 rights by removing the DNS delegation record.
3543B.1.2. PDAs and Similar Devices
3545 PDAs demonstrate the need for using multiple keys per domain.
3546 Suppose that John Doe wanted to be able to send messages using his
3547 corporate email address, jdoe@example.com, and his email device did
3548 not have the ability to make a Virtual Private Network (VPN)
3549 connection to the corporate network, either because the device is
3550 limited or because there are restrictions enforced by his Internet
3551 access provider. If the device was equipped with a private key
3552 registered for jdoe@example.com by the administrator of the
3553 example.com domain, and appropriate software to sign messages, John
3554 could sign the message on the device itself before transmission
3555 through the outgoing network of the access service provider.
3559 Roaming users often find themselves in circumstances where it is
3560 convenient or necessary to use an SMTP server other than their home
3561 server; examples are conferences and many hotels. In such
3562 circumstances, a signature that is added by the submission service
3563 will use an identity that is different from the user's home system.
3565 Ideally, roaming users would connect back to their home server using
3566 either a VPN or a SUBMISSION server running with SMTP AUTHentication
3567 on port 587. If the signing can be performed on the roaming user's
3568 laptop, then they can sign before submission, although the risk of
3569 further modification is high. If neither of these are possible,
3570 these roaming users will not be able to send mail signed using their
3573B.1.4. Independent (Kiosk) Message Submission
3575 Stand-alone services, such as walk-up kiosks and web-based
3576 information services, have no enduring email service relationship
3577 with the user, but users occasionally request that mail be sent on
3578 their behalf. For example, a website providing news often allows the
3579 reader to forward a copy of the article to a friend. This is
3580 typically done using the reader's own email address, to indicate who
3581 the author is. This is sometimes referred to as the "Evite problem",
3586Allman, et al. Standards Track [Page 64]
3588RFC 4871 DKIM Signatures May 2007
3591 named after the website of the same name that allows a user to send
3592 invitations to friends.
3594 A common way this is handled is to continue to put the reader's email
3595 address in the From header field of the message, but put an address
3596 owned by the email posting site into the Sender header field. The
3597 posting site can then sign the message, using the domain that is in
3598 the Sender field. This provides useful information to the receiving
3599 email site, which is able to correlate the signing domain with the
3600 initial submission email role.
3602 Receiving sites often wish to provide their end users with
3603 information about mail that is mediated in this fashion. Although
3604 the real efficacy of different approaches is a subject for human
3605 factors usability research, one technique that is used is for the
3606 verifying system to rewrite the From header field, to indicate the
3607 address that was verified. For example: From: John Doe via
3608 news@news-site.com <jdoe@example.com>. (Note that such rewriting
3609 will break a signature, unless it is done after the verification pass
3612B.2. Alternate Delivery Scenarios
3614 Email is often received at a mailbox that has an address different
3615 from the one used during initial submission. In these cases, an
3616 intermediary mechanism operates at the address originally used and it
3617 then passes the message on to the final destination. This mediation
3618 process presents some challenges for DKIM signatures.
3620B.2.1. Affinity Addresses
3622 "Affinity addresses" allow a user to have an email address that
3623 remains stable, even as the user moves among different email
3624 providers. They are typically associated with college alumni
3625 associations, professional organizations, and recreational
3626 organizations with which they expect to have a long-term
3627 relationship. These domains usually provide forwarding of incoming
3628 email, and they often have an associated Web application that
3629 authenticates the user and allows the forwarding address to be
3630 changed. However, these services usually depend on users sending
3631 outgoing messages through their own service providers' MTAs. Hence,
3632 mail that is signed with the domain of the affinity address is not
3633 signed by an entity that is administered by the organization owning
3636 With DKIM, affinity domains could use the Web application to allow
3637 users to register per-user keys to be used to sign messages on behalf
3638 of their affinity address. The user would take away the secret half
3642Allman, et al. Standards Track [Page 65]
3644RFC 4871 DKIM Signatures May 2007
3647 of the key pair for signing, and the affinity domain would publish
3648 the public half in DNS for access by verifiers.
3650 This is another application that takes advantage of user-level
3651 keying, and domains used for affinity addresses would typically have
3652 a very large number of user-level keys. Alternatively, the affinity
3653 domain could handle outgoing mail, operating a mail submission agent
3654 that authenticates users before accepting and signing messages for
3655 them. This is of course dependent on the user's service provider not
3656 blocking the relevant TCP ports used for mail submission.
3658B.2.2. Simple Address Aliasing (.forward)
3660 In some cases, a recipient is allowed to configure an email address
3661 to cause automatic redirection of email messages from the original
3662 address to another, such as through the use of a Unix .forward file.
3663 In this case, messages are typically redirected by the mail handling
3664 service of the recipient's domain, without modification, except for
3665 the addition of a Received header field to the message and a change
3666 in the envelope recipient address. In this case, the recipient at
3667 the final address' mailbox is likely to be able to verify the
3668 original signature since the signed content has not changed, and DKIM
3669 is able to validate the message signature.
3671B.2.3. Mailing Lists and Re-Posters
3673 There is a wide range of behaviors in services that take delivery of
3674 a message and then resubmit it. A primary example is with mailing
3675 lists (collectively called "forwarders" below), ranging from those
3676 that make no modification to the message itself, other than to add a
3677 Received header field and change the envelope information, to those
3678 that add header fields, change the Subject header field, add content
3679 to the body (typically at the end), or reformat the body in some
3680 manner. The simple ones produce messages that are quite similar to
3681 the automated alias services. More elaborate systems essentially
3682 create a new message.
3684 A Forwarder that does not modify the body or signed header fields of
3685 a message is likely to maintain the validity of the existing
3686 signature. It also could choose to add its own signature to the
3689 Forwarders which modify a message in a way that could make an
3690 existing signature invalid are particularly good candidates for
3691 adding their own signatures (e.g., mailing-list-name@example.net).
3692 Since (re-)signing is taking responsibility for the content of the
3693 message, these signing forwarders are likely to be selective, and
3694 forward or re-sign a message only if it is received with a valid
3698Allman, et al. Standards Track [Page 66]
3700RFC 4871 DKIM Signatures May 2007
3703 signature or if they have some other basis for knowing that the
3704 message is not spoofed.
3706 A common practice among systems that are primarily redistributors of
3707 mail is to add a Sender header field to the message, to identify the
3708 address being used to sign the message. This practice will remove
3709 any preexisting Sender header field as required by [RFC2822]. The
3710 forwarder applies a new DKIM-Signature header field with the
3711 signature, public key, and related information of the forwarder.
3713Appendix C. Creating a Public Key (INFORMATIVE)
3715 The default signature is an RSA signed SHA256 digest of the complete
3716 email. For ease of explanation, the openssl command is used to
3717 describe the mechanism by which keys and signatures are managed. One
3718 way to generate a 1024-bit, unencrypted private key suitable for DKIM
3719 is to use openssl like this:
3721 $ openssl genrsa -out rsa.private 1024
3723 For increased security, the "-passin" parameter can also be added to
3724 encrypt the private key. Use of this parameter will require entering
3725 a password for several of the following steps. Servers may prefer to
3726 use hardware cryptographic support.
3728 The "genrsa" step results in the file rsa.private containing the key
3729 information similar to this:
3731 -----BEGIN RSA PRIVATE KEY-----
3732 MIICXwIBAAKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYtIxN2SnFC
3733 jxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/RtdC2UzJ1lWT947qR+Rcac2gb
3734 to/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB
3735 AoGBALmn+XwWk7akvkUlqb+dOxyLB9i5VBVfje89Teolwc9YJT36BGN/l4e0l6QX
3736 /1//6DWUTB3KI6wFcm7TWJcxbS0tcKZX7FsJvUz1SbQnkS54DJck1EZO/BLa5ckJ
3737 gAYIaqlA9C0ZwM6i58lLlPadX/rtHb7pWzeNcZHjKrjM461ZAkEA+itss2nRlmyO
3738 n1/5yDyCluST4dQfO8kAB3toSEVc7DeFeDhnC1mZdjASZNvdHS4gbLIA1hUGEF9m
3739 3hKsGUMMPwJBAPW5v/U+AWTADFCS22t72NUurgzeAbzb1HWMqO4y4+9Hpjk5wvL/
3740 eVYizyuce3/fGke7aRYw/ADKygMJdW8H/OcCQQDz5OQb4j2QDpPZc0Nc4QlbvMsj
3741 7p7otWRO5xRa6SzXqqV3+F0VpqvDmshEBkoCydaYwc2o6WQ5EBmExeV8124XAkEA
3742 qZzGsIxVP+sEVRWZmW6KNFSdVUpk3qzK0Tz/WjQMe5z0UunY9Ax9/4PVhp/j61bf
3743 eAYXunajbBSOLlx4D+TunwJBANkPI5S9iylsbLs6NkaMHV6k5ioHBBmgCak95JGX
3744 GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc=
3745 -----END RSA PRIVATE KEY-----
3747 To extract the public-key component from the private key, use openssl
3750 $ openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM
3754Allman, et al. Standards Track [Page 67]
3756RFC 4871 DKIM Signatures May 2007
3759 This results in the file rsa.public containing the key information
3762 -----BEGIN PUBLIC KEY-----
3763 MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkM
3764 oGeLnQg1fWn7/zYtIxN2SnFCjxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/R
3765 tdC2UzJ1lWT947qR+Rcac2gbto/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToI
3766 MmPSPDdQPNUYckcQ2QIDAQAB
3767 -----END PUBLIC KEY-----
3769 This public-key data (without the BEGIN and END tags) is placed in
3772 brisbane IN TXT ("v=DKIM1; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ"
3773 "KBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYt"
3774 "IxN2SnFCjxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v"
3775 "/RtdC2UzJ1lWT947qR+Rcac2gbto/NMqJ0fzfVjH4OuKhi"
3776 "tdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB")
3778Appendix D. MUA Considerations
3780 When a DKIM signature is verified, the processing system sometimes
3781 makes the result available to the recipient user's MUA. How to
3782 present this information to the user in a way that helps them is a
3783 matter of continuing human factors usability research. The tendency
3784 is to have the MUA highlight the address associated with this signing
3785 identity in some way, in an attempt to show the user the address from
3786 which the mail was sent. An MUA might do this with visual cues such
3787 as graphics, or it might include the address in an alternate view, or
3788 it might even rewrite the original From address using the verified
3789 information. Some MUAs might indicate which header fields were
3790 protected by the validated DKIM signature. This could be done with a
3791 positive indication on the signed header fields, with a negative
3792 indication on the unsigned header fields, by visually hiding the
3793 unsigned header fields, or some combination of these. If an MUA uses
3794 visual indications for signed header fields, the MUA probably needs
3795 to be careful not to display unsigned header fields in a way that
3796 might be construed by the end user as having been signed. If the
3797 message has an l= tag whose value does not extend to the end of the
3798 message, the MUA might also hide or mark the portion of the message
3799 body that was not signed.
3801 The aforementioned information is not intended to be exhaustive. The
3802 MUA may choose to highlight, accentuate, hide, or otherwise display
3803 any other information that may, in the opinion of the MUA author, be
3804 deemed important to the end user.
3810Allman, et al. Standards Track [Page 68]
3812RFC 4871 DKIM Signatures May 2007
3815Appendix E. Acknowledgements
3817 The authors wish to thank Russ Allbery, Edwin Aoki, Claus Assmann,
3818 Steve Atkins, Rob Austein, Fred Baker, Mark Baugher, Steve Bellovin,
3819 Nathaniel Borenstein, Dave Crocker, Michael Cudahy, Dennis Dayman,
3820 Jutta Degener, Frank Ellermann, Patrik Faeltstroem, Mark Fanto,
3821 Stephen Farrell, Duncan Findlay, Elliot Gillum, Olafur
3822 Gu[eth]mundsson, Phillip Hallam-Baker, Tony Hansen, Sam Hartman,
3823 Arvel Hathcock, Amir Herzberg, Paul Hoffman, Russ Housley, Craig
3824 Hughes, Cullen Jennings, Don Johnsen, Harry Katz, Murray S.
3825 Kucherawy, Barry Leiba, John Levine, Charles Lindsey, Simon
3826 Longsdale, David Margrave, Justin Mason, David Mayne, Thierry Moreau,
3827 Steve Murphy, Russell Nelson, Dave Oran, Doug Otis, Shamim Pirzada,
3828 Juan Altmayer Pizzorno, Sanjay Pol, Blake Ramsdell, Christian Renaud,
3829 Scott Renfro, Neil Rerup, Eric Rescorla, Dave Rossetti, Hector
3830 Santos, Jim Schaad, the Spamhaus.org team, Malte S. Stretz, Robert
3831 Sanders, Rand Wacker, Sam Weiler, and Dan Wing for their valuable
3832 suggestions and constructive criticism.
3834 The DomainKeys specification was a primary source from which this
3835 specification has been derived. Further information about DomainKeys
3842 6425 Christie Ave, Suite 400
3843 Emeryville, CA 94608
3846 Phone: +1 510 594 5501
3847 EMail: eric+dkim@sendmail.org
3857 Phone: +1 650 319 9016
3866Allman, et al. Standards Track [Page 69]
3868RFC 4871 DKIM Signatures May 2007
3877 Phone: +1 408 349 6831
3878 EMail: markd+dkim@yahoo-inc.com
3888 EMail: mlibbeymail-mailsig@yahoo.com
3896 San Jose, CA 95134-1706
3899 Phone: +1 408 526 5914
3900 EMail: fenton@cisco.com
3908 San Jose, CA 95134-1706
3910 Phone: +1 408 525 5386
3911 EMail: mat@cisco.com
3922Allman, et al. Standards Track [Page 70]
3924RFC 4871 DKIM Signatures May 2007
3927Full Copyright Statement
3929 Copyright (C) The IETF Trust (2007).
3931 This document is subject to the rights, licenses and restrictions
3932 contained in BCP 78, and except as set forth therein, the authors
3933 retain all their rights.
3935 This document and the information contained herein are provided on an
3936 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
3937 OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND
3938 THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS
3939 OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF
3940 THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
3941 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
3943Intellectual Property
3945 The IETF takes no position regarding the validity or scope of any
3946 Intellectual Property Rights or other rights that might be claimed to
3947 pertain to the implementation or use of the technology described in
3948 this document or the extent to which any license under such rights
3949 might or might not be available; nor does it represent that it has
3950 made any independent effort to identify any such rights. Information
3951 on the procedures with respect to rights in RFC documents can be
3952 found in BCP 78 and BCP 79.
3954 Copies of IPR disclosures made to the IETF Secretariat and any
3955 assurances of licenses to be made available, or the result of an
3956 attempt made to obtain a general license or permission for the use of
3957 such proprietary rights by implementers or users of this
3958 specification can be obtained from the IETF on-line IPR repository at
3959 http://www.ietf.org/ipr.
3961 The IETF invites any interested party to bring to its attention any
3962 copyrights, patents or patent applications, or other proprietary
3963 rights that may cover technology that may be required to implement
3964 this standard. Please address the information to the IETF at
3969 Funding for the RFC Editor function is currently provided by the
3978Allman, et al. Standards Track [Page 71]