idnits 2.17.1 draft-ietf-dkim-base-10.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** It looks like you're using RFC 3978 boilerplate. You should update this to the boilerplate described in the IETF Trust License Policy document (see https://trustee.ietf.org/license-info), which is required now. -- Found old boilerplate from RFC 3978, Section 5.1 on line 22. -- Found old boilerplate from RFC 3978, Section 5.5, updated by RFC 4748 on line 3625. -- Found old boilerplate from RFC 3979, Section 5, paragraph 1 on line 3636. -- Found old boilerplate from RFC 3979, Section 5, paragraph 2 on line 3643. -- Found old boilerplate from RFC 3979, Section 5, paragraph 3 on line 3649. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There is 1 instance of too long lines in the document, the longest one being 2 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust Copyright Line does not match the current year == Line 1265 has weird spacing: '... email elec...' -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (February 15, 2007) is 6277 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'ITU.X660.1997' is defined on line 2666, but no explicit reference was found in the text -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.X660.1997' ** Obsolete normative reference: RFC 2821 (Obsoleted by RFC 5321) ** Obsolete normative reference: RFC 2822 (Obsoleted by RFC 5322) ** Obsolete normative reference: RFC 3447 (Obsoleted by RFC 8017) ** Obsolete normative reference: RFC 3490 (Obsoleted by RFC 5890, RFC 5891) ** Obsolete normative reference: RFC 4234 (Obsoleted by RFC 5234) -- Obsolete informational reference (is this intentional?): RFC 2434 (Obsoleted by RFC 5226) -- Obsolete informational reference (is this intentional?): RFC 2440 (Obsoleted by RFC 4880) -- Obsolete informational reference (is this intentional?): RFC 3851 (Obsoleted by RFC 5751) Summary: 7 errors (**), 0 flaws (~~), 3 warnings (==), 12 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 DKIM E. Allman 3 Internet-Draft Sendmail, Inc. 4 Intended status: Standards Track J. Callas 5 Expires: August 19, 2007 PGP Corporation 6 M. Delany 7 M. Libbey 8 Yahoo! Inc 9 J. Fenton 10 M. Thomas 11 Cisco Systems, Inc. 12 February 15, 2007 14 DomainKeys Identified Mail (DKIM) Signatures 15 draft-ietf-dkim-base-10 17 Status of this Memo 19 By submitting this Internet-Draft, each author represents that any 20 applicable patent or other IPR claims of which he or she is aware 21 have been or will be disclosed, and any of which he or she becomes 22 aware will be disclosed, in accordance with Section 6 of BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF), its areas, and its working groups. Note that 26 other groups may also distribute working documents as Internet- 27 Drafts. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 The list of current Internet-Drafts can be accessed at 35 http://www.ietf.org/ietf/1id-abstracts.txt. 37 The list of Internet-Draft Shadow Directories can be accessed at 38 http://www.ietf.org/shadow.html. 40 This Internet-Draft will expire on August 19, 2007. 42 Copyright Notice 44 Copyright (C) The IETF Trust (2007). 46 Abstract 48 DomainKeys Identified Mail (DKIM) defines a domain-level 49 authentication framework for email using public-key cryptography and 50 key server technology to permit verification of the source and 51 contents of messages by either Mail Transfer Agents (MTAs) or Mail 52 User Agents (MUAs). The ultimate goal of this framework is to permit 53 a signing domain to assert responsibility for a message, thus 54 protecting message signer identity and the integrity of the messages 55 they convey while retaining the functionality of Internet email as it 56 is known today. Protection of email identity may assist in the 57 global control of "spam" and "phishing". 59 Requirements Language 61 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 62 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 63 document are to be interpreted as described in [RFC2119]. 65 Table of Contents 67 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 68 1.1. Signing Identity . . . . . . . . . . . . . . . . . . . . . 6 69 1.2. Scalability . . . . . . . . . . . . . . . . . . . . . . . 6 70 1.3. Simple Key Management . . . . . . . . . . . . . . . . . . 6 71 2. Terminology and Definitions . . . . . . . . . . . . . . . . . 6 72 2.1. Signers . . . . . . . . . . . . . . . . . . . . . . . . . 6 73 2.2. Verifiers . . . . . . . . . . . . . . . . . . . . . . . . 7 74 2.3. White Space . . . . . . . . . . . . . . . . . . . . . . . 7 75 2.4. Common ABNF Tokens . . . . . . . . . . . . . . . . . . . . 7 76 2.5. Imported ABNF Tokens . . . . . . . . . . . . . . . . . . . 7 77 2.6. DKIM-Quoted-Printable . . . . . . . . . . . . . . . . . . 8 78 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . . 9 79 3.1. Selectors . . . . . . . . . . . . . . . . . . . . . . . . 9 80 3.2. Tag=Value Lists . . . . . . . . . . . . . . . . . . . . . 11 81 3.3. Signing and Verification Algorithms . . . . . . . . . . . 12 82 3.4. Canonicalization . . . . . . . . . . . . . . . . . . . . . 14 83 3.5. The DKIM-Signature header field . . . . . . . . . . . . . 18 84 3.6. Key Management and Representation . . . . . . . . . . . . 26 85 3.7. Computing the Message Hashes . . . . . . . . . . . . . . . 30 86 3.8. Signing by Parent Domains . . . . . . . . . . . . . . . . 32 87 4. Semantics of Multiple Signatures . . . . . . . . . . . . . . . 33 88 4.1. Example Scenarios . . . . . . . . . . . . . . . . . . . . 33 89 4.2. Interpretation . . . . . . . . . . . . . . . . . . . . . . 34 90 5. Signer Actions . . . . . . . . . . . . . . . . . . . . . . . . 35 91 5.1. Determine if the Email Should be Signed and by Whom . . . 35 92 5.2. Select a Private Key and Corresponding Selector 93 Information . . . . . . . . . . . . . . . . . . . . . . . 36 94 5.3. Normalize the Message to Prevent Transport Conversions . . 36 95 5.4. Determine the Header Fields to Sign . . . . . . . . . . . 37 96 5.5. Recommended Signature Content . . . . . . . . . . . . . . 39 97 5.6. Compute the Message Hash and Signature . . . . . . . . . . 40 98 5.7. Insert the DKIM-Signature Header Field . . . . . . . . . . 41 99 6. Verifier Actions . . . . . . . . . . . . . . . . . . . . . . . 41 100 6.1. Extract Signatures from the Message . . . . . . . . . . . 42 101 6.2. Communicate Verification Results . . . . . . . . . . . . . 47 102 6.3. Interpret Results/Apply Local Policy . . . . . . . . . . . 48 103 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 49 104 7.1. DKIM-Signature Tag Specifications . . . . . . . . . . . . 49 105 7.2. DKIM-Signature Query Method Registry . . . . . . . . . . . 50 106 7.3. DKIM-Signature Canonicalization Registry . . . . . . . . . 50 107 7.4. _domainkey DNS TXT Record Tag Specifications . . . . . . . 51 108 7.5. DKIM Key Type Registry . . . . . . . . . . . . . . . . . . 52 109 7.6. DKIM Hash Algorithms Registry . . . . . . . . . . . . . . 52 110 7.7. DKIM Service Types Registry . . . . . . . . . . . . . . . 53 111 7.8. DKIM Selector Flags Registry . . . . . . . . . . . . . . . 53 112 7.9. DKIM-Signature Header Field . . . . . . . . . . . . . . . 54 113 8. Security Considerations . . . . . . . . . . . . . . . . . . . 54 114 8.1. Misuse of Body Length Limits ("l=" Tag) . . . . . . . . . 54 115 8.2. Misappropriated Private Key . . . . . . . . . . . . . . . 55 116 8.3. Key Server Denial-of-Service Attacks . . . . . . . . . . . 56 117 8.4. Attacks Against DNS . . . . . . . . . . . . . . . . . . . 56 118 8.5. Replay Attacks . . . . . . . . . . . . . . . . . . . . . . 57 119 8.6. Limits on Revoking Keys . . . . . . . . . . . . . . . . . 57 120 8.7. Intentionally malformed Key Records . . . . . . . . . . . 57 121 8.8. Intentionally Malformed DKIM-Signature header fields . . . 58 122 8.9. Information Leakage . . . . . . . . . . . . . . . . . . . 58 123 8.10. Remote Timing Attacks . . . . . . . . . . . . . . . . . . 58 124 8.11. Reordered Header Fields . . . . . . . . . . . . . . . . . 58 125 8.12. RSA Attacks . . . . . . . . . . . . . . . . . . . . . . . 58 126 8.13. Inappropriate Signing by Parent Domains . . . . . . . . . 58 127 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 59 128 9.1. Normative References . . . . . . . . . . . . . . . . . . . 59 129 9.2. Informative References . . . . . . . . . . . . . . . . . . 60 130 Appendix A. Example of Use (INFORMATIVE) . . . . . . . . . . . . 61 131 A.1. The user composes an email . . . . . . . . . . . . . . . . 61 132 A.2. The email is signed . . . . . . . . . . . . . . . . . . . 61 133 A.3. The email signature is verified . . . . . . . . . . . . . 62 134 Appendix B. Usage Examples (INFORMATIVE) . . . . . . . . . . . . 63 135 B.1. Alternate Submission Scenarios . . . . . . . . . . . . . . 64 136 B.2. Alternate Delivery Scenarios . . . . . . . . . . . . . . . 66 137 Appendix C. Creating a public key (INFORMATIVE) . . . . . . . . . 68 138 Appendix D. MUA Considerations . . . . . . . . . . . . . . . . . 70 139 Appendix E. Acknowledgements . . . . . . . . . . . . . . . . . . 70 140 Appendix F. Edit History . . . . . . . . . . . . . . . . . . . . 71 141 F.1. Changes since -ietf-09 version . . . . . . . . . . . . . . 71 142 F.2. Changes since -ietf-08 version . . . . . . . . . . . . . . 71 143 F.3. Changes since -ietf-07 version . . . . . . . . . . . . . . 72 144 F.4. Changes since -ietf-06 version . . . . . . . . . . . . . . 73 145 F.5. Changes since -ietf-05 version . . . . . . . . . . . . . . 74 146 F.6. Changes since -ietf-04 version . . . . . . . . . . . . . . 74 147 F.7. Changes since -ietf-03 version . . . . . . . . . . . . . . 75 148 F.8. Changes since -ietf-02 version . . . . . . . . . . . . . . 76 149 F.9. Changes since -ietf-01 version . . . . . . . . . . . . . . 77 150 F.10. Changes since -ietf-00 version . . . . . . . . . . . . . . 77 151 F.11. Changes since -allman-01 version . . . . . . . . . . . . . 78 152 F.12. Changes since -allman-00 version . . . . . . . . . . . . . 78 153 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 79 154 Intellectual Property and Copyright Statements . . . . . . . . . . 81 156 1. Introduction 158 [[Note: text in double square brackets (such as this text) will be 159 deleted before publication.]] 161 DomainKeys Identified Mail (DKIM) defines a mechanism by which email 162 messages can be cryptographically signed, permitting a signing domain 163 to claim responsibility for the introduction of a message into the 164 mail stream. Message recipients can verify the signature by querying 165 the signer's domain directly to retrieve the appropriate public key, 166 and thereby confirm that the message was attested to by a party in 167 possession of the private key for the signing domain. 169 The approach taken by DKIM differs from previous approaches to 170 message signing (e.g. S/MIME [RFC1847], OpenPGP [RFC2440]) in that: 172 o the message signature is written as a message header field so that 173 neither human recipients nor existing MUA (Mail User Agent) 174 software are confused by signature-related content appearing in 175 the message body; 177 o there is no dependency on public and private key pairs being 178 issued by well-known, trusted certificate authorities; 180 o there is no dependency on the deployment of any new Internet 181 protocols or services for public key distribution or revocation; 183 o signature verification failure does not force rejection of the 184 message; 186 o no attempt is made to include encryption as part of the mechanism; 188 o message archiving is not a design goal. 190 DKIM: 192 o is compatible with the existing email infrastructure and 193 transparent to the fullest extent possible; 195 o requires minimal new infrastructure; 197 o can be implemented independently of clients in order to reduce 198 deployment time; 200 o can be deployed incrementally; 202 o allows delegation of signing to third parties. 204 1.1. Signing Identity 206 DKIM separates the question of the identity of the signer of the 207 message from the purported author of the message. In particular, a 208 signature includes the identity of the signer. Verifiers can use the 209 signing information to decide how they want to process the message. 210 The signing identity is included as part of the signature header 211 field. 213 INFORMATIVE RATIONALE: The signing identity specified by a DKIM 214 signature is not required to match an address in any particular 215 header field because of the broad methods of interpretation by 216 recipient mail systems, including MUAs. 218 1.2. Scalability 220 DKIM is designed to support the extreme scalability requirements 221 which characterize the email identification problem. There are 222 currently over 70 million domains and a much larger number of 223 individual addresses. DKIM seeks to preserve the positive aspects of 224 the current email infrastructure, such as the ability for anyone to 225 communicate with anyone else without introduction. 227 1.3. Simple Key Management 229 DKIM differs from traditional hierarchical public-key systems in that 230 no Certificate Authority infrastructure is required; the verifier 231 requests the public key from a repository in the domain of the 232 claimed signer directly rather than from a third party. 234 The DNS is proposed as the initial mechanism for the public keys. 235 Thus, DKIM currently depends on DNS administration and the security 236 of the DNS system. DKIM is designed to be extensible to other key 237 fetching services as they become available. 239 2. Terminology and Definitions 241 This section defines terms used in the rest of the document. Syntax 242 descriptions use the form described in Augmented BNF for Syntax 243 Specifications [RFC4234]. 245 2.1. Signers 247 Elements in the mail system that sign messages on behalf of a domain 248 are referred to as signers. These may be MUAs (Mail User Agents), 249 MSAs (Mail Submission Agents), MTAs (Mail Transfer Agents), or other 250 agents such as mailing list exploders. In general any signer will be 251 involved in the injection of a message into the message system in 252 some way. The key issue is that a message must be signed before it 253 leaves the administrative domain of the signer. 255 2.2. Verifiers 257 Elements in the mail system that verify signatures are referred to as 258 verifiers. These may be MTAs, Mail Delivery Agents (MDAs), or MUAs. 259 In most cases it is expected that verifiers will be close to an end 260 user (reader) of the message or some consuming agent such as a 261 mailing list exploder. 263 2.3. White Space 265 There are three forms of white space: 267 o WSP represents simple white space, i.e., a space or a tab 268 character (formal definition in [RFC4234]). 270 o LWSP is linear white space, defined as WSP plus CRLF (formal 271 definition in [RFC4234]). 273 o FWS is folding white space. It allows multiple lines separated by 274 CRLF followed by at least one white space, to be joined. 276 The formal ABNF for these are (WSP and LWSP are given for information 277 only): 278 WSP = SP / HTAB 279 LWSP = *(WSP / CRLF WSP) 280 FWS = [*WSP CRLF] 1*WSP 282 The definition of FWS is identical to that in [RFC2822] except for 283 the exclusion of obs-FWS. 285 2.4. Common ABNF Tokens 287 The following ABNF tokens are used elsewhere in this document. 288 hyphenated-word = ALPHA [ *(ALPHA / DIGIT / "-") (ALPHA / DIGIT) ] 289 base64string = 1*(ALPHA / DIGIT / "+" / "/" / LWSP) 290 [ "=" LWSP [ "=" LWSP ] ] 292 2.5. Imported ABNF Tokens 294 The following tokens are imported from other RFCs as noted. Those 295 RFCs should be considered definitive. 297 The following tokens are imported from [RFC2821]: 299 o "Local-part" (implementation warning: this permits quoted 300 strings) 302 o "sub-domain" 304 The following tokens are imported from [RFC2822]: 306 o "field-name" (name of a header field) 308 o "dot-atom-text" (in the local-part of an email address) 310 The following tokens are imported from [RFC2045]: 312 o "qp-section" (a single line of quoted-printable-encoded text) 314 o "hex-octet" (a quoted-printable encoded octet) 316 INFORMATIVE NOTE: Be aware that the ABNF in RFC 2045 does not 317 obey the rules of RFC 4234 and must be interpreted accordingly, 318 particularly as regards case folding. 320 Other tokens not defined herein are imported from [RFC4234]. These 321 are intuitive primitives such as SP, HTAB, WSP, ALPHA, DIGIT, CRLF, 322 etc. 324 2.6. DKIM-Quoted-Printable 326 The DKIM-Quoted-Printable encoding syntax resembles that described in 327 Quoted-Printable [RFC2045] section 6.7: any character MAY be encoded 328 as an "=" followed by two hexadecimal digits from the alphabet 329 "0123456789ABCDEF" (no lower case characters permitted) representing 330 the hexadecimal-encoded integer value of that character. All control 331 characters (those with values < %x20), eight-bit characters (values > 332 %x7F), and the characters DEL (%x7F), SPACE (%x20), and semicolon 333 (";", %x3B) MUST be encoded. Note that all white space, including 334 SPACE, CR and LF characters, MUST be encoded. After encoding, FWS 335 MAY be added at arbitrary locations in order to avoid excessively 336 long lines; such white space is NOT part of the value, and MUST be 337 removed before decoding. 339 ABNF: 340 dkim-quoted-printable = 341 *(FWS / hex-octet / dkim-safe-char) 342 ; hex-octet is from RFC 2045 343 dkim-safe-char = %x21-3A / %x3C / %x3E-7E 344 ; '!' - ':', '<', '>' - '~' 345 ; Characters not listed as "mail-safe" in 346 ; RFC 2049 are also not recommended. 348 INFORMATIVE NOTE: DKIM-Quoted-Printable differs from Quoted- 349 Printable as defined in RFC 2045 in several important ways: 351 1. White space in the input text, including CR and LF, must be 352 encoded. RFC 2045 does not require such encoding, and does 353 not permit encoding of CR or LF characters that are part of a 354 CRLF line break. 356 2. White space in the encoded text is ignored. This is to allow 357 tags encoded using DKIM-Quoted-Printable to be wrapped as 358 needed. In particular, RFC 2045 requires that line breaks in 359 the input be represented as physical line breaks; that is not 360 the case here. 362 3. The "soft line break" syntax ("=" as the last non-white-space 363 character on the line) does not apply. 365 4. DKIM-Quoted-Printable does not require that encoded lines be 366 no more than 76 characters long (although there may be other 367 requirements depending on the context in which the encoded 368 text is being used). 370 3. Protocol Elements 372 Protocol Elements are conceptual parts of the protocol that are not 373 specific to either signers or verifiers. The protocol descriptions 374 for signers and verifiers are described in later sections (Signer 375 Actions (Section 5) and Verifier Actions (Section 6)). NOTE: This 376 section must be read in the context of those sections. 378 3.1. Selectors 380 To support multiple concurrent public keys per signing domain, the 381 key namespace is subdivided using "Selectors". For example, 382 Selectors might indicate the names of office locations (e.g., 383 "sanfrancisco", "coolumbeach", and "reykjavik"), the signing date 384 (e.g., "january2005", "february2005", etc.), or even the individual 385 user. 387 Selectors are needed to support some important use cases. For 388 example: 390 o Domains which want to delegate signing capability for a specific 391 address for a given duration to a partner, such as an advertising 392 provider or other out-sourced function. 394 o Domains which want to allow frequent travelers to send messages 395 locally without the need to connect with a particular MSA. 397 o "Affinity" domains (e.g., college alumni associations) which 398 provide forwarding of incoming mail but which do not operate a 399 mail submission agent for outgoing mail. 401 Periods are allowed in Selectors and are component separators. When 402 keys are retrieved from the DNS, periods in Selectors define DNS 403 label boundaries in a manner similar to the conventional use in 404 domain names. Selector components might be used to combine dates 405 with locations; for example, "march2005.reykjavik". In a DNS 406 implementation, this can be used to allow delegation of a portion of 407 the Selector name-space. 409 ABNF: 410 selector = sub-domain *( "." sub-domain ) 412 The number of public keys and corresponding Selectors for each domain 413 are determined by the domain owner. Many domain owners will be 414 satisfied with just one Selector whereas administratively distributed 415 organizations may choose to manage disparate Selectors and key pairs 416 in different regions or on different email servers. 418 Beyond administrative convenience, Selectors make it possible to 419 seamlessly replace public keys on a routine basis. If a domain 420 wishes to change from using a public key associated with Selector 421 "january2005" to a public key associated with Selector 422 "february2005", it merely makes sure that both public keys are 423 advertised in the public-key repository concurrently for the 424 transition period during which email may be in transit prior to 425 verification. At the start of the transition period, the outbound 426 email servers are configured to sign with the "february2005" private 427 key. At the end of the transition period, the "january2005" public 428 key is removed from the public-key repository. 430 INFORMATIVE NOTE: A key may also be revoked as described below. 431 The distinction between revoking and removing a key selector 432 record is subtle. When phasing out keys as described above, a 433 signing domain would probably simply remove the key record after 434 the transition period. However, a signing domain could elect to 435 revoke the key (but maintain the key record) for a further period. 436 There is no defined semantic difference between a revoked key and 437 a removed key. 439 While some domains may wish to make Selector values well known, 440 others will want to take care not to allocate Selector names in a way 441 that allows harvesting of data by outside parties. For example, if 442 per-user keys are issued, the domain owner will need to make the 443 decision as to whether to associate this Selector directly with the 444 user name, or make it some unassociated random value, such as a 445 fingerprint of the public key. 447 INFORMATIVE OPERATIONS NOTE: Reusing a Selector with a new key 448 (for example, changing the key associated with a user's name) 449 makes it impossible to tell the difference between a message that 450 didn't verify because the key is no longer valid versus a message 451 that is actually forged. For this reason, signers are ill-advised 452 to reuse selectors for new keys. A better strategy is to assign 453 new keys to new selectors. 455 3.2. Tag=Value Lists 457 DKIM uses a simple "tag=value" syntax in several contexts, including 458 in messages and domain signature records. 460 Values are a series of strings containing either plain text, "base64" 461 text (as defined in [RFC2045], section 6.8), "qp-section" (ibid, 462 section 6.7), or "dkim-quoted-printable" (as defined in Section 2.6). 463 The name of the tag will determine the encoding of each value. 464 Unencoded semicolon (";") characters MUST NOT occur in the tag value, 465 since that separates tag-specs. 467 INFORMATIVE IMPLEMENTATION NOTE: Although the "plain text" 468 defined below (as "tag-value") only includes 7-bit characters, an 469 implementation that wished to anticipate future standards would be 470 advised to not preclude the use of UTF8-encoded text in tag=value 471 lists. 473 Formally, the syntax rules are: 474 tag-list = tag-spec 0*( ";" tag-spec ) [ ";" ] 475 tag-spec = [FWS] tag-name [FWS] "=" [FWS] tag-value [FWS] 476 tag-name = ALPHA 0*ALNUMPUNC 477 tag-value = [ tval 0*( 1*(WSP / FWS) tval ) ] 478 ; WSP and FWS prohibited at beginning and end 479 tval = 1*VALCHAR 480 VALCHAR = %x21-3A / %x3C-7E 481 ; EXCLAMATION to TILDE except SEMICOLON 482 ALNUMPUNC = ALPHA / DIGIT / "_" 484 Note that WSP is allowed anywhere around tags; in particular, any WSP 485 after the "=" and any WSP before the terminating ";" is not part of 486 the value; however, WSP inside the value is significant. 488 Tags MUST be interpreted in a case-sensitive manner. Values MUST be 489 processed as case sensitive unless the specific tag description of 490 semantics specifies case insensitivity. 492 Tags with duplicate names MUST NOT occur within a single tag-list; if 493 a tag name does occur more than once, the entire tag-list is invalid. 495 Whitespace within a value MUST be retained unless explicitly excluded 496 by the specific tag description. 498 Tag=value pairs that represent the default value MAY be included to 499 aid legibility. 501 Unrecognized tags MUST be ignored. 503 Tags that have an empty value are not the same as omitted tags. An 504 omitted tag is treated as having the default value; a tag with an 505 empty value explicitly designates the empty string as the value. For 506 example, "g=" does not mean "g=*", even though "g=*" is the default 507 for that tag. 509 3.3. Signing and Verification Algorithms 511 DKIM supports multiple digital signature algorithms. Two algorithms 512 are defined by this specification at this time: rsa-sha1, and rsa- 513 sha256. The rsa-sha256 algorithm is the default if no algorithm is 514 specified. Verifiers MUST implement both rsa-sha1 and rsa-sha256. 515 Signers MUST implement and SHOULD sign using rsa-sha256. 517 INFORMATIVE NOTE: Although sha256 is strongly encouraged, some 518 senders of low-security messages (such as routine newsletters) may 519 prefer to use sha1 because of reduced CPU requirements to compute 520 a sha1 hash. In general, sha256 should always be used whenever 521 possible. 523 3.3.1. The rsa-sha1 Signing Algorithm 525 The rsa-sha1 Signing Algorithm computes a message hash as described 526 in Section 3.7 below using SHA-1 [FIPS.180-2.2002] as the hash-alg. 527 That hash is then signed by the signer using the RSA algorithm 528 (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the 529 signer's private key. The hash MUST NOT be truncated or converted 530 into any form other than the native binary form before being signed. 531 The signing algorithm SHOULD use an exponent of 65537. 533 3.3.2. The rsa-sha256 Signing Algorithm 535 The rsa-sha256 Signing Algorithm computes a message hash as described 536 in Section 3.7 below using SHA-256 [FIPS.180-2.2002] as the hash-alg. 537 That hash is then signed by the signer using the RSA algorithm 538 (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the 539 signer's private key. The hash MUST NOT be truncated or converted 540 into any form other than the native binary form before being signed. 542 3.3.3. Key sizes 544 Selecting appropriate key sizes is a trade-off between cost, 545 performance and risk. Since short RSA keys more easily succumb to 546 off-line attacks, signers MUST use RSA keys of at least 1024 bits for 547 long-lived keys. Verifiers MUST be able to validate signatures with 548 keys ranging from 512 bits to 2048 bits, and they MAY be able to 549 validate signatures with larger keys. Verifier policies may use the 550 length of the signing key as one metric for determining whether a 551 signature is acceptable. 553 Factors that should influence the key size choice include: 555 o The practical constraint that large (e.g., 4096 bit) keys may not 556 fit within a 512 byte DNS UDP response packet 558 o The security constraint that keys smaller than 1024 bits are 559 subject to off-line attacks 561 o Larger keys impose higher CPU costs to verify and sign email 563 o Keys can be replaced on a regular basis, thus their lifetime can 564 be relatively short 566 o The security goals of this specification are modest compared to 567 typical goals of other systems that employ digital signatures 569 See [RFC3766] for further discussion on selecting key sizes. 571 3.3.4. Other algorithms 573 Other algorithms MAY be defined in the future. Verifiers MUST ignore 574 any signatures using algorithms that they do not implement. 576 3.4. Canonicalization 578 Empirical evidence demonstrates that some mail servers and relay 579 systems modify email in transit, potentially invalidating a 580 signature. There are two competing perspectives on such 581 modifications. For most signers, mild modification of email is 582 immaterial to the authentication status of the email. For such 583 signers a canonicalization algorithm that survives modest in-transit 584 modification is preferred. 586 Other signers demand that any modification of the email, however 587 minor, result in a signature verification failure. These signers 588 prefer a canonicalization algorithm that does not tolerate in-transit 589 modification of the signed email. 591 Some signers may be willing to accept modifications to header fields 592 that are within the bounds of email standards such as [RFC2822], but 593 are unwilling to accept any modification to the body of messages. 595 To satisfy all requirements, two canonicalization algorithms are 596 defined for each of the header and the body: a "simple" algorithm 597 that tolerates almost no modification and a "relaxed" algorithm that 598 tolerates common modifications such as white-space replacement and 599 header field line re-wrapping. A signer MAY specify either algorithm 600 for header or body when signing an email. If no canonicalization 601 algorithm is specified by the signer, the "simple" algorithm defaults 602 for both header and body. Verifiers MUST implement both 603 canonicalization algorithms. Note that the header and body may use 604 different canonicalization algorithms. Further canonicalization 605 algorithms MAY be defined in the future; verifiers MUST ignore any 606 signatures that use unrecognized canonicalization algorithms. 608 Canonicalization simply prepares the email for presentation to the 609 signing or verification algorithm. It MUST NOT change the 610 transmitted data in any way. Canonicalization of header fields and 611 body are described below. 613 NOTE: This section assumes that the message is already in "network 614 normal" format (e.g., text is ASCII encoded, lines are separated with 615 CRLF characters, etc.). See also Section 5.3 for information about 616 normalizing the message. 618 3.4.1. The "simple" Header Canonicalization Algorithm 620 The "simple" header canonicalization algorithm does not change header 621 fields in any way. Header fields MUST be presented to the signing or 622 verification algorithm exactly as they are in the message being 623 signed or verified. In particular, header field names MUST NOT be 624 case folded and white space MUST NOT be changed. 626 3.4.2. The "relaxed" Header Canonicalization Algorithm 628 The "relaxed" header canonicalization algorithm MUST apply the 629 following steps in order: 631 o Convert all header field names (not the header field values) to 632 lower case. For example, convert "SUBJect: AbC" to "subject: 633 AbC". 635 o Unfold all header field continuation lines as described in 636 [RFC2822]; in particular, lines with terminators embedded in 637 continued header field values (that is, CRLF sequences followed by 638 WSP) MUST be interpreted without the CRLF. Implementations MUST 639 NOT remove the CRLF at the end of the header field value. 641 o Convert all sequences of one or more WSP characters to a single SP 642 character. WSP characters here include those before and after a 643 line folding boundary. 645 o Delete all WSP characters at the end of each unfolded header field 646 value. 648 o Delete any WSP characters remaining before and after the colon 649 separating the header field name from the header field value. The 650 colon separator MUST be retained. 652 3.4.3. The "simple" Body Canonicalization Algorithm 654 The "simple" body canonicalization algorithm ignores all empty lines 655 at the end of the message body. An empty line is a line of zero 656 length after removal of the line terminator. If there is no body or 657 no trailing CRLF on the message body, a CRLF is added. It makes no 658 other changes to the message body. In more formal terms, the 659 "simple" body canonicalization algorithm converts "0*CRLF" at the end 660 of the body to a single "CRLF". 662 Note that a completely empty or missing body is canonicalized as a 663 single "CRLF"; that is, the canonicalized length will be 2 octets. 665 3.4.4. The "relaxed" Body Canonicalization Algorithm 667 The "relaxed" body canonicalization algorithm: 669 o Ignores all white space at the end of lines. Implementations MUST 670 NOT remove the CRLF at the end of the line. 672 o Reduces all sequences of WSP within a line to a single SP 673 character. 675 o Ignores all empty lines at the end of the message body. "Empty 676 line" is defined in Section 3.4.3. 678 INFORMATIVE NOTE: It should be noted that the relaxed body 679 canonicalization algorithm may enable certain types of extremely 680 crude "ASCII Art" attacks where a message may be conveyed by 681 adjusting the spacing between words. If this is a concern, the 682 "simple" body canonicalization algorithm should be used instead. 684 3.4.5. Body Length Limits 686 A body length count MAY be specified to limit the signature 687 calculation to an initial prefix of the body text, measured in 688 octets. If the body length count is not specified then the entire 689 message body is signed. 691 INFORMATIVE RATIONALE: This capability is provided because it is 692 very common for mailing lists to add trailers to messages (e.g., 693 instructions how to get off the list). Until those messages are 694 also signed, the body length count is a useful tool for the 695 verifier since it may as a matter of policy accept messages having 696 valid signatures with extraneous data. 698 INFORMATIVE IMPLEMENTATION NOTE: Using body length limits enables 699 an attack in which an attacker modifies a message to include 700 content that solely benefits the attacker. It is possible for the 701 appended content to completely replace the original content in the 702 end recipient's eyes and to defeat duplicate message detection 703 algorithms. To avoid this attack, signers should be wary of using 704 this tag, and verifiers might wish to ignore the tag or remove 705 text that appears after the specified content length, perhaps 706 based on other criteria. 708 The body length count allows the signer of a message to permit data 709 to be appended to the end of the body of a signed message. The body 710 length count MUST be calculated following the canonicalization 711 algorithm; for example, any white space ignored by a canonicalization 712 algorithm is not included as part of the body length count. Signers 713 of MIME messages that include a body length count SHOULD be sure that 714 the length extends to the closing MIME boundary string. 716 INFORMATIVE IMPLEMENTATION NOTE: A signer wishing to ensure that 717 the only acceptable modifications are to add to the MIME postlude 718 would use a body length count encompassing the entire final MIME 719 boundary string, including the final "--CRLF". A signer wishing 720 to allow additional MIME parts but not modification of existing 721 parts would use a body length count extending through the final 722 MIME boundary string, omitting the final "--CRLF". Note that this 723 only works for some MIME types, e.g., multipart/mixed but not 724 multipart/signed. 726 A body length count of zero means that the body is completely 727 unsigned. 729 Signers wishing to ensure that no modification of any sort can occur 730 should specify the "simple" canonicalization algorithm for both 731 header and body and omit the body length count. 733 3.4.6. Canonicalization Examples (INFORMATIVE) 735 In the following examples, actual white space is used only for 736 clarity. The actual input and output text is designated using 737 bracketed descriptors: "" for a space character, "" for a 738 tab character, and "" for a carriage-return/line-feed sequence. 739 For example, "X Y" and "XY" represent the same three 740 characters. 742 Example 1: A message reading: 743 A: X 744 B : Y 745 Z 746 747 C 748 D E 749 750 752 when canonicalized using relaxed canonicalization for both header and 753 body results in a header reading: 754 a:X 755 b:Y Z 757 and a body reading: 758 C 759 D E 761 Example 2: The same message canonicalized using simple 762 canonicalization for both header and body results in a header 763 reading: 764 A: X 765 B : Y 766 Z 768 and a body reading: 769 C 770 D E 772 Example 3: When processed using relaxed header canonicalization and 773 simple body canonicalization, the canonicalized version has a header 774 of: 775 a:X 776 b:Y Z 778 and a body reading: 779 C 780 D E 782 3.5. The DKIM-Signature header field 784 The signature of the email is stored in the "DKIM-Signature:" header 785 field. This header field contains all of the signature and key- 786 fetching data. The DKIM-Signature value is a tag-list as described 787 in Section 3.2. 789 The "DKIM-Signature:" header field SHOULD be treated as though it 790 were a trace header field as defined in section 3.6 of [RFC2822], and 791 hence SHOULD NOT be reordered and SHOULD be prepended to the message. 793 The "DKIM-Signature:" header field being created or verified is 794 always included in the signature calculation, after the rest of the 795 header fields being signed; however, when calculating or verifying 796 the signature, the value of the b= tag (signature value) of that 797 DKIM-Signature header field MUST be treated as though it were an 798 empty string. Unknown tags in the "DKIM-Signature:" header field 799 MUST be included in the signature calculation but MUST be otherwise 800 ignored by verifiers. Other "DKIM-Signature:" header fields that are 801 included in the signature should be treated as normal header fields; 802 in particular, the b= tag is not treated specially. 804 The encodings for each field type are listed below. Tags described 805 as qp-section are encoded as described in section 6.7 of MIME Part 806 One [RFC2045], with the additional conversion of semicolon characters 807 to "=3B"; intuitively, this is one line of quoted-printable encoded 808 text. The dkim-quoted-printable syntax is defined in Section 2.6. 810 Tags on the DKIM-Signature header field along with their type and 811 requirement status are shown below. Unrecognized tags MUST be 812 ignored. 814 v= Version (MUST be included). This tag defines the version of this 815 specification that applies to the signature record. It MUST have 816 the value 0.5. Note that verifiers must do a string comparison 817 on this value; for example, "1" is not the same as "1.0". 819 ABNF: 821 sig-v-tag = %x76 [FWS] "=" [FWS] "0.5" 823 INFORMATIVE NOTE: DKIM-Signature version numbers are 824 expected to increase arithmetically as new versions of this 825 specification are released. 827 [[INFORMATIVE NOTE: Upon publication, this version number 828 should be changed to "1" (two places), and this note should 829 be deleted.]] 831 a= The algorithm used to generate the signature (plain-text; 832 REQUIRED). Verifiers MUST support "rsa-sha1" and "rsa-sha256"; 833 signers SHOULD sign using "rsa-sha256". See Section 3.3 for a 834 description of algorithms. 836 ABNF: 838 sig-a-tag = %x61 [FWS] "=" [FWS] sig-a-tag-alg 839 sig-a-tag-alg = sig-a-tag-k "-" sig-a-tag-h 840 sig-a-tag-k = "rsa" / x-sig-a-tag-k 841 sig-a-tag-h = "sha1" / "sha256" / x-sig-a-tag-h 842 x-sig-a-tag-k = ALPHA *(ALPHA / DIGIT) ; for later extension 843 x-sig-a-tag-h = ALPHA *(ALPHA / DIGIT) ; for later extension 845 b= The signature data (base64; REQUIRED). Whitespace is ignored in 846 this value and MUST be ignored when re-assembling the original 847 signature. In particular, the signing process can safely insert 848 FWS in this value in arbitrary places to conform to line-length 849 limits. See Signer Actions (Section 5) for how the signature is 850 computed. 852 ABNF: 854 sig-b-tag = %x62 [FWS] "=" [FWS] sig-b-tag-data 855 sig-b-tag-data = base64string 857 bh= The hash of the canonicalized body part of the message as limited 858 by the "l=" tag (base64; REQUIRED). Whitespace is ignored in 859 this value and MUST be ignored when re-assembling the original 860 signature. In particular, the signing process can safely insert 861 FWS in this value in arbitrary places to conform to line-length 862 limits. See Section 3.7 for how the body hash is computed. 864 ABNF: 866 sig-bh-tag = %x62 %x68 [FWS] "=" [FWS] sig-bh-tag-data 867 sig-bh-tag-data = base64string 869 c= Message canonicalization (plain-text; OPTIONAL, default is 870 "simple/simple"). This tag informs the verifier of the type of 871 canonicalization used to prepare the message for signing. It 872 consists of two names separated by a "slash" (%d47) character, 873 corresponding to the header and body canonicalization algorithms 874 respectively. These algorithms are described in Section 3.4. If 875 only one algorithm is named, that algorithm is used for the 876 header and "simple" is used for the body. For example, 877 "c=relaxed" is treated the same as "c=relaxed/simple". 879 ABNF: 881 sig-c-tag = %x63 [FWS] "=" [FWS] sig-c-tag-alg 882 ["/" sig-c-tag-alg] 883 sig-c-tag-alg = "simple" / "relaxed" / x-sig-c-tag-alg 884 x-sig-c-tag-alg = hyphenated-word ; for later extension 886 d= The domain of the signing entity (plain-text; REQUIRED). This is 887 the domain that will be queried for the public key. This domain 888 MUST be the same as or a parent domain of the "i=" tag (the 889 signing identity, as described below), or it MUST meet the 890 requirements for parent domain signing described in Section 3.8. 891 When presented with a signature that does not meet these 892 requirement, verifiers MUST consider the signature invalid. 894 Internationalized domain names MUST be encoded as described in 895 [RFC3490]. 897 ABNF: 899 sig-d-tag = %x64 [FWS] "=" [FWS] domain-name 900 domain-name = sub-domain 1*("." sub-domain) 901 ; from RFC 2821 Domain, but excluding address-literal 903 h= Signed header fields (plain-text, but see description; REQUIRED). 904 A colon-separated list of header field names that identify the 905 header fields presented to the signing algorithm. The field MUST 906 contain the complete list of header fields in the order presented 907 to the signing algorithm. The field MAY contain names of header 908 fields that do not exist when signed; nonexistent header fields 909 do not contribute to the signature computation (that is, they are 910 treated as the null input, including the header field name, the 911 separating colon, the header field value, and any CRLF 912 terminator). The field MUST NOT include the DKIM-Signature 913 header field that is being created or verified, but may include 914 others. Folding white space (FWS) MAY be included on either side 915 of the colon separator. Header field names MUST be compared 916 against actual header field names in a case insensitive manner. 917 This list MUST NOT be empty. See Section 5.4 for a discussion of 918 choosing header fields to sign. 920 ABNF: 922 sig-h-tag = %x68 [FWS] "=" [FWS] hdr-name 923 0*( *FWS ":" *FWS hdr-name ) 924 hdr-name = field-name 926 INFORMATIVE EXPLANATION: By "signing" header fields that do 927 not actually exist, a signer can prevent insertion of those 928 header fields before verification. However, since a signer 929 cannot possibly know what header fields might be created in 930 the future, and that some MUAs might present header fields 931 that are embedded inside a message (e.g., as a message/rfc822 932 content type), the security of this solution is not total. 934 INFORMATIVE EXPLANATION: The exclusion of the header field 935 name and colon as well as the header field value for non- 936 existent header fields prevents an attacker from inserting an 937 actual header field with a null value. 939 i= Identity of the user or agent (e.g., a mailing list manager) on 940 behalf of which this message is signed (dkim-quoted-printable; 941 OPTIONAL, default is an empty local-part followed by an "@" 942 followed by the domain from the "d=" tag). The syntax is a 943 standard email address where the local-part MAY be omitted. The 944 domain part of the address MUST be the same as or a subdomain of 945 the value of the "d=" tag. 947 Internationalized domain names MUST be converted using the steps 948 listed in section 4 of [RFC3490] using the "ToASCII" function. 950 ABNF: 952 sig-i-tag = %x69 [FWS] "=" [FWS] [ Local-part ] "@" domain-name 954 INFORMATIVE NOTE: The local-part of the "i=" tag is optional 955 because in some cases a signer may not be able to establish a 956 verified individual identity. In such cases, the signer may 957 wish to assert that although it is willing to go as far as 958 signing for the domain, it is unable or unwilling to commit 959 to an individual user name within their domain. It can do so 960 by including the domain part but not the local-part of the 961 identity. 963 INFORMATIVE DISCUSSION: This document does not require the 964 value of the "i=" tag to match the identity in any message 965 header field fields. This is considered to be a verifier 966 policy issue. Constraints between the value of the "i=" tag 967 and other identities in other header fields seek to apply 968 basic authentication into the semantics of trust associated 969 with a role such as content author. Trust is a broad and 970 complex topic and trust mechanisms are subject to highly 971 creative attacks. The real-world efficacy of any but the 972 most basic bindings between the "i=" value and other 973 identities is not well established, nor is its vulnerability 974 to subversion by an attacker. Hence reliance on the use of 975 these options should be strictly limited. In particular it 976 is not at all clear to what extent a typical end-user 977 recipient can rely on any assurances that might be made by 978 successful use of the "i=" options. 980 l= Body length count (plain-text unsigned decimal integer; OPTIONAL, 981 default is entire body). This tag informs the verifier of the 982 number of octets in the body of the email after canonicalization 983 included in the cryptographic hash, starting from 0 immediately 984 following the CRLF preceding the body. This value MUST NOT be 985 larger than the actual number of octets in the canonicalized 986 message body. 988 INFORMATIVE IMPLEMENTATION WARNING: Use of the l= tag might 989 allow display of fraudulent content without appropriate 990 warning to end users. The l= tag is intended for increasing 991 signature robustness when sending to mailing lists that both 992 modify their content and do not sign their messages. 993 However, using the l= tag enables attacks in which an 994 intermediary with malicious intent modifies a message to 995 include content that solely benefits the attacker. It is 996 possible for the appended content to completely replace the 997 original content in the end recipient's eyes and to defeat 998 duplicate message detection algorithms. Examples are 999 described in Security Considerations (Section 8). To avoid 1000 this attack, signers should be extremely wary of using this 1001 tag, and verifiers might wish to ignore the tag or remove 1002 text that appears after the specified content length. 1004 INFORMATIVE NOTE: The value of the l= tag is constrained to 1005 76 decimal digits. This constraint is not intended to 1006 predict the size of future messages or to require 1007 implementations to use an integer representation large enough 1008 to represent the maximum possible value, but is intended to 1009 remind the implementer to check the length of this and all 1010 other tags during verification and to test for integer 1011 overflow when decoding the value. Implementers may need to 1012 limit the actual value expressed to a value smaller than 1013 10^76, e.g., to allow a message to fit within the available 1014 storage space. 1016 ABNF: 1018 sig-l-tag = %x6c [FWS] "=" [FWS] 1*76DIGIT 1020 q= A colon-separated list of query methods used to retrieve the 1021 public key (plain-text; OPTIONAL, default is "dns/txt"). Each 1022 query method is of the form "type[/options]", where the syntax 1023 and semantics of the options depends on the type and specified 1024 options. If there are multiple query mechanisms listed, the 1025 choice of query mechanism MUST NOT change the interpretation of 1026 the signature. Implementations MUST use the recognized query 1027 mechanisms in the order presented. 1029 Currently the only valid value is "dns/txt" which defines the DNS 1030 TXT record lookup algorithm described elsewhere in this document. 1031 The only option defined for the "dns" query type is "txt", which 1032 MUST be included. Verifiers and signers MUST support "dns/txt". 1034 ABNF: 1036 sig-q-tag = %x71 [FWS] "=" [FWS] sig-q-tag-method 1037 *([FWS] ":" [FWS] sig-q-tag-method) 1038 sig-q-tag-method = "dns/txt" / x-sig-q-tag-type 1039 ["/" x-sig-q-tag-args] 1040 x-sig-q-tag-type = hyphenated-word ; for future extension 1041 x-sig-q-tag-args = qp-hdr-value 1043 s= The Selector subdividing the namespace for the "d=" (domain) tag 1044 (plain-text; REQUIRED). 1046 ABNF: 1048 sig-s-tag = %x73 [FWS] "=" [FWS] selector 1050 t= Signature Timestamp (plain-text unsigned decimal integer; 1051 RECOMMENDED, default is an unknown creation time). The time that 1052 this signature was created. The format is the number of seconds 1053 since 00:00:00 on January 1, 1970 in the UTC time zone. The 1054 value is expressed as an unsigned integer in decimal ASCII. This 1055 value is not constrained to fit into a 31- or 32-bit integer. 1056 Implementations SHOULD be prepared to handle values up to at 1057 least 10^12 (until approximately AD 200,000; this fits into 40 1058 bits). To avoid denial of service attacks, implementations MAY 1059 consider any value longer than 12 digits to be infinite. Leap 1060 seconds are not counted. Implementations MAY ignore signatures 1061 that have a timestamp in the future. 1063 ABNF: 1065 sig-t-tag = %x74 [FWS] "=" [FWS] 1*12DIGIT 1067 x= Signature Expiration (plain-text unsigned decimal integer; 1068 RECOMMENDED, default is no expiration). The format is the same 1069 as in the "t=" tag, represented as an absolute date, not as a 1070 time delta from the signing timestamp. The value is expressed as 1071 an unsigned integer in decimal ASCII, with the same constraints 1072 on the value in the "t=" tag. Signatures MAY be considered 1073 invalid if the verification time at the verifier is past the 1074 expiration date. The verification time should be the time that 1075 the message was first received at the administrative domain of 1076 the verifier if that time is reliably available; otherwise the 1077 current time should be used. The value of the "x=" tag MUST be 1078 greater than the value of the "t=" tag if both are present. 1080 INFORMATIVE NOTE: The x= tag is not intended as an anti- 1081 replay defense. 1083 ABNF: 1085 sig-x-tag = %x78 [FWS] "=" [FWS] 1*12DIGIT 1087 z= Copied header fields (dkim-quoted-printable, but see description; 1088 OPTIONAL, default is null). A vertical-bar-separated list of 1089 selected header fields present when the message was signed, 1090 including both the field name and value. It is not required to 1091 include all header fields present at the time of signing. This 1092 field need not contain the same header fields listed in the "h=" 1093 tag. The header field text itself must encode the vertical bar 1094 ("|", %x7C) character (i.e., vertical bars in the z= text are 1095 metacharacters, and any actual vertical bar characters in a 1096 copied header field must be encoded). Note that all white space 1097 must be encoded, including white space between the colon and the 1098 header field value. After encoding, LWSP MAY be added at 1099 arbitrary locations in order to avoid excessively long lines; 1100 such white space is NOT part of the value of the header field, 1101 and MUST be removed before decoding. 1103 The header fields referenced by the h= tag refer to the fields in 1104 the 2822 header of the message, not to any copied fields in the 1105 z= tag. Copied header field values are for diagnostic use. 1107 Header fields with characters requiring conversion (perhaps from 1108 legacy MTAs which are not [RFC2822] compliant) SHOULD be 1109 converted as described in MIME Part Three [RFC2047]. 1111 ABNF: 1112 sig-z-tag = %x7A [FWS] "=" [FWS] sig-z-tag-copy 1113 *( [FWS] "|" sig-z-tag-copy ) 1114 sig-z-tag-copy = hdr-name ":" qp-hdr-value 1115 qp-hdr-value = dkim-quoted-printable ; with "|" encoded 1117 INFORMATIVE EXAMPLE of a signature header field spread across 1118 multiple continuation lines: 1120 DKIM-Signature: a=rsa-sha256; d=example.net; s=brisbane; 1121 c=simple; q=dns/txt; i=@eng.example.net; 1122 t=1117574938; x=1118006938; 1123 h=from:to:subject:date; 1124 z=From:foo@eng.example.net|To:joe@example.com| 1125 Subject:demo=20run|Date:July=205,=202005=203:44:08=20PM=20-0700; 1126 bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=; 1127 b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ 1128 VoG4ZHRNiYzR 1130 3.6. Key Management and Representation 1132 Signature applications require some level of assurance that the 1133 verification public key is associated with the claimed signer. Many 1134 applications achieve this by using public key certificates issued by 1135 a trusted third party. However, DKIM can achieve a sufficient level 1136 of security, with significantly enhanced scalability, by simply 1137 having the verifier query the purported signer's DNS entry (or some 1138 security-equivalent) in order to retrieve the public key. 1140 DKIM keys can potentially be stored in multiple types of key servers 1141 and in multiple formats. The storage and format of keys are 1142 irrelevant to the remainder of the DKIM algorithm. 1144 Parameters to the key lookup algorithm are the type of the lookup 1145 (the "q=" tag), the domain of the signer (the "d=" tag of the DKIM- 1146 Signature header field), and the Selector (the "s=" tag). 1148 public_key = dkim_find_key(q_val, d_val, s_val) 1150 This document defines a single binding, using DNS TXT records to 1151 distribute the keys. Other bindings may be defined in the future. 1153 3.6.1. Textual Representation 1155 It is expected that many key servers will choose to present the keys 1156 in an otherwise unstructured text format (for example, an XML form 1157 would not be considered to be unstructured text for this purpose). 1158 The following definition MUST be used for any DKIM key represented in 1159 an otherwise unstructured textual form. 1161 The overall syntax is a tag-list as described in Section 3.2. The 1162 current valid tags are described below. Other tags MAY be present 1163 and MUST be ignored by any implementation that does not understand 1164 them. 1166 v= Version of the DKIM key record (plain-text; RECOMMENDED, default 1167 is "DKIM1"). If specified, this tag MUST be set to "DKIM1" 1168 (without the quotes). This tag MUST be the first tag in the 1169 record. Records beginning with a "v=" tag with any other value 1170 MUST be discarded. Note that verifiers must do a string 1171 comparison on this value; for example, "DKIM1" is not the same as 1172 "DKIM1.0". 1174 ABNF: 1176 key-v-tag = %x76 [FWS] "=" [FWS] "DKIM1" 1178 g= granularity of the key (plain-text; OPTIONAL, default is "*"). 1179 This value MUST match the Local-part of the "i=" tag of the DKIM- 1180 Signature header field (or its default value of the empty string 1181 if "i=" is not specified), with a single, optional "*" character 1182 matching a sequence of zero or more arbitrary characters 1183 ("wildcarding"). An email with a signing address that does not 1184 match the value of this tag constitutes a failed verification. 1185 The intent of this tag is to constrain which signing address can 1186 legitimately use this Selector, for example, when delegating a 1187 key to a third party that should only be used for special 1188 purposes. Wildcarding allows matching for addresses such as 1189 "user+*" or "*-offer". An empty "g=" value never matches any 1190 addresses. 1192 ABNF: 1194 key-g-tag = %x67 [FWS] "=" [FWS] key-g-tag-lpart 1195 key-g-tag-lpart = [dot-atom-text] ["*" [dot-atom-text] ] 1197 [[NON-NORMATIVE DISCUSSION POINT: "*" is legal in a 1198 "dot-atom-text". This should probably use a different 1199 character for wildcarding. Unfortunately, the options are 1200 non-mnemonic (e.g., "@", "(", ":"). Alternatively we could 1201 insist on escaping a "*" intended as a literal "*" in the 1202 address.]] 1204 h= Acceptable hash algorithms (plain-text; OPTIONAL, defaults to 1205 allowing all algorithms). A colon-separated list of hash 1206 algorithms that might be used. Signers and Verifiers MUST 1207 support the "sha256" hash algorithm. Verifiers MUST also support 1208 the "sha1" hash algorithm. 1210 ABNF: 1212 key-h-tag = %x68 [FWS] "=" [FWS] key-h-tag-alg 1213 0*( [FWS] ":" [FWS] key-h-tag-alg ) 1214 key-h-tag-alg = "sha1" / "sha256" / x-key-h-tag-alg 1215 x-key-h-tag-alg = hyphenated-word ; for future extension 1217 k= Key type (plain-text; OPTIONAL, default is "rsa"). Signers and 1218 verifiers MUST support the "rsa" key type. The "rsa" key type 1219 indicates that an ASN.1 DER-encoded [ITU.X660.1997] RSAPublicKey 1220 [RFC3447] (see sections 3.1 and A.1.1) is being used in the p= 1221 tag. (Note: the p= tag further encodes the value using the 1222 base64 algorithm.) 1224 ABNF: 1226 key-k-tag = %x76 [FWS] "=" [FWS] key-k-tag-type 1227 key-k-tag-type = "rsa" / x-key-k-tag-type 1228 x-key-k-tag-type = hyphenated-word ; for future extension 1230 n= Notes that might be of interest to a human (qp-section; OPTIONAL, 1231 default is empty). No interpretation is made by any program. 1232 This tag should be used sparingly in any key server mechanism 1233 that has space limitations (notably DNS). This is intended for 1234 use by administrators, not end users. 1236 ABNF: 1238 key-n-tag = %x6e [FWS] "=" [FWS] qp-section 1240 p= Public-key data (base64; REQUIRED). An empty value means that 1241 this public key has been revoked. The syntax and semantics of 1242 this tag value before being encoded in base64 is defined by the 1243 k= tag. 1245 INFORMATIVE RATIONALE: If a private key has been compromised 1246 or otherwise disabled (e.g., an outsourcing contract has been 1247 terminated), a signer might want to explicitly state that it 1248 knows about the selector, but all messages using that 1249 selector should fail verification. Verifiers should ignore 1250 any DKIM-Signature header fields with a selector referencing 1251 a revoked key. 1253 ABNF: 1255 key-p-tag = %x70 [FWS] "=" [ [FWS] base64string ] 1257 s= Service Type (plain-text; OPTIONAL; default is "*"). A colon- 1258 separated list of service types to which this record applies. 1259 Verifiers for a given service type MUST ignore this record if the 1260 appropriate type is not listed. Currently defined service types 1261 are: 1263 * matches all service types 1265 email electronic mail (not necessarily limited to SMTP) 1267 This tag is intended to constrain the use of keys for other 1268 purposes, should use of DKIM be defined by other services in the 1269 future. 1271 ABNF: 1273 key-s-tag = %x73 [FWS] "=" [FWS] key-s-tag-type 1274 0*( [FWS] ":" [FWS] key-s-tag-type ) 1275 key-s-tag-type = "email" / "*" / x-key-s-tag-type 1276 x-key-s-tag-type = hyphenated-word ; for future extension 1278 t= Flags, represented as a colon-separated list of names (plain- 1279 text; OPTIONAL, default is no flags set). The defined flags are: 1281 y This domain is testing DKIM. Verifiers MUST NOT treat 1282 messages from signers in testing mode differently from 1283 unsigned email, even should the signature fail to verify. 1284 Verifiers MAY wish to track testing mode results to assist 1285 the signer. 1287 s Any DKIM-Signature header fields using the "i=" tag MUST have 1288 the same domain value on the right hand side of the "@" in 1289 the "i=" tag and the value of the "d=" tag. That is, the 1290 "i=" domain MUST NOT be a subdomain of "d=". Use of this 1291 flag is RECOMMENDED unless subdomaining is required. 1293 ABNF: 1295 key-t-tag = %x74 [FWS] "=" [FWS] key-t-tag-flag 1296 0*( [FWS] ":" [FWS] key-t-tag-flag ) 1297 key-t-tag-flag = "y" / "s" / x-key-t-tag-flag 1298 x-key-t-tag-flag = hyphenated-word ; for future extension 1300 Unrecognized flags MUST be ignored. 1302 3.6.2. DNS binding 1304 A binding using DNS TXT records as a key service is hereby defined. 1305 All implementations MUST support this binding. 1307 3.6.2.1. Name Space 1309 All DKIM keys are stored in a subdomain named "_domainkey". Given a 1310 DKIM-Signature field with a "d=" tag of "example.com" and an "s=" tag 1311 of "foo.bar", the DNS query will be for 1312 "foo.bar._domainkey.example.com". 1314 INFORMATIVE OPERATIONAL NOTE: Wildcard DNS records (e.g., 1315 *.bar._domainkey.example.com) do not make sense in this context 1316 and should not be used. Note also that wildcards within domains 1317 (e.g., s._domainkey.*.example.com) are not supported by the DNS. 1319 3.6.2.2. Resource Record Types for Key Storage 1321 The DNS Resource Record type used is specified by an option to the 1322 query-type ("q=") tag. The only option defined in this base 1323 specification is "txt", indicating the use of a TXT Resource Record 1324 (RR). A later extension of this standard may define another RR type. 1326 Strings in a TXT RR MUST be concatenated together before use with no 1327 intervening white space. TXT RRs MUST be unique for a particular 1328 selector name; that is, if there are multiple records in an RRset, 1329 the results are undefined. 1331 TXT RRs are encoded as described in Section 3.6.1. 1333 3.7. Computing the Message Hashes 1335 Both signing and verifying message signatures starts with a step of 1336 computing two cryptographic hashes over the message. Signers will 1337 choose the parameters of the signature as described in Signer Actions 1338 (Section 5); verifiers will use the parameters specified in the 1339 "DKIM-Signature" header field being verified. In the following 1340 discussion, the names of the tags in the "DKIM-Signature" header 1341 field which either exists (when verifying) or will be created (when 1342 signing) are used. Note that canonicalization (Section 3.4) is only 1343 used to prepare the email for signing or verifying; it does not 1344 affect the transmitted email in any way. 1346 The signer/verifier MUST compute two hashes, one over the body of the 1347 message and one over the selected header fields of the message. 1348 Signers MUST compute them in the order shown. Verifiers MAY compute 1349 them in any order convenient to the verifier, provided that the 1350 result is semantically identical to the semantics that would be the 1351 case had they been computed in this order. 1353 In hash step 1, the signer/verifier MUST hash the message body, 1354 canonicalized using the body canonicalization algorithm specified in 1355 the "c=" tag and then truncated to the length specified in the "l=" 1356 tag. That hash value is then converted to base64 form and inserted 1357 into (signers) or compared to (verifiers) the "bh=" tag of the DKIM- 1358 Signature: header field. 1360 In hash step 2, the signer/verifier MUST pass the following to the 1361 hash algorithm in the indicated order. 1363 1. The header fields specified by the "h=" tag, in the order 1364 specified in that tag, and canonicalized using the header 1365 canonicalization algorithm specified in the "c=" tag. Each 1366 header field MUST be terminated with a single CRLF. 1368 2. The "DKIM-Signature" header field that exists (verifying) or will 1369 be inserted (signing) in the message, with the value of the "b=" 1370 tag deleted (i.e., treated as the empty string), canonicalized 1371 using the header canonicalization algorithm specified in the "c=" 1372 tag, and without a trailing CRLF. 1374 All tags and their values in the DKIM-Signature header field are 1375 included in the cryptographic hash with the sole exception of the 1376 value portion of the "b=" (signature) tag, which MUST be treated as 1377 the null string. All tags MUST be included even if they might not be 1378 understood by the verifier. The header field MUST be presented to 1379 the hash algorithm after the body of the message rather than with the 1380 rest of the header fields and MUST be canonicalized as specified in 1381 the "c=" (canonicalization) tag. The DKIM-Signature header field 1382 MUST NOT be included in its own h= tag, although other DKIM-Signature 1383 header fields MAY be signed (see Section 4). 1385 When calculating the hash on messages that will be transmitted using 1386 base64 or quoted-printable encoding, signers MUST compute the hash 1387 after the encoding. Likewise, the verifier MUST incorporate the 1388 values into the hash before decoding the base64 or quoted-printable 1389 text. However, the hash MUST be computed before transport level 1390 encodings such as SMTP "dot-stuffing" (the modification of lines 1391 beginning with a "." to avoid confusion with the SMTP end-of-message 1392 marker, as specified in [RFC2821]). 1394 With the exception of the canonicalization procedure described in 1395 Section 3.4, the DKIM signing process treats the body of messages as 1396 simply a string of octets. DKIM messages MAY be either in plain-text 1397 or in MIME format; no special treatment is afforded to MIME content. 1398 Message attachments in MIME format MUST be included in the content 1399 which is signed. 1401 More formally, the algorithm for the signature is: 1402 body-hash = hash-alg(canon_body) 1403 header-hash = hash-alg(canon_header || DKIM-SIG) 1404 signature = sig-alg(header-hash, key) 1406 where "sig-alg" is the signature algorithm specified by the "a=" tag, 1407 "hash-alg" is the hash algorithm specified by the "a=" tag, 1408 "canon_header" and "canon_body" are the canonicalized message header 1409 and body (respectively) as defined in Section 3.4 (excluding the 1410 DKIM-Signature header field), and "DKIM-SIG" is the canonicalized 1411 DKIM-Signature header field sans the signature value itself, but with 1412 "body-hash" included as the "bh=" tag. 1414 INFORMATIVE IMPLEMENTERS' NOTE: Many digital signature APIs 1415 provide both hashing and application of the RSA private key using 1416 a single "sign()" primitive. When using such an API the last two 1417 steps in the algorithm would probably be combined into a single 1418 call that would perform both the "hash-alg" and the "sig-alg". 1420 3.8. Signing by Parent Domains 1422 In some circumstances, it is desirable for a domain to apply a 1423 signature on behalf of any of its subdomains without the need to 1424 maintain separate selectors (key records) in each subdomain. By 1425 default, private keys corresponding to key records can be used to 1426 sign messages for any subdomain of the domain in which they reside, 1427 e.g., a key record for the domain example.com can be used to verify 1428 messages where the signing identity (i= tag of the signature) is 1429 sub.example.com, or even sub1.sub2.example.com. In order to limit 1430 the capability of such keys when this is not intended, the "s" flag 1431 may be set in the t= tag of the key record to constrain the validity 1432 of the record to exactly the domain of the signing identity. If the 1433 referenced key record contains the "s" flag as part of the t= tag, 1434 the domain of the signing identity (i= flag) MUST be the same as that 1435 of the d= domain. If this flag is absent, the domain of the signing 1436 identity MUST be the same as, or a subdomain of, the d= domain. Key 1437 records which are not intended for use with subdomains SHOULD specify 1438 the "s" flag in the t= tag. 1440 4. Semantics of Multiple Signatures 1442 4.1. Example Scenarios 1444 There are many reasons that a message might have multiple signatures. 1445 For example, a given signer might sign multiple times, perhaps with 1446 different hashing or signing algorithms during a transition phase. 1448 INFORMATIVE EXAMPLE: Suppose SHA-256 is in the future found to be 1449 insufficiently strong, and DKIM usage transitions to SHA-1024. A 1450 signer might immediately sign using the newer algorithm, but 1451 continue to sign using the older algorithm for interoperability 1452 with verifiers that had not yet upgraded. The signer would do 1453 this by adding two DKIM-Signature header fields, one using each 1454 algorithm. Older verifiers that did not recognize SHA-1024 as an 1455 acceptable algorithm would skip that signature and use the older 1456 algorithm; newer verifiers could use either signature at their 1457 option, and all other things being equal might not even attempt to 1458 verify the other signature. 1460 Similarly, a signer might sign a message including all headers and no 1461 "l=" tag (to satisfy strict verifiers) and a second time with a 1462 limited set of headers and an "l=" tag (in anticipation of possible 1463 message modifications in route to other verifiers). Verifiers could 1464 then choose which signature they preferred. 1466 INFORMATIVE EXAMPLE: A verifier might receive a message with two 1467 signatures, one covering more of the message than the other. If 1468 the signature covering more of the message verified, then the 1469 verifier could make one set of policy decisions; if that signature 1470 failed but the signature covering less of the message verified, 1471 the verifier might make a different set of policy decisions. 1473 Of course, a message might also have multiple signatures because it 1474 passed through multiple signers. A common case is expected to be 1475 that of a signed message that passes through a mailing list that also 1476 signs all messages. Assuming both of those signatures verify, a 1477 recipient might choose to accept the message if either of those 1478 signatures were known to come from trusted sources. 1480 INFORMATIVE EXAMPLE: Recipients might choose to whitelist mailing 1481 lists to which they have subscribed and which have acceptable 1482 anti-abuse policies so as to accept messages sent to that list 1483 even from unknown authors. They might also subscribe to less 1484 trusted mailing lists (e.g., those without anti-abuse protection) 1485 and be willing to accept all messages from specific authors, but 1486 insist on doing additional abuse scanning for other messages. 1488 Another related example of multiple signers might be forwarding 1489 services, such as those commonly associated with academic alumni 1490 sites. 1492 INFORMATIVE EXAMPLE: A recipient might have an address at 1493 members.example.org, a site that has anti-abuse protection that is 1494 somewhat less effective than the recipient would prefer. Such a 1495 recipient might have specific authors whose messages would be 1496 trusted absolutely, but messages from unknown authors which had 1497 passed the forwarder's scrutiny would have only medium trust. 1499 4.2. Interpretation 1501 A signer that is adding a signature to a message merely creates a new 1502 DKIM-Signature header, using the usual semantics of the h= option. A 1503 signer MAY sign previously existing DKIM-Signature header fields 1504 using the method described in section Section 5.4 to sign trace 1505 header fields. 1507 INFORMATIVE NOTE: Signers should be cognizant that signing DKIM- 1508 Signature header fields may result in signature failures with 1509 intermediaries that do not recognize that DKIM-Signature header 1510 fields are trace header fields and unwittingly reorder them, thus 1511 breaking such signatures. For this reason, signing existing DKIM- 1512 Signature header fields is unadvised, albeit legal. 1514 INFORMATIVE NOTE: If a header field with multiple instances is 1515 signed, those header fields are always signed from the bottom up. 1516 Thus, it is not possible to sign only specific DKIM-Signature 1517 header fields. For example, if the message being signed already 1518 contains three DKIM-Signature header fields A, B, and C, it is 1519 possible to sign all of them, B and C only, or C only, but not A 1520 only, B only, A and B only, or A and C only. 1522 A signer MAY add more than one DKIM-Signature header field using 1523 different parameters. For example, during a transition period a 1524 signer might want to produce signatures using two different hash 1525 algorithms. 1527 Signers SHOULD NOT remove any DKIM-Signature header fields from 1528 messages they are signing, even if they know that the signatures 1529 cannot be verified. 1531 When evaluating a message with multiple signatures, a verifier SHOULD 1532 evaluate signatures independently and on their own merits. For 1533 example, a verifier that by policy chooses not to accept signatures 1534 with deprecated cryptographic algorithms would consider such 1535 signatures invalid. Verifiers MAY process signatures in any order of 1536 their choice; for example, some verifiers might choose to process 1537 signatures corresponding to the From field in the message header 1538 before other signatures. See Section 6.1 for more information about 1539 signature choices. 1541 INFORMATIVE IMPLEMENTATION NOTE: Verifier attempts to correlate 1542 valid signatures with invalid signatures in an attempt to guess 1543 why a signature failed are ill-advised. In particular, there is 1544 no general way that a verifier can determine that an invalid 1545 signature was ever valid. 1547 Verifiers SHOULD ignore failed signatures as though they were not 1548 present in the message. Verifiers SHOULD continue to check 1549 signatures until a signature successfully verifies to the 1550 satisfaction of the verifier. To limit potential denial-of-service 1551 attacks, verifiers MAY limit the total number of signatures they will 1552 attempt to verify. 1554 5. Signer Actions 1556 The following steps are performed in order by signers. 1558 5.1. Determine if the Email Should be Signed and by Whom 1560 A signer can obviously only sign email for domains for which it has a 1561 private key and the necessary knowledge of the corresponding public 1562 key and Selector information. However there are a number of other 1563 reasons beyond the lack of a private key why a signer could choose 1564 not to sign an email. 1566 INFORMATIVE NOTE: Signing modules may be incorporated into any 1567 portion of the mail system as deemed appropriate, including an 1568 MUA, a SUBMISSION server, or an MTA. Wherever implemented, 1569 signers should beware of signing (and thereby asserting 1570 responsibility for) messages that may be problematic. In 1571 particular, within a trusted enclave the signing address might be 1572 derived from the header according to local policy; SUBMISSION 1573 servers might only sign messages from users that are properly 1574 authenticated and authorized. 1576 INFORMATIVE IMPLEMENTER ADVICE: SUBMISSION servers should not 1577 sign Received header fields if the outgoing gateway MTA obfuscates 1578 Received header fields, for example to hide the details of 1579 internal topology. 1581 If an email cannot be signed for some reason, it is a local policy 1582 decision as to what to do with that email. 1584 5.2. Select a Private Key and Corresponding Selector Information 1586 This specification does not define the basis by which a signer should 1587 choose which private key and Selector information to use. Currently, 1588 all Selectors are equal as far as this specification is concerned, so 1589 the decision should largely be a matter of administrative 1590 convenience. Distribution and management of private keys is also 1591 outside the scope of this document. 1593 INFORMATIVE OPERATIONS ADVICE: A signer should not sign with a 1594 private key when the Selector containing the corresponding public 1595 key is expected to be revoked or removed before the verifier has 1596 an opportunity to validate the signature. The signer should 1597 anticipate that verifiers may choose to defer validation, perhaps 1598 until the message is actually read by the final recipient. In 1599 particular, when rotating to a new key pair, signing should 1600 immediately commence with the new private key and the old public 1601 key should be retained for a reasonable validation interval before 1602 being removed from the key server. 1604 5.3. Normalize the Message to Prevent Transport Conversions 1606 Some messages, particularly those using 8-bit characters, are subject 1607 to modification during transit, notably conversion to 7-bit form. 1608 Such conversions will break DKIM signatures. In order to minimize 1609 the chances of such breakage, signers SHOULD convert the message to a 1610 suitable MIME content transfer encoding such as quoted-printable or 1611 base64 as described in MIME Part One [RFC2045] before signing. Such 1612 conversion is outside the scope of DKIM; the actual message SHOULD be 1613 converted to 7-bit MIME by an MUA or MSA prior to presentation to the 1614 DKIM algorithm. 1616 If the message is submitted to the signer with any local encoding 1617 that will be modified before transmission, that modification to 1618 canonical [RFC2822] form MUST be done before signing. In particular, 1619 bare CR or LF characters (used by some systems as a local line 1620 separator convention) MUST be converted to the SMTP-standard CRLF 1621 sequence before the message is signed. Any conversion of this sort 1622 SHOULD be applied to the message actually sent to the recipient(s), 1623 not just to the version presented to the signing algorithm. 1625 More generally, the signer MUST sign the message as it is expected to 1626 be received by the verifier rather than in some local or internal 1627 form. 1629 5.4. Determine the Header Fields to Sign 1631 The From header field MUST be signed (that is, included in the h= tag 1632 of the resulting DKIM-Signature header field). Signers SHOULD NOT 1633 sign an existing header field likely to be legitimately modified or 1634 removed in transit. In particular, [RFC2821] explicitly permits 1635 modification or removal of the "Return-Path" header field in transit. 1636 Signers MAY include any other header fields present at the time of 1637 signing at the discretion of the signer. 1639 INFORMATIVE OPERATIONS NOTE: The choice of which header fields to 1640 sign is non-obvious. One strategy is to sign all existing, non- 1641 repeatable header fields. An alternative strategy is to sign only 1642 header fields that are likely to be displayed to or otherwise be 1643 likely to affect the processing of the message at the receiver. A 1644 third strategy is to sign only "well known" headers. Note that 1645 verifiers may treat unsigned header fields with extreme 1646 skepticism, including refusing to display them to the end user or 1647 even ignore the signature if it does not cover certain header 1648 fields. For this reason signing fields present in the message 1649 such as Date, Subject, Reply-To, Sender, and all MIME header 1650 fields is highly advised. 1652 The DKIM-Signature header field is always implicitly signed and MUST 1653 NOT be included in the h= tag except to indicate that other 1654 preexisting signatures are also signed. 1656 Signers MAY claim to have signed header fields that do not exist 1657 (that is, signers MAY include the header field name in the h= tag 1658 even if that header field does not exist in the message). When 1659 computing the signature, the non-existing header field MUST be 1660 treated as the null string (including the header field name, header 1661 field value, all punctuation, and the trailing CRLF). 1663 INFORMATIVE RATIONALE: This allows signers to explicitly assert 1664 the absence of a header field; if that header field is added later 1665 the signature will fail. 1667 INFORMATIVE NOTE: A header field name need only be listed once 1668 more than the actual number of that header field in a message at 1669 the time of signing in order to prevent any further additions. 1670 For example, if there is a single "Comments" header field at the 1671 time of signing, listing "Comments" twice in the h= tag is 1672 sufficient to prevent any number of Comments header fields from 1673 being appended; it is not necessary (but is legal) to list 1674 "Comments" three or more times in the h= tag. 1676 Signers choosing to sign an existing header field that occurs more 1677 than once in the message (such as Received) MUST sign the physically 1678 last instance of that header field in the header block. Signers 1679 wishing to sign multiple instances of such a header field MUST 1680 include the header field name multiple times in the h= tag of the 1681 DKIM-Signature header field, and MUST sign such header fields in 1682 order from the bottom of the header field block to the top. The 1683 signer MAY include more instances of a header field name in h= than 1684 there are actual corresponding header fields to indicate that 1685 additional header fields of that name SHOULD NOT be added. 1687 INFORMATIVE EXAMPLE: 1689 If the signer wishes to sign two existing Received header fields, 1690 and the existing header contains: 1692 Received: 1693 Received: 1694 Received: 1696 then the resulting DKIM-Signature header field should read: 1698 DKIM-Signature: ... h=Received : Received : ... 1700 and Received header fields and will be signed in that 1701 order. 1703 Signers should be careful of signing header fields that might have 1704 additional instances added later in the delivery process, since such 1705 header fields might be inserted after the signed instance or 1706 otherwise reordered. Trace header fields (such as Received) and 1707 Resent-* blocks are the only fields prohibited by [RFC2822] from 1708 being reordered. In particular, since DKIM-Signature header fields 1709 may be reordered by some intermediate MTAs, signing existing DKIM- 1710 Signature header fields is error-prone. 1712 INFORMATIVE ADMONITION: Despite the fact that [RFC2822] permits 1713 header fields to be reordered (with the exception of Received 1714 header fields), reordering of signed header fields with multiple 1715 instances by intermediate MTAs will cause DKIM signatures to be 1716 broken; such anti-social behavior should be avoided. 1718 INFORMATIVE IMPLEMENTER'S NOTE: Although not required by this 1719 specification, all end-user visible header fields should be signed 1720 to avoid possible "indirect spamming." For example, if the 1721 "Subject" header field is not signed, a spammer can resend a 1722 previously signed mail, replacing the legitimate subject with a 1723 one-line spam. 1725 5.5. Recommended Signature Content 1727 In order to maximize compatibility with a variety of verifiers, it is 1728 recommended that signers follow the practices outlined in this 1729 section when signing a message. However, these are generic 1730 recommendations applying to the general case; specific senders may 1731 wish to modify these guidelines as required by their unique 1732 situations. Verifiers MUST be capable of verifying signatures even 1733 if one or more of the recommended header fields is not signed (with 1734 the exception of From, which must always be signed) or if one or more 1735 of the disrecommended header fields is signed. Note that verifiers 1736 do have the option of ignoring signatures that do not cover a 1737 sufficient portion of the header or body, just as they may ignore 1738 signatures from an identity they do not trust. 1740 The following header fields SHOULD be included in the signature, if 1741 they are present in the message being signed: 1743 o From (REQUIRED in all signatures) 1745 o Sender, Reply-To 1747 o Subject 1749 o Date, Message-ID 1751 o To, Cc 1753 o MIME-Version 1755 o Content-Type, Content-Transfer-Encoding, Content-ID, Content- 1756 Description 1758 o Resent-Date, Resent-From, Resent-Sender, Resent-To, Resent-cc, 1759 Resent-Message-ID 1761 o In-Reply-To, References 1763 o List-Id, List-Help, List-Unsubscribe, List-Subscribe, List-Post, 1764 List-Owner, List-Archive 1766 The following header fields SHOULD NOT be included in the signature: 1768 o Return-Path 1770 o Received 1772 o Comments, Keywords 1774 o Bcc, Resent-Bcc 1776 o DKIM-Signature 1778 Optional header fields (those not mentioned above) normally SHOULD 1779 NOT be included in the signature, because of the potential for 1780 additional header fields of the same name to be legitimately added or 1781 reordered prior to verification. There are likely to be legitimate 1782 exceptions to this rule, because of the wide variety of application- 1783 specific header fields which may be applied to a message, some of 1784 which are unlikely to be duplicated, modified, or reordered. 1786 Signers SHOULD choose canonicalization algorithms based on the types 1787 of messages they process and their aversion to risk. For example, 1788 e-commerce sites sending primarily purchase receipts, which are not 1789 expected to be processed by mailing lists or other software likely to 1790 modify messages, will generally prefer "simple" canonicalization. 1791 Sites sending primarily person-to-person email will likely prefer to 1792 be more more resilient to modification during transport by using 1793 "relaxed" canonicalization. 1795 Signers SHOULD NOT use l= unless they intend to accomodate 1796 intermediate mail processors that append text to a message. For 1797 example, many mailing list processors append "unsubscribe" 1798 information to message bodies. If signers use l=, they SHOULD 1799 include the entire message body existing at the time of signing in 1800 computing the count. In particular, signers SHOULD NOT specify a 1801 body length of 0 since this may be interpreted as a meaningless 1802 signature by some verifiers. 1804 5.6. Compute the Message Hash and Signature 1806 The signer MUST compute the message hash as described in Section 3.7 1807 and then sign it using the selected public-key algorithm. This will 1808 result in a DKIM-Signature header field which will include the body 1809 hash and a signature of the header hash, where that header includes 1810 the DKIM-Signature header field itself. 1812 Entities such as mailing list managers that implement DKIM and which 1813 modify the message or a header field (for example, inserting 1814 unsubscribe information) before retransmitting the message SHOULD 1815 check any existing signature on input and MUST make such 1816 modifications before re-signing the message. 1818 The signer MAY elect to limit the number of bytes of the body that 1819 will be included in the hash and hence signed. The length actually 1820 hashed should be inserted in the "l=" tag of the "DKIM-Signature" 1821 header field. 1823 5.7. Insert the DKIM-Signature Header Field 1825 Finally, the signer MUST insert the "DKIM-Signature:" header field 1826 created in the previous step prior to transmitting the email. The 1827 "DKIM-Signature" header field MUST be the same as used to compute the 1828 hash as described above, except that the value of the "b=" tag MUST 1829 be the appropriately signed hash computed in the previous step, 1830 signed using the algorithm specified in the "a=" tag of the "DKIM- 1831 Signature" header field and using the private key corresponding to 1832 the Selector given in the "s=" tag of the "DKIM-Signature" header 1833 field, as chosen above in Section 5.2 1835 The "DKIM-Signature" MUST be inserted before any other DKIM-Signature 1836 fields in the header block. 1838 INFORMATIVE IMPLEMENTATION NOTE: The easiest way to achieve this 1839 is to insert the "DKIM-Signature" header field at the beginning of 1840 the header block. In particular, it may be placed before any 1841 existing Received header fields. This is consistent with treating 1842 "DKIM-Signature" as a trace header field. 1844 6. Verifier Actions 1846 Since a signer MAY remove or revoke a public key at any time, it is 1847 recommended that verification occur in a timely manner. In many 1848 configurations, the most timely place is during acceptance by the 1849 border MTA or shortly thereafter. In particular, deferring 1850 verification until the message is accessed by the end user is 1851 discouraged. 1853 A border or intermediate MTA MAY verify the message signature(s). An 1854 MTA who has performed verification MAY communicate the result of that 1855 verification by adding a verification header field to incoming 1856 messages. This considerably simplifies things for the user, who can 1857 now use an existing mail user agent. Most MUAs have the ability to 1858 filter messages based on message header fields or content; these 1859 filters would be used to implement whatever policy the user wishes 1860 with respect to unsigned mail. 1862 A verifying MTA MAY implement a policy with respect to unverifiable 1863 mail, regardless of whether or not it applies the verification header 1864 field to signed messages. 1866 Verifiers MUST produce a result that is semantically equivalent to 1867 applying the following steps in the order listed. In practice, 1868 several of these steps can be performed in parallel in order to 1869 improve performance. 1871 6.1. Extract Signatures from the Message 1873 The order in which verifiers try DKIM-Signature header fields is not 1874 defined; verifiers MAY try signatures in any order they would like. 1875 For example, one implementation might prefer to try the signatures in 1876 textual order, whereas another might want to prefer signatures by 1877 identities that match the contents of the "From" header field over 1878 other identities. Verifiers MUST NOT attribute ultimate meaning to 1879 the order of multiple DKIM-Signature header fields. In particular, 1880 there is reason to believe that some relays will reorder the header 1881 fields in potentially arbitrary ways. 1883 INFORMATIVE IMPLEMENTATION NOTE: Verifiers might use the order as 1884 a clue to signing order in the absence of any other information. 1885 However, other clues as to the semantics of multiple signatures 1886 (such as correlating the signing host with Received header fields) 1887 may also be considered. 1889 A verifier SHOULD NOT treat a message that has one or more bad 1890 signatures and no good signatures differently from a message with no 1891 signature at all; such treatment is a matter of local policy and is 1892 beyond the scope of this document. 1894 When a signature successfully verifies, a verifier will either stop 1895 processing or attempt to verify any other signatures, at the 1896 discretion of the implementation. A verifier MAY limit the number of 1897 signatures it tries to avoid denial-of-service attacks. 1899 INFORMATIVE NOTE: An attacker could send messages with large 1900 numbers of faulty signatures, each of which would require a DNS 1901 lookup and corresponding CPU time to verify the message. This 1902 could be an attack on the domain that receives the message, by 1903 slowing down the verifier by requiring it to do large number of 1904 DNS lookups and/or signature verifications. It could also be an 1905 attack against the domains listed in the signatures, essentially 1906 by enlisting innocent verifiers in launching an attack against the 1907 DNS servers of the actual victim. 1909 In the following description, text reading "return status 1910 (explanation)" (where "status" is one of "PERMFAIL" or "TEMPFAIL") 1911 means that the verifier MUST immediately cease processing that 1912 signature. The verifier SHOULD proceed to the next signature, if any 1913 is present, and completely ignore the bad signature. If the status 1914 is "PERMFAIL", the signature failed and should not be reconsidered. 1915 If the status is "TEMPFAIL", the signature could not be verified at 1916 this time but may be tried again later. A verifier MAY either defer 1917 the message for later processing, perhaps by queueing it locally or 1918 issuing a 451/4.7.5 SMTP reply, or try another signature; if no good 1919 signature is found and any of the signatures resulted in a TEMPFAIL 1920 status, the verifier MAY save the message for later processing. The 1921 "(explanation)" is not normative text; it is provided solely for 1922 clarification. 1924 Verifiers SHOULD ignore any DKIM-Signature header fields where the 1925 signature does not validate. Verifiers that are prepared to validate 1926 multiple signature header fields SHOULD proceed to the next signature 1927 header field, should it exist. However, verifiers MAY make note of 1928 the fact that an invalid signature was present for consideration at a 1929 later step. 1931 INFORMATIVE NOTE: The rationale of this requirement is to permit 1932 messages that have invalid signatures but also a valid signature 1933 to work. For example, a mailing list exploder might opt to leave 1934 the original submitter signature in place even though the exploder 1935 knows that it is modifying the message in some way that will break 1936 that signature, and the exploder inserts its own signature. In 1937 this case the message should succeed even in the presence of the 1938 known-broken signature. 1940 For each signature to be validated, the following steps should be 1941 performed in such a manner as to produce a result that is 1942 semantically equivalent to performing them in the indicated order. 1944 6.1.1. Validate the Signature Header Field 1946 Implementers MUST meticulously validate the format and values in the 1947 DKIM-Signature header field; any inconsistency or unexpected values 1948 MUST cause the header field to be completely ignored and the verifier 1949 to return PERMFAIL (signature syntax error). Being "liberal in what 1950 you accept" is definitely a bad strategy in this security context. 1951 Note however that this does not include the existence of unknown tags 1952 in a DKIM-Signature header field, which are explicitly permitted. 1954 Verifiers MUST ignore DKIM-Signature header fields with a "v=" tag 1955 that is inconsistent with this specification and return PERMFAIL 1956 (incompatible version). 1958 INFORMATIVE IMPLEMENTATION NOTE: An implementation may, of 1959 course, choose to also verify signatures generated by older 1960 versions of this specification. 1962 If any tag listed as "required" in Section 3.5 is omitted from the 1963 DKIM-Signature header field, the verifier MUST ignore the DKIM- 1964 Signature header field and return PERMFAIL (signature missing 1965 required tag). 1967 INFORMATIONAL NOTE: The tags listed as required in Section 3.5 1968 are "v=", "a=", "b=", "bh=", "d=", "h=", and "s=". Should there 1969 be a conflict between this note and Section 3.5, Section 3.5 is 1970 normative. 1972 If the "DKIM-Signature" header field does not contain the "i=" tag, 1973 the verifier MUST behave as though the value of that tag were "@d", 1974 where "d" is the value from the "d=" tag. 1976 Verifiers MUST confirm that the domain specified in the "d=" tag is 1977 the same as or a parent domain of the domain part of the "i=" tag. 1978 If not, the DKIM-Signature header field MUST be ignored and the 1979 verifier should return PERMFAIL (domain mismatch). 1981 If the "h=" tag does not include the "From" header field the verifier 1982 MUST ignore the DKIM-Signature header field and return PERMFAIL (From 1983 field not signed). 1985 Verifiers MAY ignore the DKIM-Signature header field and return 1986 PERMFAIL (signature expired) if it contains an "x=" tag and the 1987 signature has expired. 1989 Verifiers MAY ignore the DKIM-Signature header field if the domain 1990 used by the signer in the d= tag is not associated with a valid 1991 signing entity. For example, signatures with d= values such as "com" 1992 and "co.uk" may be ignored. The list of unacceptable domains SHOULD 1993 be configurable. 1995 Verifiers MAY ignore the DKIM-Signature header field and return 1996 PERMFAIL (unacceptable signature header) for any other reason, for 1997 example, if the signature does not sign header fields that the 1998 verifier views to be essential. As a case in point, if MIME header 1999 fields are not signed, certain attacks may be possible that the 2000 verifier would prefer to avoid. 2002 6.1.2. Get the Public Key 2004 The public key for a signature is needed to complete the verification 2005 process. The process of retrieving the public key depends on the 2006 query type as defined by the "q=" tag in the "DKIM-Signature:" header 2007 field. Obviously, a public key need only be retrieved if the process 2008 of extracting the signature information is completely successful. 2009 Details of key management and representation are described in 2010 Section 3.6. The verifier MUST validate the key record and MUST 2011 ignore any public key records that are malformed. 2013 When validating a message, a verifier MUST perform the following 2014 steps in a manner that is semantically the same as performing them in 2015 the order indicated (in some cases the implementation may parallelize 2016 or reorder these steps, as long as the semantics remain unchanged): 2018 1. Retrieve the public key as described in (Section 3.6) using the 2019 algorithm in the "q=" tag, the domain from the "d=" tag, and the 2020 Selector from the "s=" tag. 2022 2. If the query for the public key fails to respond, the verifier 2023 MAY defer acceptance of this email and return TEMPFAIL (key 2024 unavailable). If verification is occurring during the incoming 2025 SMTP session, this MAY be achieved with a 451/4.7.5 SMTP reply 2026 code. Alternatively, the verifier MAY store the message in the 2027 local queue for later trial or ignore the signature. Note that 2028 storing a message in the local queue is subject to denial-of- 2029 service attacks. 2031 3. If the query for the public key fails because the corresponding 2032 key record does not exist, the verifier MUST immediately return 2033 PERMFAIL (no key for signature). 2035 4. If the query for the public key returns multiple key records, the 2036 verifier may choose one of the key records or may cycle through 2037 the key records performing the remainder of these steps on each 2038 record at the discretion of the implementer. The order of the 2039 key records is unspecified. If the verifier chooses to cycle 2040 through the key records, then the "return ..." wording in the 2041 remainder of this section means "try the next key record, if any; 2042 if none, return to try another signature in the usual way." 2044 5. If the result returned from the query does not adhere to the 2045 format defined in this specification, the verifier MUST ignore 2046 the key record and return PERMFAIL (key syntax error). Verifiers 2047 are urged to validate the syntax of key records carefully to 2048 avoid attempted attacks. In particular, the verifier MUST ignore 2049 keys with a version code ("v=" tag) that they do not implement. 2051 6. If the "g=" tag in the public key does not match the Local-part 2052 of the "i=" tag in the message signature header field, the 2053 verifier MUST ignore the key record and return PERMFAIL 2054 (inapplicable key). If the Local-part of the "i=" tag on the 2055 message signature is not present, the g= tag must be * (valid for 2056 all addresses in the domain) or the entire g= tag must be omitted 2057 (which defaults to "g=*"), otherwise the verifier MUST ignore the 2058 key record and return PERMFAIL (inapplicable key). Other than 2059 this test, verifiers SHOULD NOT treat a message signed with a key 2060 record having a g= tag any differently than one without; in 2061 particular, verifiers SHOULD NOT prefer messages that seem to 2062 have an individual signature by virtue of a g= tag versus a 2063 domain signature. 2065 7. If the "h=" tag exists in the public key record and the hash 2066 algorithm implied by the a= tag in the DKIM-Signature header 2067 field is not included in the contents of the "h=" tag, the 2068 verifier MUST ignore the key record and return PERMFAIL 2069 (inappropriate hash algorithm). 2071 8. If the public key data (the "p=" tag) is empty then this key has 2072 been revoked and the verifier MUST treat this as a failed 2073 signature check and return PERMFAIL (key revoked). There is no 2074 defined semantic difference between a key that has been revoked 2075 and a key record that has been removed. 2077 9. If the public key data is not suitable for use with the algorithm 2078 and key types defined by the "a=" and "k=" tags in the "DKIM- 2079 Signature" header field, the verifier MUST immediately return 2080 PERMFAIL (inappropriate key algorithm). 2082 6.1.3. Compute the Verification 2084 Given a signer and a public key, verifying a signature consists of 2085 actions semantically equivalent to the following steps. 2087 1. Based on the algorithm defined in the "c=" tag, the body length 2088 specified in the "l=" tag, and the header field names in the "h=" 2089 tag, prepare a canonicalized version of the message as is 2090 described in Section 3.7 (note that this version does not 2091 actually need to be instantiated). When matching header field 2092 names in the "h=" tag against the actual message header field, 2093 comparisons MUST be case-insensitive. 2095 2. Based on the algorithm indicated in the "a=" tag, compute the 2096 message hashes from the canonical copy as described in 2097 Section 3.7. 2099 3. Verify that the hash of the canonicalized message body computed 2100 in the previous step matches the hash value conveyed in the "bh=" 2101 tag. If the hash does not match, the verifier SHOULD ignore the 2102 signature and return PERMFAIL (body hash did not verify). 2104 4. Using the signature conveyed in the "b=" tag, verify the 2105 signature against the header hash using the mechanism appropriate 2106 for the public key algorithm described in the "a=" tag. If the 2107 signature does not validate, the verifier SHOULD ignore the 2108 signature and return PERMFAIL (signature did not verify). 2110 5. Otherwise, the signature has correctly verified. 2112 INFORMATIVE IMPLEMENTER'S NOTE: Implementations might wish to 2113 initiate the public-key query in parallel with calculating the 2114 hash as the public key is not needed until the final decryption is 2115 calculated. Implementations may also verify the signature on the 2116 message header before validating that the message hash listed in 2117 the "bh=" tag in the DKIM-Signature header field matches that of 2118 the actual message body; however, if the body hash does not match, 2119 the entire signature must be considered to have failed. 2121 A body length specified in the "l=" tag of the signature limits the 2122 number of bytes of the body passed to the verification algorithm. 2123 All data beyond that limit is not validated by DKIM. Hence, 2124 verifiers might treat a message that contains bytes beyond the 2125 indicated body length with suspicion, such as by truncating the 2126 message at the indicated body length, declaring the signature invalid 2127 (e.g., by returning PERMFAIL (unsigned content)), or conveying the 2128 partial verification to the policy module. 2130 INFORMATIVE IMPLEMENTATION NOTE: Verifiers that truncate the body 2131 at the indicated body length might pass on a malformed MIME 2132 message if the signer used the "N-4" trick (omitting the final 2133 "--CRLF") described in the informative note in Section 3.4.5. 2134 Such verifiers may wish to check for this case and include a 2135 trailing "--CRLF" to avoid breaking the MIME structure. A simple 2136 way to achieve this might be to append "--CRLF" to any "multipart" 2137 message with a body length; if the MIME structure is already 2138 correctly formed, this will appear in the postlude and will not be 2139 displayed to the end user. 2141 6.2. Communicate Verification Results 2143 Verifiers wishing to communicate the results of verification to other 2144 parts of the mail system may do so in whatever manner they see fit. 2145 For example, implementations might choose to add an email header 2146 field to the message before passing it on. Any such header field 2147 SHOULD be inserted before any existing DKIM-Signature or preexisting 2148 authentication status header fields in the header field block. 2150 INFORMATIVE ADVICE to MUA filter writers: Patterns intended to 2151 search for results header fields to visibly mark authenticated 2152 mail for end users should verify that such header field was added 2153 by the appropriate verifying domain and that the verified identity 2154 matches the author identity that will be displayed by the MUA. In 2155 particular, MUA filters should not be influenced by bogus results 2156 header fields added by attackers. To circumvent this attack, 2157 verifiers may wish to delete existing results header fields after 2158 verification and before adding a new header field. 2160 6.3. Interpret Results/Apply Local Policy 2162 It is beyond the scope of this specification to describe what actions 2163 a verifier system should make, but an authenticated email presents an 2164 opportunity to a receiving system that unauthenticated email cannot. 2165 Specifically, an authenticated email creates a predictable identifier 2166 by which other decisions can reliably be managed, such as trust and 2167 reputation. Conversely, unauthenticated email lacks a reliable 2168 identifier that can be used to assign trust and reputation. It is 2169 reasonable to treat unauthenticated email as lacking any trust and 2170 having no positive reputation. 2172 In general verifiers SHOULD NOT reject messages solely on the basis 2173 of a lack of signature or an unverifiable signature; such rejection 2174 would cause severe interoperability problems. However, if the 2175 verifier does opt to reject such messages (for example, when 2176 communicating with a peer who, by prior agreement, agrees to only 2177 send signed messages), and the verifier runs synchronously with the 2178 SMTP session and a signature is missing or does not verify, the MTA 2179 SHOULD use a 550/5.7.x reply code. 2181 If it is not possible to fetch the public key, perhaps because the 2182 key server is not available, a temporary failure message MAY be 2183 generated using a 451/4.7.5 reply code, such as: 2185 451 4.7.5 Unable to verify signature - key server unavailable 2187 Temporary failures such as inability to access the key server or 2188 other external service are the only conditions that SHOULD use a 4xx 2189 SMTP reply code. In particular, cryptographic signature verification 2190 failures MUST NOT return 4xx SMTP replies. 2192 Once the signature has been verified, that information MUST be 2193 conveyed to higher level systems (such as explicit allow/white lists 2194 and reputation systems) and/or to the end user. If the message is 2195 signed on behalf of any address other than that in the From: header 2196 field, the mail system SHOULD take pains to ensure that the actual 2197 signing identity is clear to the reader. 2199 The verifier MAY treat unsigned header fields with extreme 2200 skepticism, including marking them as untrusted or even deleting them 2201 before display to the end user. 2203 While the symptoms of a failed verification are obvious -- the 2204 signature doesn't verify -- establishing the exact cause can be more 2205 difficult. If a Selector cannot be found, is that because the 2206 Selector has been removed or was the value changed somehow in 2207 transit? If the signature line is missing is that because it was 2208 never there, or was it removed by an over-zealous filter? For 2209 diagnostic purposes, the exact reason why the verification fails 2210 SHOULD be made available to the policy module and possibly recorded 2211 in the system logs. If the email cannot be verified, then it SHOULD 2212 be rendered the same as all unverified email regardless of whether it 2213 looks like it was signed or not. 2215 7. IANA Considerations 2217 DKIM introduces some new namespaces that require IANA registry. In 2218 all cases, new values are assigned only for values that have 2219 documented in a published RFC having IETF Consensus [RFC2434]. 2221 7.1. DKIM-Signature Tag Specifications 2223 A DKIM-Signature provides for a list of tag specifications. IANA is 2224 requested to establish the DKIM Signature Tag Specification Registry, 2225 for tag specifications that can be used in DKIM-Signature fields and 2226 that have been specified in any published RFC. 2228 The initial entries in the registry comprise: 2230 +------+-----------------+ 2231 | TYPE | REFERENCE | 2232 +------+-----------------+ 2233 | v | (this document) | 2234 | a | (this document) | 2235 | b | (this document) | 2236 | bh | (this document) | 2237 | c | (this document) | 2238 | d | (this document) | 2239 | h | (this document) | 2240 | i | (this document) | 2241 | l | (this document) | 2242 | q | (this document) | 2243 | s | (this document) | 2244 | t | (this document) | 2245 | x | (this document) | 2246 | z | (this document) | 2247 +------+-----------------+ 2249 DKIM Signature Tag Specification Registry Initial Values 2251 7.2. DKIM-Signature Query Method Registry 2253 The "q=" tag-spec, as specified in Section 3.5 provides for a list of 2254 query methods. 2256 IANA is requested to establish the DKIM Query Method Registry, for 2257 mechanisms that can be used to retrieve the key that will permit 2258 validation processing of a message signed using DKIM and have been 2259 specified in any published RFC. 2261 The initial entry in the registry comprises: 2263 +------+--------+-----------------+ 2264 | TYPE | OPTION | REFERENCE | 2265 +------+--------+-----------------+ 2266 | dns | txt | (this document) | 2267 +------+--------+-----------------+ 2269 DKIM-Signature Query Method Registry Initial Values 2271 7.3. DKIM-Signature Canonicalization Registry 2273 The "c=" tag-spec, as specified in Section 3.5 provides for a 2274 specifier for canonicalization algorithms for the header and body of 2275 the message. 2277 IANA is requested to establish the DKIM Canonicalization Algorithm 2278 Registry, for algorithms for converting a message into a canonical 2279 form before signing or verifying using DKIM and have been specified 2280 in any published RFC. 2282 The initial entries in the header registry comprise: 2284 +---------+-----------------+ 2285 | TYPE | REFERENCE | 2286 +---------+-----------------+ 2287 | simple | (this document) | 2288 | relaxed | (this document) | 2289 +---------+-----------------+ 2291 DKIM-Signature Header Canonicalization Algorithm Registry Initial 2292 Values 2294 The initial entries in the body registry comprise: 2296 +---------+-----------------+ 2297 | TYPE | REFERENCE | 2298 +---------+-----------------+ 2299 | simple | (this document) | 2300 | relaxed | (this document) | 2301 +---------+-----------------+ 2303 DKIM-Signature Body Canonicalization Algorithm Registry Initial 2304 Values 2306 7.4. _domainkey DNS TXT Record Tag Specifications 2308 A _domainkey DNS TXT record provides for a list of tag 2309 specifications. IANA is requested to establish the DKIM _domainkey 2310 DNS TXT Tag Specification Registry, for tag specifications that can 2311 be used in DNS TXT Records and that have been specified in any 2312 published RFC. 2314 The initial entries in the registry comprise: 2316 +------+-----------------+ 2317 | TYPE | REFERENCE | 2318 +------+-----------------+ 2319 | v | (this document) | 2320 | g | (this document) | 2321 | h | (this document) | 2322 | k | (this document) | 2323 | n | (this document) | 2324 | p | (this document) | 2325 | s | (this document) | 2326 | t | (this document) | 2327 +------+-----------------+ 2329 DKIM _domainkey DNS TXT Record Tag Specification Registry Initial 2330 Values 2332 7.5. DKIM Key Type Registry 2334 The "k=" (as specified in Section 3.6.1) and the "a=" 2335 (Section 3.5) tags provide for a list of mechanisms 2336 that can be used to decode a DKIM signature. 2338 IANA is requested to establish the DKIM Key Type Registry, for such 2339 mechanisms that have been specified in any published RFC. 2341 The initial entry in the registry comprises: 2343 +------+-----------+ 2344 | TYPE | REFERENCE | 2345 +------+-----------+ 2346 | rsa | [RFC3447] | 2347 +------+-----------+ 2349 DKIM Key Type Initial Values 2351 7.6. DKIM Hash Algorithms Registry 2353 The "h=" list (specified in Section 3.6.1) and the "a=" 2354 (Section 3.5) provide for a list of mechanisms that can 2355 be used to produce a digest of message data. 2357 IANA is requested to establish the DKIM Hash Algorithms Registry, for 2358 such mechanisms that have been specified in any published RFC. 2360 The initial entries in the registry comprise: 2362 +--------+-------------------+ 2363 | TYPE | REFERENCE | 2364 +--------+-------------------+ 2365 | sha1 | [FIPS.180-2.2002] | 2366 | sha256 | [FIPS.180-2.2002] | 2367 +--------+-------------------+ 2369 DKIM Hash Algorithms Initial Values 2371 7.7. DKIM Service Types Registry 2373 The "s=" list (specified in Section 3.6.1) provides for a 2374 list of service types to which this selector may apply. 2376 IANA is requested to establish the DKIM Service Types Registry, for 2377 service types that have been specified in any published RFC. 2379 The initial entries in the registry comprise: 2381 +-------+-----------------+ 2382 | TYPE | REFERENCE | 2383 +-------+-----------------+ 2384 | email | (this document) | 2385 | * | (this document) | 2386 +-------+-----------------+ 2388 DKIM Hash Algorithms Initial Values 2390 7.8. DKIM Selector Flags Registry 2392 The "t=" list (specified in Section 3.6.1) provides for a 2393 list of flags to modify interpretation of the selector. 2395 IANA is requested to establish the DKIM Selector Flags Registry, for 2396 additional flags that have been specified in any published RFC. 2398 The initial entries in the registry comprise: 2400 +------+-----------------+ 2401 | TYPE | REFERENCE | 2402 +------+-----------------+ 2403 | y | (this document) | 2404 | s | (this document) | 2405 +------+-----------------+ 2407 DKIM Hash Algorithms Initial Values 2409 7.9. DKIM-Signature Header Field 2411 IANA is requested to add DKIM-Signature to the "Permanent Message 2412 Header Fields" registry (see [RFC3864]) for the "mail" protocol, 2413 using this document as the Reference. 2415 8. Security Considerations 2417 It has been observed that any mechanism that is introduced which 2418 attempts to stem the flow of spam is subject to intensive attack. 2419 DKIM needs to be carefully scrutinized to identify potential attack 2420 vectors and the vulnerability to each. See also [RFC4686]. 2422 8.1. Misuse of Body Length Limits ("l=" Tag) 2424 Body length limits (in the form of the "l=" tag) are subject to 2425 several potential attacks. 2427 8.1.1. Addition of new MIME parts to multipart/* 2429 If the body length limit does not cover a closing MIME multipart 2430 section (including the trailing ""--CRLF"" portion), then it is 2431 possible for an attacker to intercept a properly signed multipart 2432 message and add a new body part. Depending on the details of the 2433 MIME type and the implementation of the verifying MTA and the 2434 receiving MUA, this could allow an attacker to change the information 2435 displayed to an end user from an apparently trusted source. 2437 For example, if an attacker can append information to a "text/html" 2438 body part, they may be able to exploit a bug in some MUAs that 2439 continue to read after a "" marker, and thus display HTML text 2440 on top of already displayed text. If a message has a 2441 "multipart/alternative" body part, they might be able to add a new 2442 body part that is preferred by the displaying MUA. 2444 8.1.2. Addition of new HTML content to existing content 2446 Several receiving MUA implementations do not cease display after a 2447 """" tag. In particular, this allows attacks involving 2448 overlaying images on top of existing text. 2450 INFORMATIVE EXAMPLE: Appending the following text to an existing, 2451 properly closed message will in many MUAs result in inappropriate 2452 data being rendered on top of existing, correct data: 2454
2455 2457
2459 8.2. Misappropriated Private Key 2461 If the private key for a user is resident on their computer and is 2462 not protected by an appropriately secure mechanism, it is possible 2463 for malware to send mail as that user and any other user sharing the 2464 same private key. The malware would, however, not be able to 2465 generate signed spoofs of other signers' addresses, which would aid 2466 in identification of the infected user and would limit the 2467 possibilities for certain types of attacks involving socially- 2468 engineered messages. This threat applies mainly to MUA-based 2469 implementations; protection of private keys on servers can be easily 2470 achieved through the use of specialized cryptographic hardware. 2472 A larger problem occurs if malware on many users' computers obtains 2473 the private keys for those users and transmits them via a covert 2474 channel to a site where they can be shared. The compromised users 2475 would likely not know of the misappropriation until they receive 2476 "bounce" messages from messages they are purported to have sent. 2477 Many users might not understand the significance of these bounce 2478 messages and would not take action. 2480 One countermeasure is to use a user-entered passphrase to encrypt the 2481 private key, although users tend to choose weak passphrases and often 2482 reuse them for different purposes, possibly allowing an attack 2483 against DKIM to be extended into other domains. Nevertheless, the 2484 decoded private key might be briefly available to compromise by 2485 malware when it is entered, or might be discovered via keystroke 2486 logging. The added complexity of entering a passphrase each time one 2487 sends a message would also tend to discourage the use of a secure 2488 passphrase. 2490 A somewhat more effective countermeasure is to send messages through 2491 an outgoing MTA that can authenticate the submitter using existing 2492 techniques (e.g., SMTP Authentication), possibly validate the message 2493 itself (e.g., verify that the header is legitimate and that the 2494 content passes a spam content check), and sign the message using a 2495 key appropriate for the submitter address. Such an MTA can also 2496 apply controls on the volume of outgoing mail each user is permitted 2497 to originate in order to further limit the ability of malware to 2498 generate bulk email. 2500 8.3. Key Server Denial-of-Service Attacks 2502 Since the key servers are distributed (potentially separate for each 2503 domain), the number of servers that would need to be attacked to 2504 defeat this mechanism on an Internet-wide basis is very large. 2505 Nevertheless, key servers for individual domains could be attacked, 2506 impeding the verification of messages from that domain. This is not 2507 significantly different from the ability of an attacker to deny 2508 service to the mail exchangers for a given domain, although it 2509 affects outgoing, not incoming, mail. 2511 A variation on this attack is that if a very large amount of mail 2512 were to be sent using spoofed addresses from a given domain, the key 2513 servers for that domain could be overwhelmed with requests. However, 2514 given the low overhead of verification compared with handling of the 2515 email message itself, such an attack would be difficult to mount. 2517 8.4. Attacks Against DNS 2519 Since DNS is a required binding for key services, specific attacks 2520 against DNS must be considered. 2522 While the DNS is currently insecure [RFC3833], these security 2523 problems are the motivation behind DNSSEC [RFC4033], and all users of 2524 the DNS will reap the benefit of that work. 2526 DKIM is only intended as a "sufficient" method of proving 2527 authenticity. It is not intended to provide strong cryptographic 2528 proof about authorship or contents. Other technologies such as 2529 OpenPGP [RFC2440] and S/MIME [RFC3851] address those requirements. 2531 A second security issue related to the DNS revolves around the 2532 increased DNS traffic as a consequence of fetching Selector-based 2533 data as well as fetching signing domain policy. Widespread 2534 deployment of DKIM will result in a significant increase in DNS 2535 queries to the claimed signing domain. In the case of forgeries on a 2536 large scale, DNS servers could see a substantial increase in queries. 2538 A specific DNS security issue which should be considered by DKIM 2539 verifiers is the name chaining attack described in section 2.3 of the 2540 DNS Threat Analysis [RFC3833]. A DKIM verifier, while verifying a 2541 DKIM-Signature header field, could be prompted to retrieve a key 2542 record of an attacker's choosing. This threat can be minimized by 2543 ensuring that name servers, including recursive name servers, used by 2544 the verifier enforce strict checking of "glue" and other additional 2545 information in DNS responses and are therefore not vulnerable to this 2546 attack. 2548 8.5. Replay Attacks 2550 In this attack, a spammer sends a message to be spammed to an 2551 accomplice, which results in the message being signed by the 2552 originating MTA. The accomplice resends the message, including the 2553 original signature, to a large number of recipients, possibly by 2554 sending the message to many compromised machines that act as MTAs. 2555 The messages, not having been modified by the accomplice, have valid 2556 signatures. 2558 Partial solutions to this problem involve the use of reputation 2559 services to convey the fact that the specific email address is being 2560 used for spam, and that messages from that signer are likely to be 2561 spam. This requires a real-time detection mechanism in order to 2562 react quickly enough. However, such measures might be prone to 2563 abuse, if for example an attacker resent a large number of messages 2564 received from a victim in order to make them appear to be a spammer. 2566 Large verifiers might be able to detect unusually large volumes of 2567 mails with the same signature in a short time period. Smaller 2568 verifiers can get substantially the same volume information via 2569 existing collaborative systems. 2571 8.6. Limits on Revoking Keys 2573 When a large domain detects undesirable behavior on the part of one 2574 of its users, it might wish to revoke the key used to sign that 2575 user's messages in order to disavow responsibility for messages which 2576 have not yet been verified or which are the subject of a replay 2577 attack. However, the ability of the domain to do so can be limited 2578 if the same key, for scalability reasons, is used to sign messages 2579 for many other users. Mechanisms for explicitly revoking keys on a 2580 per-address basis have been proposed but require further study as to 2581 their utility and the DNS load they represent. 2583 8.7. Intentionally malformed Key Records 2585 It is possible for an attacker to publish key records in DNS which 2586 are intentionally malformed, with the intent of causing a denial-of- 2587 service attack on a non-robust verifier implementation. The attacker 2588 could then cause a verifier to read the malformed key record by 2589 sending a message to one of its users referencing the malformed 2590 record in a (not necessarily valid) signature. Verifiers MUST 2591 thoroughly verify all key records retrieved from DNS and be robust 2592 against intentionally as well as unintentionally malformed key 2593 records. 2595 8.8. Intentionally Malformed DKIM-Signature header fields 2597 Verifiers MUST be prepared to receive messages with malformed DKIM- 2598 Signature header fields, and thoroughly verify the header field 2599 before depending on any of its contents. 2601 8.9. Information Leakage 2603 An attacker could determine when a particular signature was verified 2604 by using a per-message Selector and then monitoring their DNS traffic 2605 for the key lookup. This would act as the equivalent of a "web bug" 2606 for verification time rather than when the message was read. 2608 8.10. Remote Timing Attacks 2610 In some cases it may be possible to extract private keys using a 2611 remote timing attack [BONEH03]. Implementations should consider 2612 obfuscating the timing to prevent such attacks. 2614 8.11. Reordered Header Fields 2616 Existing standards allow intermediate MTAs to reorder header fields. 2617 If a signer signs two or more header fields of the same name, this 2618 can cause spurious verification errors on otherwise legitimate 2619 messages. In particular, signers that sign any existing DKIM- 2620 Signature fields run the risk of having messages incorrectly fail to 2621 verify. 2623 8.12. RSA Attacks 2625 An attacker could create a large RSA signing key with a small 2626 exponent, thus requiring that the verification key have a large 2627 exponent. This will force verifiers to use considerable computing 2628 resources to verify the signature. Verifiers might avoid this attack 2629 by refusing to verify signatures that reference selectors with public 2630 keys having unreasonable exponents. 2632 In general, an attacker might try to overwhelm a verifier by flooding 2633 it with messages requiring verification. This is similar to other 2634 MTA denial-of-service attacks and should be dealt with in a similar 2635 fashion. 2637 8.13. Inappropriate Signing by Parent Domains 2639 The trust relationship described in Section 3.8 could conceivably be 2640 used by a parent domain to sign messages with identities in a 2641 subdomain not administratively related to the parent. For example, 2642 the ".com" registry could create messages with signatures using an 2643 "i=" value in the example.com domain. There is no general solution 2644 to this problem, since the administrative cut could occur anywhere in 2645 the domain name. For example, in the domain "example.podunk.ca.us" 2646 there are three administrative cuts (podunk.ca.us, ca.us, and us), 2647 any of which could create messages with an identity in the full 2648 domain. 2650 INFORMATIVE NOTE: This is considered an acceptable risk for the 2651 same reason that it is acceptable for domain delegation. For 2652 example, in the example above any of the domains could potentially 2653 simply delegate "example.podunk.ca.us" to a server of their choice 2654 and completely replace all DNS-served information. Note that a 2655 verifier MAY ignore signatures that come from an unlikely domain 2656 such as ".com", as discussed in Section 6.1.1. 2658 9. References 2660 9.1. Normative References 2662 [FIPS.180-2.2002] 2663 U.S. Department of Commerce, "Secure Hash Standard", FIPS 2664 PUB 180-2, August 2002. 2666 [ITU.X660.1997] 2667 "Information Technology - ASN.1 encoding rules: 2668 Specification of Basic Encoding Rules (BER), Canonical 2669 Encoding Rules (CER) and Distinguished Encoding Rules 2670 (DER)", ITU-T Recommendation X.660, 1997. 2672 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 2673 Extensions (MIME) Part One: Format of Internet Message 2674 Bodies", RFC 2045, November 1996. 2676 [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail Extensions) 2677 Part Three: Message header field Extensions for Non-ASCII 2678 Text", RFC 2047, November 1996. 2680 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2681 Requirement Levels", BCP 14, RFC 2119, March 1997. 2683 [RFC2821] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821, 2684 April 2001. 2686 [RFC2822] Resnick, P., "Internet Message Format", RFC 2822, 2687 April 2001. 2689 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 2690 Standards (PKCS) #1: RSA Cryptography Specifications 2691 Version 2.1", RFC 3447, February 2003. 2693 [RFC3490] Faltstrom, P., Hoffman, P., and A. Costello, 2694 "Internationalizing Domain Names in Applications (IDNA)", 2695 RFC 3490, March 2003. 2697 [RFC4234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 2698 Specifications: ABNF", RFC 4234, October 2005. 2700 9.2. Informative References 2702 [BONEH03] Proc. 12th USENIX Security Symposium, "Remote Timing 2703 Attacks are Practical", 2003. 2705 [RFC-DK] "DomainKeys specification (to be published with this 2706 RFC)", 2005. 2708 [RFC1847] Galvin, J., Murphy, S., Crocker, S., and N. Freed, 2709 "Security Multiparts for MIME: Multipart/Signed and 2710 Multipart/Encrypted", RFC 1847, October 1995. 2712 [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for Writing an 2713 IANA Considers Section in RFCs", BCP 26, October 1998. 2715 [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, 2716 "OpenPGP Message Format", RFC 2440, November 1998. 2718 [RFC3766] Orman, H. and P. Hoffman, "Determining Strengths for 2719 Public Keys Used For Exchanging Symmetric Keys", RFC 3766, 2720 April 2004. 2722 [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the Domain 2723 Name System (DNS)", RFC 3833, August 2004. 2725 [RFC3851] Ramsdell, B., "S/MIME Version 3 Message Specification", 2726 RFC 3851, June 1999. 2728 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration 2729 Procedures for Message Header Fields", BCP 90, 2730 September 2004. 2732 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. 2733 Rose, "DNS Security Introduction and Requirements", 2734 RFC 4033, March 2005. 2736 [RFC4686] Fenton, J., "Analysis of Threats Motivating DomainKeys 2737 Identified Mail (DKIM)", RFC 4686, September 2006. 2739 Appendix A. Example of Use (INFORMATIVE) 2741 This section shows the complete flow of an email from submission to 2742 final delivery, demonstrating how the various components fit 2743 together. 2745 A.1. The user composes an email 2747 From: Joe SixPack 2748 To: Suzie Q 2749 Subject: Is dinner ready? 2750 Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) 2751 Message-ID: <20030712040037.46341.5F8J@football.example.com> 2753 Hi. 2755 We lost the game. Are you hungry yet? 2757 Joe. 2759 A.2. The email is signed 2761 This email is signed by the example.com outbound email server and now 2762 looks like this: 2764 DKIM-Signature: a=rsa-sha256; s=brisbane; d=example.com; 2765 c=simple; q=dns/txt; i=joe@football.example.com; 2766 h=Received : From : To : Subject : Date : Message-ID; 2767 bh=jpltwNFTq83Bkjt/Y2ekyqr/+i296daNkFZSdaz8VCY=; 2768 b=bnUoMBPJ5wBigyZG2V4OG2JxLWJATkSkb9Ig+8OAu3cE2x/er+B 2769 7Tp1a1kEwZKdOtlTHlvF4JKg6RZUbN5urRJoaiD4RiSbf8D6fmMHt 2770 zEn8/OHpTCcdLOJaTp8/mKz69/RpatVBas2OqWas7jrlaLGfHdBkt 2771 Hs6fxOzzAB7Wro=; 2772 Received: from client1.football.example.com [192.0.2.1] 2773 by submitserver.example.com with SUBMISSION; 2774 Fri, 11 Jul 2003 21:01:54 -0700 (PDT) 2775 From: Joe SixPack 2776 To: Suzie Q 2777 Subject: Is dinner ready? 2778 Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) 2779 Message-ID: <20030712040037.46341.5F8J@football.example.com> 2781 Hi. 2783 We lost the game. Are you hungry yet? 2785 Joe. 2787 The signing email server requires access to the private key 2788 associated with the "brisbane" Selector to generate this signature. 2790 A.3. The email signature is verified 2792 The signature is normally verified by an inbound SMTP server or 2793 possibly the final delivery agent. However, intervening MTAs can 2794 also perform this verification if they choose to do so. The 2795 verification process uses the domain "example.com" extracted from the 2796 "d=" tag and the Selector "brisbane" from the "s=" tag in the "DKIM- 2797 Signature" header field to form the DNS DKIM query for: 2799 brisbane._domainkey.example.com 2801 Signature verification starts with the physically last "Received" 2802 header field, the "From" header field, and so forth, in the order 2803 listed in the "h=" tag. Verification follows with a single CRLF 2804 followed by the body (starting with "Hi."). The email is canonically 2805 prepared for verifying with the "simple" method. The result of the 2806 query and subsequent verification of the signature is stored (in this 2807 example) in the "X-Authentication-Results" header field line. After 2808 successful verification, the email looks like this: 2810 X-Authentication-Results: shopping.example.net 2811 header.from=joe@football.example.com; dkim=pass 2812 Received: from mout23.football.example.com (192.168.1.1) 2813 by shopping.example.net with SMTP; 2814 Fri, 11 Jul 2003 21:01:59 -0700 (PDT) 2815 DKIM-Signature: a=rsa-sha256; s=brisbane; d=example.com; 2816 c=simple; q=dns/txt; i=joe@football.example.com; 2817 h=Received : From : To : Subject : Date : Message-ID; 2818 bh=jpltwNFTq83Bkjt/Y2ekyqr/+i296daNkFZSdaz8VCY=; 2819 b=bnUoMBPJ5wBigyZG2V4OG2JxLWJATkSkb9Ig+8OAu3cE2x/er+B 2820 7Tp1a1kEwZKdOtlTHlvF4JKg6RZUbN5urRJoaiD4RiSbf8D6fmMHt 2821 zEn8/OHpTCcdLOJaTp8/mKz69/RpatVBas2OqWas7jrlaLGfHdBkt 2822 Hs6fxOzzAB7Wro=; 2823 Received: from client1.football.example.com [192.0.2.1] 2824 by submitserver.example.com with SUBMISSION; 2825 Fri, 11 Jul 2003 21:01:54 -0700 (PDT) 2826 From: Joe SixPack 2827 To: Suzie Q 2828 Subject: Is dinner ready? 2829 Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) 2830 Message-ID: <20030712040037.46341.5F8J@football.example.com> 2832 Hi. 2834 We lost the game. Are you hungry yet? 2836 Joe. 2838 INFORMATIVE NOTE: The key used to compute this signature is shown 2839 in Appendix C. 2841 Appendix B. Usage Examples (INFORMATIVE) 2843 DKIM signing and validating can be used in different ways, for 2844 different operational scenarios. This Appendix discusses some common 2845 examples. 2847 NOTE: Descriptions in this Appendix are for informational 2848 purposes only. They describe various ways that DKIM can be used, 2849 given particular constraints and needs. In no case are these 2850 examples intended to be taken as providing explanation or guidance 2851 concerning DKIM specification details, when creating an 2852 implementation. 2854 B.1. Alternate Submission Scenarios 2856 In the most simple scenario, a user's MUA, MSA, and Internet 2857 (boundary) MTA are all within the same administrative environment, 2858 using the same domain name. Therefore, all of the components 2859 involved in submission and initial transfer are related. However it 2860 is common for two or more of the components to be under independent 2861 administrative control. This creates challenges for choosing and 2862 administering the domain name to use for signing, and for its 2863 relationship to common email identity header fields. 2865 B.1.1. Delegated Business Functions 2867 Some organizations assign specific business functions to discrete 2868 groups, inside or outside the organization. The goal, then, is to 2869 authorize that group to sign some mail, but to constrain what 2870 signatures they can generate. DKIM Selectors (the "s=" signature 2871 tag) and granularity (the "g=" key tag) facilitate this kind of 2872 restricted authorization. Examples of these outsourced business 2873 functions are legitimate email marketing providers and corporate 2874 benefits providers. 2876 Here, the delegated group needs to be able to send messages that are 2877 signed, using the email domain of the client company. At the same 2878 time, the client often is reluctant to register a key for the 2879 provider that grants the ability to send messages for arbitrary 2880 addresses in the domain. 2882 There are multiple ways to administer these usage scenarios. In one 2883 case, the client organization provides all of the public query 2884 service (for example, DNS) administration, and in another it uses DNS 2885 delegation to enable all on-going administration of the DKIM key 2886 record by the delegated group. 2888 If the client organization retains responsibility for all of the DNS 2889 administration, the outsourcing company can generate a key pair, 2890 supplying the public key to the client company, which then registers 2891 it in the query service, using a unique Selector that authorizes a 2892 specific From header field local-part. For example, a client with 2893 the domain "example.com" could have the Selector record specify 2894 "g=winter-promotions" so that this signature is only valid for mail 2895 with a From address of "winter-promotions@example.com". This would 2896 enable the provider to send messages using that specific address and 2897 have them verify properly. The client company retains control over 2898 the email address because it retains the ability to revoke the key at 2899 any time. 2901 If the client wants the delegated group to do the DNS administration, 2902 it can have the domain name that is specified with the selector point 2903 to the provider's DNS server. The provider then creates and 2904 maintains all of the DKIM signature information for that Selector. 2905 Hence, the client cannot provide constraints on the local-part of 2906 addresses that get signed, but it can revoke the provider's signing 2907 rights by removing the DNS delegation record. 2909 B.1.2. PDAs and Similar Devices 2911 PDAs demonstrate the need for using multiple keys per domain. 2912 Suppose that John Doe wanted to be able to send messages using his 2913 corporate email address, jdoe@example.com, and his email device did 2914 not have the ability to make a VPN connection to the corporate 2915 network, either because the device is limited or because there are 2916 restrictions enforced by his Internet access provider. If the device 2917 was equipped with a private key registered for jdoe@example.com by 2918 the administrator of the example.com domain, and appropriate software 2919 to sign messages, John could sign the message on the device itself 2920 before transmission through the outgoing network of the access 2921 service provider. 2923 B.1.3. Roaming Users 2925 Roaming users often find themselves in circumstances where it is 2926 convenient or necessary to use an SMTP server other than their home 2927 server; examples are conferences and many hotels. In such 2928 circumstances a signature that is added by the submission service 2929 will use an identity that is different from the user's home system. 2931 Ideally roaming users would connect back to their home server using 2932 either a VPN or a SUBMISSION server running with SMTP AUTHentication 2933 on port 587. If the signing can be performed on the roaming user's 2934 laptop then they can sign before submission, although the risk of 2935 further modification is high. If neither of these are possible, 2936 these roaming users will not be able to send mail signed using their 2937 own domain key. 2939 B.1.4. Independent (Kiosk) Message Submission 2941 Stand-alone services, such as walk-up kiosks and web-based 2942 information services, have no enduring email service relationship 2943 with the user, but the user occasionally requests that mail be sent 2944 on their behalf. For example, a website providing news often allows 2945 the reader to forward a copy of the article to a friend. This is 2946 typically done using the reader's own email address, to indicate who 2947 the author is. This is sometimes referred to as the "Evite problem", 2948 named after the website of the same name that allows a user to send 2949 invitations to friends. 2951 A common way this is handled is to continue to put the reader's email 2952 address in the From header field of the message, but put an address 2953 owned by the email posting site into the Sender header field. The 2954 posting site can then sign the message, using the domain that is in 2955 the Sender field. This provides useful information to the receiving 2956 email site, which is able to correlate the signing domain with the 2957 initial submission email role. 2959 Receiving sites often wish to provide their end users with 2960 information about mail that is mediated in this fashion. Although 2961 the real efficacy of different approaches is a subject for human 2962 factors usability research, one technique that is used is for the 2963 verifying system to rewrite the From header field, to indicate the 2964 address that was verified. For example: From: John Doe via 2965 news@news-site.com . (Note that, such rewriting 2966 will break a signature, unless it is done after the verification pass 2967 is complete.) 2969 B.2. Alternate Delivery Scenarios 2971 Email is often received at a mailbox that has an address different 2972 from the one used during initial submission. In these cases, an 2973 intermediary mechanism operates at the address originally used and it 2974 then passes the message on to the final destination. This mediation 2975 process presents some challenges for DKIM signatures. 2977 B.2.1. Affinity Addresses 2979 "Affinity addresses" allow a user to have an email address that 2980 remains stable, even as the user moves among different email 2981 providers. They are typically associated with college alumni 2982 associations, professional organizations, and recreational 2983 organizations with which they expect to have a long-term 2984 relationship. These domains usually provide forwarding of incoming 2985 email, and they often have an associated Web application which 2986 authenticates the user and allows the forwarding address to be 2987 changed. However these services usually depend on the user's sending 2988 outgoing messages through their own service provider's MTA. Hence, 2989 mail that is signed with the domain of the affinity address is not 2990 signed by an entity that is administered by the organization owning 2991 that domain. 2993 With DKIM, affinity domains could use the Web application to allow 2994 users to register per-user keys to be used to sign messages on behalf 2995 of their affinity address. The user would take away the secret half 2996 of the key pair for signing, and the affinity domain would publish 2997 the public half in DNS for access by verifiers. 2999 This is another application that takes advantage of user-level 3000 keying, and domains used for affinity addresses would typically have 3001 a very large number of user-level keys. Alternatively, the affinity 3002 domain could handle outgoing mail, operating a mail submission agent 3003 that authenticates users before accepting and signing messages for 3004 them. This is of course dependent on the user's service provider not 3005 blocking the relevant TCP ports used for mail submission. 3007 B.2.2. Simple Address Aliasing (.forward) 3009 In some cases a recipient is allowed to configure an email address to 3010 cause automatic redirection of email messages from the original 3011 address to another, such as through the use of a Unix .forward file. 3012 In this case messages are typically redirected by the mail handling 3013 service of the recipient's domain, without modification, except for 3014 the addition of a Received header field to the message and a change 3015 in the envelope recipient address. In this case, the recipient at 3016 the final address' mailbox is likely to be able to verify the 3017 original signature since the signed content has not changed, and DKIM 3018 is able to validate the message signature. 3020 B.2.3. Mailing Lists and Re-Posters 3022 There is a wide range of behaviors in services that take delivery of 3023 a message and then resubmit it. A primary example is with mailing 3024 lists (collectively called "forwarders" below), ranging from those 3025 which make no modification to the message itself, other than to add a 3026 Received header field and change the envelope information, to those 3027 which add header fields, change the Subject header field, add content 3028 to the body (typically at the end), or reformat the body in some 3029 manner. The simple ones produces messages that are quite similar to 3030 the automated alias services. More elaborate systems essentially 3031 create a new message. 3033 A Forwarder which does not modify the body or signed header fields of 3034 a message is likely to maintain the validity of the existing 3035 signature. It also could choose to add its own signature to the 3036 message. 3038 Forwarders which modify a message in a way that could make an 3039 existing signature invalid are particularly good candidates for 3040 adding their own signatures (e.g., mailing-list-name@example.net). 3041 Since (re-)signing is taking responsibility for the content of the 3042 message, these signing forwarders are likely to be selective, and 3043 forward or re-sign only those messages which are received with a 3044 valid signature or some other basis for knowing that the messages 3045 being signed is not spoofed. 3047 A common practice among systems that are primarily re-distributors of 3048 mail is to add a Sender header field to the message, to identify the 3049 address being used to sign the message. This practice will remove 3050 any preexisting Sender header field as required by [RFC2822]. The 3051 forwarder applies a new DKIM-Signature header field with the 3052 signature, public key, and related information of the forwarder. 3054 Appendix C. Creating a public key (INFORMATIVE) 3056 The default signature is an RSA signed SHA256 digest of the complete 3057 email. For ease of explanation, the openssl command is used to 3058 describe the mechanism by which keys and signatures are managed. One 3059 way to generate a 1024 bit, unencrypted private key suitable for 3060 DKIM, is to use openssl like this: 3062 $ openssl genrsa -out rsa.private 1024 3064 For increased security, the "-passin" parameter can also be added to 3065 encrypt the private key. Use of this parameter will require entering 3066 a password for several of the following steps. Servers may prefer to 3067 use hardware cryptographic support. 3069 The "genrsa" step results in the file rsa.private containing the key 3070 information similar to this: 3072 -----BEGIN RSA PRIVATE KEY----- 3073 MIICXwIBAAKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYtIxN2SnFC 3074 jxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/RtdC2UzJ1lWT947qR+Rcac2gb 3075 to/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB 3076 AoGBALmn+XwWk7akvkUlqb+dOxyLB9i5VBVfje89Teolwc9YJT36BGN/l4e0l6QX 3077 /1//6DWUTB3KI6wFcm7TWJcxbS0tcKZX7FsJvUz1SbQnkS54DJck1EZO/BLa5ckJ 3078 gAYIaqlA9C0ZwM6i58lLlPadX/rtHb7pWzeNcZHjKrjM461ZAkEA+itss2nRlmyO 3079 n1/5yDyCluST4dQfO8kAB3toSEVc7DeFeDhnC1mZdjASZNvdHS4gbLIA1hUGEF9m 3080 3hKsGUMMPwJBAPW5v/U+AWTADFCS22t72NUurgzeAbzb1HWMqO4y4+9Hpjk5wvL/ 3081 eVYizyuce3/fGke7aRYw/ADKygMJdW8H/OcCQQDz5OQb4j2QDpPZc0Nc4QlbvMsj 3082 7p7otWRO5xRa6SzXqqV3+F0VpqvDmshEBkoCydaYwc2o6WQ5EBmExeV8124XAkEA 3083 qZzGsIxVP+sEVRWZmW6KNFSdVUpk3qzK0Tz/WjQMe5z0UunY9Ax9/4PVhp/j61bf 3084 eAYXunajbBSOLlx4D+TunwJBANkPI5S9iylsbLs6NkaMHV6k5ioHBBmgCak95JGX 3085 GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc= 3086 -----END RSA PRIVATE KEY----- 3088 To extract the public-key component from the private key, use openssl 3089 like this: 3091 $ openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM 3093 This results in the file rsa.public containing the key information 3094 similar to this: 3096 -----BEGIN PUBLIC KEY----- 3097 MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkM 3098 oGeLnQg1fWn7/zYtIxN2SnFCjxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/R 3099 tdC2UzJ1lWT947qR+Rcac2gbto/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToI 3100 MmPSPDdQPNUYckcQ2QIDAQAB 3101 -----END PUBLIC KEY----- 3103 This public-key data (without the BEGIN and END tags) is placed in 3104 the DNS. With the signature, canonical email contents, and public 3105 key, a verifying system can test the validity of the signature. The 3106 openssl invocation to verify a signature looks like this: 3108 openssl dgst -verify rsa.public -sha256 -signature signature.file \ 3109