DKIM E. Allman Internet-Draft Sendmail, Inc. Expires:June 7,July 22, 2007 J. Callas PGP Corporation M. Delany M. Libbey Yahoo! Inc J. Fenton M. Thomas Cisco Systems, Inc.December 4, 2006January 18, 2007 DomainKeys Identified Mail (DKIM) Signaturesdraft-ietf-dkim-base-07draft-ietf-dkim-base-08 Status of this Memo By submitting this Internet-Draft, each author represents that any applicable patent or other IPR claims of which he or she is aware have been or will be disclosed, and any of which he or she becomes aware will be disclosed, in accordance with Section 6 of BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet- Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. This Internet-Draft will expire onJune 7,July 22, 2007. Copyright Notice Copyright (C) The Internet Society(2006).(2007). Abstract DomainKeys Identified Mail (DKIM) defines a domain-level authentication framework for email using public-key cryptography and key server technology to permit verification of the source and contents of messages by either Mail Transfer Agents (MTAs) or Mail User Agents (MUAs). The ultimate goal of this framework is to permit a signing domain to assert responsibility for a message, thus protecting message signer identity and the integrity of the messages they convey while retaining the functionality of Internet email as it is known today. Protection of email identity may assist in the global control of "spam" and "phishing". Requirements Language The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1 Signing Identity . . . . . . . . . . . . . . . . . . . . . 6 1.2 Scalability . . . . . . . . . . . . . . . . . . . . . . . 6 1.3 Simple Key Management . . . . . . . . . . . . . . . . . . 6 2. Terminology and Definitions . . . . . . . . . . . . . . . . 6 2.1 Signers . . . . . . . . . . . . . . . . . . . . . . . . .76 2.2 Verifiers . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3 White Space . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 Common ABNF Tokens . . . . . . . . . . . . . . . . . . . . 7 2.5 Imported ABNF Tokens . . . . . . . . . . . . . . . . . . . 8 2.6 DKIM-Quoted-Printable . . . . . . . . . . . . . . . . . . 8 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . 9 3.1 Selectors . . . . . . . . . . . . . . . . . . . . . . . . 9 3.2 Tag=Value Lists . . . . . . . . . . . . . . . . . . . . . 11 3.3 Signing and Verification Algorithms . . . . . . . . . . . 12 3.4 Canonicalization . . . . . . . . . . . . . . . . . . . . . 14 3.5 The DKIM-Signature header field . . . . . . . . . . . . . 18 3.6 Key Management and Representation . . . . . . . . . . . .2526 3.7 Computing the Message Hashes . . . . . . . . . . . . . . . 30 3.8 Signing by Parent Domains . . . . . . . . . . . . . . . . 32 4. Semantics of Multiple Signatures . . . . . . . . . . . . . .3233 4.1 Example Scenarios . . . . . . . . . . . . . . . . . . . . 33 4.2 Interpretation . . . . . . . . . . . . . . . . . . . . . . 34 5. Signer Actions . . . . . . . . . . . . . . . . . . . . . . .3335 5.1 Determine if the Email Should be Signed and by Whom . . .3335 5.2 Select aprivate-keyPrivate Key andcorresponding selector informationCorresponding Selector Information . . . . . . . . . . . . . . . . . . . . . . .3336 5.3 Normalize the Message to Prevent Transport Conversions . .3436 5.4 Determine theheader fieldsHeader Fields to Sign . . . . . . . . . . .3437 5.5 Compute the Message Hash and Signature . . . . . . . . . .3640 5.6 Insert the DKIM-Signatureheader fieldHeader Field . . . . . . . . . .3740 6. Verifier Actions . . . . . . . . . . . . . . . . . . . . . .3741 6.1 Extract Signatures from the Message . . . . . . . . . . .3841 6.2 Communicate Verification Results . . . . . . . . . . . . .4347 6.3 Interpret Results/Apply Local Policy . . . . . . . . . . .4447 7. IANA Considerations . . . . . . . . . . . . . . . . . . . .4549 7.1 DKIM-Signature Tag Specifications . . . . . . . . . . . .4549 7.2 DKIM-Signature Query Method Registry . . . . . . . . . . .4649 7.3 DKIM-Signature Canonicalization Registry . . . . . . . . .4650 7.4 _domainkey DNS TXT Record Tag Specifications . . . . . . .4750 7.5 DKIM Key Type Registry . . . . . . . . . . . . . . . . . .4851 7.6 DKIM Hash Algorithms Registry . . . . . . . . . . . . . .4851 7.7 DKIM Service Types Registry . . . . . . . . . . . . . . .4852 7.8 DKIM Selector Flags Registry . . . . . . . . . . . . . . .4952 7.9 DKIM-Signature Header Field . . . . . . . . . . . . . . .4953 8. Security Considerations . . . . . . . . . . . . . . . . . .4953 8.1 Misuse of Body Length Limits ("l=" Tag) . . . . . . . . .4953 8.2 Misappropriated Private Key . . . . . . . . . . . . . . .5054 8.3 Key Server Denial-of-Service Attacks . . . . . . . . . . .5154 8.4 Attacks Against DNS . . . . . . . . . . . . . . . . . . .5155 8.5 Replay Attacks . . . . . . . . . . . . . . . . . . . . . .5255 8.6 Limits on Revoking Keys . . . . . . . . . . . . . . . . .5356 8.7 Intentionally malformed Key Records . . . . . . . . . . .5356 8.8 Intentionally Malformed DKIM-Signature header fields . . .5356 8.9 Information Leakage . . . . . . . . . . . . . . . . . . .5357 8.10 Remote Timing Attacks . . . . . . . . . . . . . . . . .5357 8.11 Reordered Header Fields . . . . . . . . . . . . . . . .5457 8.12 RSA Attacks . . . . . . . . . . . . . . . . . . . . . . 57 8.13 Inappropriate Signing by Parent Domains . . . . . . . . 57 9. References . . . . . . . . . . . . . . . . . . . . . . . . .5458 9.1 Normative References . . . . . . . . . . . . . . . . . . .5458 9.2 Informative References . . . . . . . . . . . . . . . . . .5559 Authors' Addresses . . . . . . . . . . . . . . . . . . . . .5559 A. Example of Use (INFORMATIVE) . . . . . . . . . . . . . . . .5761 A.1 The user composes an email . . . . . . . . . . . . . . . .5761 A.2 The email is signed . . . . . . . . . . . . . . . . . . .5761 A.3 The email signature is verified . . . . . . . . . . . . .5862 B. Usage Examples (INFORMATIVE) . . . . . . . . . . . . . . . .5963 B.1 Alternate Submission Scenarios . . . . . . . . . . . . . .5964 B.2 Alternate Delivery Scenarios . . . . . . . . . . . . . . .6266 C. Creating a public key (INFORMATIVE) . . . . . . . . . . . .6468 D. MUA Considerations . . . . . . . . . . . . . . . . . . . . .6570 E. Acknowledgements . . . . . . . . . . . . . . . . . . . . . .6670 F. Edit History . . . . . . . . . . . . . . . . . . . . . . . .6671 F.1 Changes since-ietf-06-ietf-07 version . . . . . . . . . . . . . .6771 F.2 Changes since-ietf-05-ietf-06 version . . . . . . . . . . . . . .6772 F.3 Changes since-ietf-04-ietf-05 version . . . . . . . . . . . . . .6873 F.4 Changes since-ietf-03-ietf-04 version . . . . . . . . . . . . . .6873 F.5 Changes since-ietf-02-ietf-03 version . . . . . . . . . . . . . .6974 F.6 Changes since-ietf-01-ietf-02 version . . . . . . . . . . . . . .7075 F.7 Changes since-ietf-00-ietf-01 version . . . . . . . . . . . . . .7176 F.8 Changes since-allman-01-ietf-00 version . . . . . . . . . . . . .71. 76 F.9 Changes since-allman-00-allman-01 version . . . . . . . . . . . . .7277 F.10 Changes since -allman-00 version . . . . . . . . . . . . 77 Intellectual Property and Copyright Statements . . . . . . .7379 1. Introduction [[Note: text in double square brackets (such as this text) will be deleted before publication.]] DomainKeys Identified Mail (DKIM) defines a mechanism by which email messages can be cryptographically signed, permitting a signing domain to claim responsibility for the introduction of a message into the mail stream. Message recipients can verify the signature by querying the signer's domain directly to retrieve the appropriate public key, and thereby confirm that the message was attested to by a party in possession of the private key for the signing domain. The approach taken by DKIM differs from previous approaches to message signing (e.g. S/MIME [RFC1847], OpenPGP [RFC2440]) in that: o the message signature is written as a message header field so that neither human recipients nor existing MUA (Mail User Agent) software are confused by signature-related content appearing in the message body; o there is no dependency on public and private key pairs being issued by well-known, trusted certificate authorities; o there is no dependency on the deployment of any new Internet protocols or services for public key distribution or revocation; o signature verification failure does not force rejection of the message; o no attempt is made to include encryption as part of the mechanism; o message archiving is not a design goal. DKIM: o is compatible with the existing email infrastructure and transparent to the fullest extent possible; o requires minimal new infrastructure; o can be implemented independently of clients in order to reduce deployment time; odoes not require the use of an additional trusted third party (such as a certificate authority or other entity) which might impose significant costs or introduce delays to deployment; ocan be deployed incrementally; o allows delegation of signing to third parties. 1.1 Signing Identity DKIM separates the question of the identity of the signer of the message from the purported author of the message. In particular, a signature includes the identity of the signer. Verifiers can use the signing information to decide how they want to process the message. The signing identity is included as part of the signature header field. INFORMATIVE RATIONALE: The signing identity specified by a DKIM signature is not required to match an address in any particular header field because of the broad methods of interpretation by recipient mail systems, including MUAs. 1.2 Scalability DKIM is designed to support the extreme scalability requirements which characterize the email identification problem. There are currently over 70 million domains and a much larger number of individual addresses. DKIM seeks to preserve the positive aspects of the current email infrastructure, such as the ability for anyone to communicate with anyone else without introduction. 1.3 Simple Key Management DKIM differs from traditional hierarchical public-key systems in that no Certificate Authority infrastructure is required; the verifier requests the public key from a repository in the domain of the claimed signer directly rather than from a third party. The DNS is proposed as the initial mechanism for the public keys. Thus, DKIM currently depends on DNSadminstrationadministration and the security of the DNS system. DKIM is designed to be extensible to other key fetching services as they become available. 2. Terminology and Definitions This section defines terms used in the rest of the document. Syntax descriptions use the form described in Augmented BNF for Syntax Specifications [RFC4234]. 2.1 Signers Elements in the mail system that sign messagesareon behalf of a domain are referred to as signers. These may be MUAs (Mail User Agents), MSAs (Mail Submission Agents), MTAs (Mail Transfer Agents), or other agents such as mailing list exploders. In general any signer will be involved in the injection of a message into the message system in some way. The key issue is that a message must be signed before it leaves the administrative domain of the signer. 2.2 Verifiers Elements in the mail system that verify signatures are referred to as verifiers. These may be MTAs, Mail Delivery Agents (MDAs), or MUAs. In most cases it is expected that verifiers will be close to an end user (reader) of the message or some consuming agent such as a mailing list exploder. 2.3 White Space There are three forms of white space: o WSP represents simple white space, i.e., a space or a tab character (formal definition in [RFC4234]). o LWSP is linear white space, defined as WSP plus CRLF (formal definition in [RFC4234]). o FWS is folding white space. It allows multiple lines separated by CRLF followed by at least one white space, to be joined. The formal ABNF for these are (WSP and LWSP are given for information only): WSP = SP / HTAB LWSP = *(WSP / CRLF WSP) FWS = [*WSP CRLF] 1*WSP The definition of FWS is identical to that in [RFC2822] except for the exclusion of obs-FWS. 2.4 Common ABNF Tokens The following ABNF tokens are used elsewhere in this document. hyphenated-word = ALPHA [ *(ALPHA / DIGIT / "-") (ALPHA / DIGIT) ] base64string = 1*(ALPHA / DIGIT / "+" / "/" / LWSP) [ "="*LWSPLWSP [ "="*LWSPLWSP ] ] 2.5 Imported ABNF Tokens The following tokens are imported from other RFCs as noted. Those RFCs should be considered definitive. The following tokens are imported from [RFC2821]: o "Local-part" (implementation warning: this permits quoted strings) o "sub-domain" The following tokens are imported from [RFC2822]: o "field-name" (name of a header field) o "dot-atom-text" (in the local-part of an email address) The following tokens are imported from [RFC2045]: o "qp-section" (a single line of quoted-printable-encoded text) o "hex-octet" (a quoted-printable encoded octet) INFORMATIVE NOTE: Be aware that the ABNF in RFC 2045 does not obey the rules of RFC 4234 and must be interpreted accordingly, particularly as regards case folding. Other tokens not defined herein are imported from [RFC4234]. These are intuitive primitives such as SP, HTAB, WSP, ALPHA, DIGIT, CRLF, etc. 2.6 DKIM-Quoted-Printable The DKIM-Quoted-Printable encoding syntax resembles that described in Quoted-Printable [RFC2045] section 6.7: any character MAY be encoded as an "=" followed by two hexadecimal digits from the alphabet "0123456789ABCDEF" (no lower case characters permitted) representing the hexadecimal-encoded integer value of that character. All control characters (those with values < %x20), eight-bit characters (values > %x7F), and the characters DEL (%x7F), SPACE (%x20), and semicolon (";", %x3B) MUST be encoded. Note that all white space, including SPACE, CR and LF characters, MUST be encoded. After encoding, FWS MAY be added at arbitrary locations in order to avoid excessively long lines; such white space is NOT part of the value, and MUST be removed before decoding. ABNF: dkim-quoted-printable = *(FWS / hex-octet / dkim-safe-char) ; hex-octet is from RFC 2045 dkim-safe-char = %x21-3A / %x3C / %x3E-7E ; '!' - ':', '<', '>' - '~' ; Characters not listed as "mail-safe" in ; RFC 2049 are also not recommended. INFORMATIVE NOTE: DKIM-Quoted-Printable differs from Quoted- Printable as defined in RFC 2045 in several important ways: 1. White space in the input text, including CR and LF, must be encoded. RFC 2045 does not require such encoding, and does not permit encoding of CR or LF characters that are part of a CRLF line break. 2. White space in the encoded text is ignored. This is to allow tags encoded using DKIM-Quoted-Printable to be wrapped as needed. In particular, RFC 2045 requires that line breaks in the input be represented as physical line breaks; that is not the case here. 3. The "soft line break" syntax ("=" as the last non-white-space character on the line) does not apply. 4. DKIM-Quoted-Printable does not require that encoded lines be no more than 76 characters long (although there may be other requirements depending on the context in which the encoded text is being used). 3. Protocol Elements Protocol Elements are conceptual parts of the protocol that are not specific to either signers or verifiers. The protocol descriptions for signers and verifiers are described in later sections (Signer Actions (Section 5) and Verifier Actions (Section 6)). NOTE: This section must be read in the context of those sections. 3.1 Selectors To support multiple concurrent public keys per signing domain, the key namespace is subdivided using "Selectors". For example, Selectors might indicate the names of office locations (e.g., "sanfrancisco", "coolumbeach", and "reykjavik"), the signing date (e.g., "january2005", "february2005", etc.), or even the individual user. Selectors are needed to support some important use cases. For example: o Domains which want to delegate signing capability for a specific address for a given duration to a partner, such as an advertising provider or other out-sourced function. o Domains which want to allow frequent travelers to send messages locally without the need to connect with a particular MSA. o "Affinity" domains (e.g., college alumni associations) which provide forwarding of incoming mail but which do not operate a mail submission agent for outgoing mail. Periods are allowed in Selectors and are component separators. When keys are retrieved from the DNS, periods in Selectors define DNS label boundaries in a manner similar to the conventional use in domain names. Selector components might be used to combine dates with locations; for example, "march2005.reykjavik". In a DNS implementation, this can be used to allow delegation of a portion of the Selector name-space. ABNF: selector = sub-domain *( "." sub-domain ) The number of public keys and corresponding Selectors for each domain are determined by the domain owner. Many domain owners will be satisfied with just one Selector whereas administratively distributed organizations may choose to manage disparate Selectors and key pairs in different regions or on different email servers. Beyond administrative convenience, Selectors make it possible to seamlessly replace public keys on a routine basis. If a domain wishes to change from using a public key associated with Selector "january2005" to a public key associated with Selector "february2005", it merely makes sure that both public keys are advertised in the public-key repository concurrently for the transition period during which email may be in transit prior to verification. At the start of the transition period, the outbound email servers are configured to sign with the "february2005"private-private key. At the end of the transition period, the "january2005" public key is removed from the public-key repository. INFORMATIVE NOTE: A key may also be revoked as described below. The distinction between revoking and removing a key selector record is subtle. When phasing out keys as described above, a signing domain would probably simply remove the key record after the transition period. However, a signing domain could elect to revoke the key (but maintain the key record) for a further period. There is no defined semantic difference between a revoked key and a removed key. While some domains may wish to make Selector values well known, others will want to take care not to allocate Selector names in a way that allows harvesting of data by outside parties. For example, if per-user keys are issued, the domain owner will need to make the decision as to whether to associate this Selector directly with the user name, or make it some unassociated random value, such as a fingerprint of the public key. INFORMATIVE OPERATIONS NOTE: Reusing a Selector with a new key (for example, changing the key associated with a user's name) makes it impossible to tell the difference between a message that didn't verify because the key is no longer valid versus a message that is actually forged.Signers SHOULD NOT change the key associated with a Selector. When creating a new key,For this reason, signersSHOULD associate it with aare ill-advised to reuse selectors for newSelector.keys. A better strategy is to assign new keys to new selectors. 3.2 Tag=Value Lists DKIM uses a simple "tag=value" syntax in several contexts, including in messages and domain signature records. Values are a series of strings containing either plain text, "base64" text (as defined in [RFC2045], section 6.8), "qp-section" (ibid, section 6.7), or "dkim-quoted-printable" (as defined in Section 2.6). The name of the tag will determine the encoding of each value. Unencoded semicolon (";") characters MUST NOT occur in the tag value, since that separates tag-specs. INFORMATIVE IMPLEMENTATION NOTE: Although the "plain text" defined below (as "tag-value") only includes 7-bit characters, an implementation that wished to anticipate future standards would be advised to not preclude the use of UTF8-encoded text in tag=value lists. Formally, the syntax rules are: tag-list = tag-spec 0*( ";" tag-spec ) [ ";" ] tag-spec = [FWS] tag-name [FWS] "=" [FWS] tag-value [FWS] tag-name = ALPHA 0*ALNUMPUNC tag-value = [ tval 0*( 1*(WSP / FWS) tval ) ] ; WSP and FWS prohibited at beginning and end tval = 1*VALCHAR VALCHAR = %x21-3A / %x3C-7E ; EXCLAMATION to TILDE except SEMICOLON ALNUMPUNC = ALPHA / DIGIT / "_" Note that WSP is allowed anywhere around tags; in particular, any WSP after the "=" and any WSP before the terminating ";" is not part of the value; however, WSP inside the value is significant. Tags MUST be interpreted in a case-sensitive manner. Values MUST be processed as case sensitive unless the specific tag description of semantics specifies case insensitivity. Tags with duplicate names MUST NOT occur within a single tag-list; if a tag name does occur more than once, the entire tag-list is invalid. Whitespace within a value MUST be retained unless explicitly excluded by the specific tag description. Tag=value pairs that represent the default value MAY be included to aid legibility. Unrecognized tags MUST be ignored. Tags that have an empty value are not the same as omitted tags. An omitted tag is treated as having the default value; a tag with an empty value explicitly designates the empty string as the value. For example, "g=" does not mean "g=*", even though "g=*" is the default for that tag. 3.3 Signing and Verification Algorithms DKIM supports multiple digital signature algorithms. Two algorithms are defined by this specification at this time: rsa-sha1, and rsa- sha256. The rsa-sha256 algorithm is the default if no algorithm is specified. Verifiers MUST implement both rsa-sha1 and rsa-sha256. Signers MUST implement and SHOULD sign using rsa-sha256. INFORMATIVE NOTE: Although sha256 is strongly encouraged, some senders of low-security messages (such as routine newsletters) may prefer to use sha1 because of reduced CPU requirements to compute a sha1 hash. In general, sha256 should always be used whenever possible. 3.3.1 The rsa-sha1 Signing Algorithm The rsa-sha1 Signing Algorithm computes a message hash as described in Section 3.7 below using SHA-1 [SHA] as the hash-alg. That hash is then signed by the signer using the RSA algorithm (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the signer's private key. The hash MUST NOT be truncated or converted into any form other than the native binary form before being signed. INFORMATIVE IMPLEMENTATION WARNING: Low-valued exponents should be avoided, as they are believed to be subject to attack. 3.3.2 The rsa-sha256 Signing Algorithm The rsa-sha256 Signing Algorithm computes a message hash as described in Section 3.7 below using SHA-256 [SHA] as the hash-alg. That hash is then signed by the signer using the RSA algorithm (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the signer's private key. The hash MUST NOT be truncated or converted into any form other than the native binary form before being signed. 3.3.3 Key sizes Selecting appropriate key sizes is a trade-off between cost, performance and risk. Since short RSA keys more easily succumb to off-line attacks, signers MUST use RSA keys of at least 1024 bits for long-lived keys. Verifiers MUST be able to validate signatures with keys ranging from 512 bits to 2048 bits, and they MAY be able to validate signatures with larger keys. Verifier policies may use the length of the signing key as one metric for determining whether a signature is acceptable. Factors that should influence the key size choice include: o The practical constraint that large (e.g., 4096 bit) keys may not fit within a 512 byte DNS UDP response packet o The security constraint that keys smaller than 1024 bits are subject to off-line attacks o Larger keys impose higher CPU costs to verify and sign email o Keys can be replaced on a regular basis, thus their lifetime can be relatively short o The security goals of this specification are modest compared to typical goals of other systems that employ digital signatures See [RFC3766] for further discussion on selecting key sizes. 3.3.4 Other algorithms Other algorithms MAY be defined in the future. Verifiers MUST ignore any signatures using algorithms that they do not implement. 3.4 Canonicalization Empirical evidence demonstrates that some mail servers and relay systems modify email in transit, potentially invalidating a signature. There are two competing perspectives on such modifications. For most signers, mild modification of email is immaterial to the authentication status of the email. For such signers a canonicalization algorithm that survives modest in-transit modification is preferred. Other signers demand that any modification of the email, however minor, result in a signature verification failure. These signers prefer a canonicalization algorithm that does not tolerate in-transit modification of the signed email. Some signers may be willing to accept modifications to header fields that are within the bounds of email standards such as [RFC2822], but are unwilling to accept any modification to the body of messages. To satisfy all requirements, two canonicalization algorithms are defined for each of the header and the body: a "simple" algorithm that tolerates almost no modification and a "relaxed" algorithm that tolerates common modifications such as white-space replacement and header field line re-wrapping. A signer MAY specify either algorithm for header or body when signing an email. If no canonicalization algorithm is specified by the signer, the "simple" algorithm defaults for both header and body. Verifiers MUST implement both canonicalization algorithms. Note that the header and body may use different canonicalization algorithms. Further canonicalization algorithms MAY be defined in the future; verifiers MUST ignore any signatures that use unrecognized canonicalization algorithms. Canonicalization simply prepares the email for presentation to the signing or verification algorithm. It MUST NOT change the transmitted data in any way. Canonicalization of header fields and body are described below. NOTE: This section assumes that the message is already in "network normal" format (e.g., text is ASCII encoded, lines are separated with CRLF characters, etc.). See also Section 5.3 for information about normalizing the message. 3.4.1 The "simple" Header Canonicalization Algorithm The "simple" header canonicalization algorithm does not change header fields in any way. Header fields MUST be presented to the signing or verification algorithm exactly as they are in the message being signed or verified. In particular, header field names MUST NOT be case folded and white space MUST NOT be changed. 3.4.2 The "relaxed" Header Canonicalization Algorithm The "relaxed" header canonicalization algorithm MUST apply the following steps in order: o Convert all header field names (not the header field values) to lower case. For example, convert "SUBJect: AbC" to "subject: AbC". o Unfold all header field continuation lines as described in [RFC2822]; in particular, lines with terminators embedded in continued header field values (that is, CRLF sequences followed by WSP) MUST be interpreted without the CRLF. Implementations MUST NOT remove the CRLF at the end of the header field value. o Convert all sequences of one or more WSP characters to a single SP character. WSP characters here include those before and after a line folding boundary. o Delete all WSP characters at the end of each unfolded header field value. o Delete any WSP characters remaining before and after the colon separating the header field name from the header field value. The colon separator MUST be retained. 3.4.3 The "simple" Body Canonicalization Algorithm The "simple" body canonicalization algorithm ignores all empty lines at the end of the message body. An empty line is a line of zero length after removal of the line terminator. If there is no body or no trailing CRLF on themessage,message body, a CRLF is added. It makes no other changes to the message body. In more formal terms, the "simple" body canonicalization algorithm converts "0*CRLF" at the end of the body to a single "CRLF". Note that a completely empty or missing body is canonicalized as a single "CRLF"; that is, the canonicalized length will be 2 octets. 3.4.4 The "relaxed" Body Canonicalization Algorithm The "relaxed" body canonicalization algorithm: o Ignores all white space at the end of lines. Implementations MUST NOT remove the CRLF at the end of the line. o Reduces all sequences of WSP within a line to a single SP character. o Ignores all empty lines at the end of the message body. "Empty line" is defined in Section 3.4.3. 3.4.5 Body Length Limits A body length count MAY be specified to limit the signature calculation to an initial prefix of the body text, measured in octets. If the body length count is not specified then the entire message body is signed. INFORMATIVE RATIONALE: This capability is provided because it is very common for mailing lists to add trailers to messages (e.g., instructions how to get off the list). Until those messages are also signed, the body length count is a useful tool for the verifier since it may as a matter of policy accept messages having valid signatures with extraneous data. INFORMATIVE IMPLEMENTATION NOTE: Using body length limits enables an attack in which an attacker modifies a message to include content that solely benefits the attacker. It is possible for the appended content to completely replace the original content in the end recipient's eyes and to defeat duplicate message detection algorithms. To avoid this attack, signers should be wary of using this tag, and verifiers might wish to ignore the tag or remove text that appears after the specified content length, perhaps based on other criteria. The body length count allows the signer of a message to permit data to be appended to the end of the body of a signed message. The body length count MUST be calculated following the canonicalization algorithm; for example, any white space ignored by a canonicalization algorithm is not included as part of the body length count. Signers of MIME messages that include a body length count SHOULD be sure that the length extends to the closing MIME boundary string. INFORMATIVE IMPLEMENTATION NOTE: A signer wishing to ensure that the only acceptable modifications are to add to the MIME postlude would use a body length count encompassing the entire final MIME boundary string, including the final "--CRLF". A signer wishing to allow additional MIME parts but not modification of existing parts would use a body length count extending through the final MIME boundary string, omitting the final "--CRLF". Note that this only works for some MIME types, e.g., multipart/mixed but not multipart/signed. A body length count of zero means that the body is completely unsigned. Signers wishing to ensure that no modification of any sort can occur should specify the "simple" canonicalization algorithm for both header and body and omit the body length count. 3.4.6 Canonicalization Examples (INFORMATIVE) In the following examples, actual white space is used only for clarity. The actual input and output text is designated using bracketed descriptors: "<SP>" for a space character, "<HTAB>" for a tab character, and "<CRLF>" for a carriage-return/line-feed sequence. For example, "X <SP> Y" and "X<SP>Y" represent the same three characters. Example 1: A message reading: A: <SP> X <CRLF> B <SP> : <SP> Y <HTAB><CRLF> <HTAB> Z <SP><SP><CRLF> <CRLF> <SP> C <SP><CRLF> D <SP><HTAB><SP> E <CRLF> <CRLF> <CRLF> when canonicalized using relaxed canonicalization for both header and body results in a header reading: a:X <CRLF> b:Y <SP> Z <CRLF> and a body reading: <SP> C <CRLF> D <SP> E <CRLF> Example 2: The same message canonicalized using simple canonicalization for both header and body results in a header reading: A: <SP> X <CRLF> B <SP> : <SP> Y <HTAB><CRLF> <HTAB> Z <SP><SP><CRLF> and a body reading: <SP> C <SP><CRLF> D <SP><HTAB><SP> E <CRLF> Example 3: When processed using relaxed header canonicalization and simple body canonicalization, the canonicalized version has a header of: a:X <CRLF> b:Y <SP> Z <CRLF> and a body reading: <SP> C <SP><CRLF> D <SP><HTAB><SP> E <CRLF> 3.5 The DKIM-Signature header field The signature of the email is stored in the "DKIM-Signature:" header field. This header field contains all of the signature and key- fetching data. The DKIM-Signature value is a tag-list as described in Section 3.2. The "DKIM-Signature:" header field SHOULD be treated as though it were a trace header field as defined in section 3.6 of [RFC2822], and hence SHOULD NOT be reordered and SHOULD be prepended to the message. The "DKIM-Signature:" header field being created or verified is always included in the signature calculation, after the rest of the header fields being signed; however, when calculating or verifying the signature, the value of the b= tag (signature value) of that DKIM-Signature header field MUST be treated as though it were an empty string. Unknown tags in the "DKIM-Signature:" header field MUST be included in the signature calculation but MUST be otherwise ignored by verifiers. Other "DKIM-Signature:" header fields that are included in the signature should be treated as normal header fields; in particular, the b= tag is not treated specially. The encodings for each field type are listed below. Tags described as qp-section are encoded as described in section 6.7 of MIME Part One [RFC2045], with the additional conversion of semicolon characters to "=3B"; intuitively, this is one line of quoted-printable encoded text. The dkim-quoted-printable syntax is defined in Section 2.6. Tags on the DKIM-Signature header field along with their type and requirement status are shown below. Unrecognized tags MUST be ignored. v= Version (MUST be included). This tag defines the version of this specification that applies to the signature record. It MUST have the value 0.5. Note that verifiers must do a string comparison on this value; for example, "1" is not the same as "1.0". ABNF: sig-v-tag = %x76 [FWS] "=" [FWS] "0.5" INFORMATIVE NOTE: DKIM-Signature version numbers are expected to increase arithmetically as new versions of this specification are released. [[INFORMATIVE NOTE: Upon publication, this version number should be changed to"1","1" (two places), and this note should be deleted.]] a= The algorithm used to generate the signature (plain-text; REQUIRED). Verifiers MUST support "rsa-sha1" and "rsa-sha256"; signers SHOULD sign using "rsa-sha256". See Section 3.3 for a description of algorithms. ABNF: sig-a-tag = %x61 [FWS] "=" [FWS] sig-a-tag-alg sig-a-tag-alg = sig-a-tag-k "-" sig-a-tag-h sig-a-tag-k = "rsa" / x-sig-a-tag-k sig-a-tag-h = "sha1" / "sha256" / x-sig-a-tag-h x-sig-a-tag-k = ALPHA *(ALPHA / DIGIT) ; for later extension x-sig-a-tag-h = ALPHA *(ALPHA / DIGIT) ; for later extension b= The signature data (base64; REQUIRED). Whitespace is ignored in this value and MUST be ignored when re-assembling the original signature. In particular, the signing process can safely insert FWS in this value in arbitrary places to conform to line-length limits. See Signer Actions (Section 5) for how the signature is computed. ABNF: sig-b-tag = %x62 [FWS] "=" [FWS] sig-b-tag-data sig-b-tag-data = base64string bh= The hash of the canonicalized body part of the message as limited by the "l=" tag (base64; REQUIRED). Whitespace is ignored in this value and MUST be ignored when re-assembling the original signature. In particular, the signing process can safely insert FWS in this value in arbitrary places to conform to line-length limits. See Section 3.7 for how the body hash is computed. ABNF: sig-bh-tag = %x62 %x68 [FWS] "=" [FWS] sig-bh-tag-data sig-bh-tag-data = base64string c= Message canonicalization (plain-text; OPTIONAL, default is "simple/simple"). This tag informs the verifier of the type of canonicalization used to prepare the message for signing. It consists of two names separated by a "slash" (%d47) character, corresponding to the header and body canonicalization algorithms respectively. These algorithms are described in Section 3.4. If only one algorithm is named, that algorithm is used for the header and "simple" is used for the body. For example, "c=relaxed" is treated the same as "c=relaxed/simple". ABNF: sig-c-tag = %x63 [FWS] "=" [FWS] sig-c-tag-alg ["/" sig-c-tag-alg] sig-c-tag-alg = "simple" / "relaxed" / x-sig-c-tag-alg x-sig-c-tag-alg = hyphenated-word ; for later extension d= The domain of the signing entity (plain-text; REQUIRED). This is the domain that will be queried for the public key. This domain MUST be the same as or a parent domain of the "i=" tag (the signing identity, as described below), or it MUST meet the requirements for parent domain signing described in Section 3.8. When presented with a signature that does not meet these requirement, verifiers MUST consider the signature invalid. Internationalized domain names MUST be encoded as described in [RFC3490]. ABNF: sig-d-tag = %x64 [FWS] "=" [FWS] domain-name domain-name = sub-domain 1*("." sub-domain) ; from RFC 2821 Domain, but excluding address-literal h= Signed header fields (plain-text, but see description; REQUIRED). A colon-separated list of header field names that identify the header fields presented to the signing algorithm. The field MUST contain the complete list of header fields in the order presented to the signing algorithm. The field MAY contain names of header fields that do not exist when signed; nonexistent header fields do not contribute to the signature computation (that is, they are treated as the null input, including the header field name, the separating colon, the header field value, and any CRLF terminator). The field MUST NOT include the DKIM-Signature header field that is being created or verified, but may include others. Folding white space (FWS) MAY be included on either side of the colon separator. Header field names MUST be compared against actual header field names in a case insensitive manner. This list MUST NOT be empty. See Section 5.4 for a discussion of choosing header fields to sign. ABNF: sig-h-tag = %x68 [FWS] "=" [FWS] hdr-name 0*( *FWS ":" *FWS hdr-name ) hdr-name = field-name INFORMATIVE EXPLANATION: By "signing" header fields that do not actually exist, a signer can prevent insertion of those header fields before verification. However, since a signer cannot possibly know what header fields might be created in the future, and that some MUAs might present header fields that are embedded inside a message (e.g., as a message/rfc822 content type), the security of this solution is not total. INFORMATIVE EXPLANATION: The exclusion of the header field name and colon as well as the header field value for non- existent header fields prevents an attacker from inserting an actual header field with a null value. i= Identity of the user or agent (e.g., a mailing list manager) on behalf of which this message is signed (dkim-quoted-printable; OPTIONAL, default is an empty local-part followed by an "@" followed by the domain from the "d=" tag). The syntax is a standard email address where the local-part MAY be omitted. The domain part of the address MUST be the same as or a subdomain of the value of the "d=" tag. Internationalized domain names MUST be converted using the steps listed in section 4 of [RFC3490] using the "ToASCII" function. ABNF: sig-i-tag = %x69 [FWS] "=" [FWS] [ Local-part ] "@" domain-name INFORMATIVE NOTE: The local-part of the "i=" tag is optional because in some cases a signer may not be able to establish a verified individual identity. In such cases, the signer may wish to assert that although it is willing to go as far as signing for the domain, it is unable or unwilling to commit to an individual user name within their domain. It can do so by including the domain part but not the local-part of the identity. INFORMATIVE DISCUSSION: This document does not require the value of the "i=" tag to match the identity in any message header field fields. This is considered to be a verifier policy issue. Constraints between the value of the "i=" tag and other identities in other header fields seek to apply basic authentication into the semantics of trust associated with a role such as content author. Trust is a broad and complex topic and trust mechanisms are subject to highly creative attacks. The real-world efficacy of any but the most basic bindings between the "i=" value and other identities is not well established, nor is its vulnerability to subversion by an attacker. Hence reliance on the use of these options should be strictly limited. In particular it is not at all clear to what extent a typical end-user recipient can rely on any assurances that might be made by successful use of the "i=" options. l= Body length count (plain-text unsigned decimal integer; OPTIONAL, default is entire body). This tag informs the verifier of the number of octets in the body of the email after canonicalization included in the cryptographic hash, starting from 0 immediately following the CRLF preceding the body. This value MUST NOT be larger than the actual number of octets in the canonicalized message body. INFORMATIVE IMPLEMENTATION WARNING: Use of the l= tag might allow display of fraudulent content without appropriate warning to end users. The l= tag is intended for increasing signature robustness when sending to mailing lists that both modify their content and do not sign their messages. However, using the l= tag enables attacks in which an intermediary with malicious intent modifies a message to include content that solely benefits the attacker. It is possible for the appended content to completely replace the original content in the end recipient's eyes and to defeat duplicate message detection algorithms. Examples are described in Security Considerations (Section 8). To avoid this attack, signers should be extremely wary of using this tag, and verifiers might wish to ignore the tag or remove text that appears after the specified content length. INFORMATIVE NOTE: The value of the l= tag is constrained to 76 decimaldigits, which will fit in a 256-bit binary integer field.digits. This constraint is not intended to predict the size of futuremessages,messages or to require implementations to use an integer representation large enough to represent the maximum possible value, but is intended to remind the implementer to check the length of this and all other tags duringverification.verification and to test for integer overflow when decoding the value. Implementers may need to limit the actual value expressed to a value smaller than 10^76, e.g., to allow a message to fit within the available storage space. ABNF: sig-l-tag = %x6c [FWS] "=" [FWS] 1*76DIGIT q= A colon-separated list of query methods used to retrieve the public key (plain-text; OPTIONAL, default is "dns/txt"). Each query method is of the form "type[/options]", where the syntax and semantics of the options depends on the type and specified options. If there are multiple query mechanisms listed, the choice of query mechanism MUST NOT change the interpretation of the signature. Implementations MUST use the recognized query mechanisms in the order presented. Currently the only valid value is "dns/txt" which defines the DNS TXT record lookup algorithm described elsewhere in this document. The only option defined for the "dns" query type is "txt", which MUST be included. Verifiers and signers MUST support "dns/txt". ABNF: sig-q-tag = %x71 [FWS] "=" [FWS] sig-q-tag-method *([FWS] ":" [FWS] sig-q-tag-method) sig-q-tag-method = "dns/txt" / x-sig-q-tag-type ["/" x-sig-q-tag-args] x-sig-q-tag-type = hyphenated-word ; for future extension x-sig-q-tag-args = qp-hdr-value s= The Selector subdividing the namespace for the "d=" (domain) tag (plain-text; REQUIRED). ABNF: sig-s-tag = %x73 [FWS] "=" [FWS] selector t= Signature Timestamp (plain-text unsigned decimal integer; RECOMMENDED, default is an unknown creation time). The time that this signature was created. The format is the number of seconds since 00:00:00 on January 1, 1970 in the UTC time zone. The value is expressed as an unsigned integer in decimal ASCII. This value is not constrained to fit into a 31- or 32-bit integer. Implementations SHOULD be prepared to handle values up to at least 10^12 (until approximately AD 200,000; this fits into 40 bits). To avoid denial of service attacks, implementations MAY consider any value longer than 12 digits to be infinite. Leap seconds are not counted. Implementations MAY ignore signatures that have a timestamp in the future. ABNF: sig-t-tag = %x74 [FWS] "=" [FWS] 1*12DIGIT x= Signature Expiration (plain-text unsigned decimal integer; RECOMMENDED, default is no expiration). The format is the same as in the "t=" tag, represented as an absolute date, not as a time delta from the signing timestamp. The value is expressed as an unsigned integer in decimal ASCII, with the same constraints on the value in the "t=" tag. Signatures MAY be considered invalid if the verification time at the verifier is past the expiration date. The verification time should be the time that the message was first received at the administrative domain of the verifier if that time is reliably available; otherwise the current time should be used. The value of the "x=" tag MUST be greater than the value of the "t=" tag if both are present. INFORMATIVE NOTE: The x= tag is not intended as an anti- replay defense. ABNF: sig-x-tag = %x78 [FWS] "=" [FWS] 1*12DIGIT z= Copied header fields (dkim-quoted-printable, but see description; OPTIONAL, default is null). A vertical-bar-separated list of selected header fields present when the message was signed, including both the field name and value. It is not required to include all header fields present at the time of signing. This field need not contain the same header fields listed in the "h=" tag. The header field text itself must encode the vertical bar ("|", %x7C) character (i.e., vertical bars in the z= text are metacharacters, and any actual vertical bar characters in a copied header field must be encoded). Note that all white space must be encoded, including white space between the colon and the header field value. After encoding, LWSP MAY be added at arbitrary locations in order to avoid excessively long lines; such white space is NOT part of the value of the header field, and MUST be removed before decoding.Verifiers MUST NOT use theThe headerfield names or copied values for checkingfields referenced by thesignatureh= tag refer to the fields in the 2822 header of the message, not to anyway.copied fields in the z= tag. Copied header field values are for diagnosticuse only.use. Header fields with characters requiring conversion (perhaps from legacy MTAs which are not [RFC2822] compliant) SHOULD be converted as described in MIME Part Three [RFC2047]. ABNF: sig-z-tag = %x7A [FWS] "=" [FWS] sig-z-tag-copy *( [FWS] "|" sig-z-tag-copy ) sig-z-tag-copy = hdr-name ":" qp-hdr-value qp-hdr-value = dkim-quoted-printable ; with "|" encoded INFORMATIVE EXAMPLE of a signature header field spread across multiple continuation lines: DKIM-Signature: a=rsa-sha256; d=example.net; s=brisbane; c=simple; q=dns/txt; i=@eng.example.net; t=1117574938; x=1118006938; h=from:to:subject:date; z=From:foo@eng.example.net|To:joe@example.com| Subject:demo=20run|Date:July=205,=202005=203:44:08=20PM=20-0700; bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=; b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ VoG4ZHRNiYzR 3.6 Key Management and Representation Signature applications require some level of assurance that the verification public key is associated with the claimed signer. Many applications achieve this by using public key certificates issued by a trusted third party. However, DKIM can achieve a sufficient level of security, with significantly enhanced scalability, by simply having the verifier query the purported signer's DNS entry (or some security-equivalent) in order to retrieve the public key. DKIM keys can potentially be stored in multiple types of key servers and in multiple formats. The storage and format of keys are irrelevant to the remainder of the DKIM algorithm. Parameters to the key lookup algorithm are the type of the lookup (the "q=" tag), the domain of theresponsiblesigner (the "d=" tag of theDKIM-SignatureDKIM- Signature header field), and the Selector (the "s=" tag). public_key = dkim_find_key(q_val, d_val, s_val) This document defines a single binding, using DNS TXT records to distribute the keys. Other bindings may be defined in the future. 3.6.1 Textual Representation It is expected that many key servers will choose to present the keys in an otherwise unstructured text format (for example, an XML form would not be considered to be unstructured text for this purpose). The following definition MUST be used for any DKIM key represented in an otherwise unstructured textual form. The overall syntax is a tag-list as described in Section 3.2. The current valid tags are described below. Other tags MAY be present and MUST be ignored by any implementation that does not understand them. v= Version of the DKIM key record (plain-text; RECOMMENDED, default is "DKIM1"). If specified, this tag MUST be set to "DKIM1" (without the quotes). This tag MUST be the first tag in the record. Records beginning with a "v=" tag with any other value MUST be discarded. Note that verifiers must do a string comparison on this value; for example, "DKIM1" is not the same as "DKIM1.0". ABNF: key-v-tag = %x76 [FWS] "=" [FWS] "DKIM1" g= granularity of the key (plain-text; OPTIONAL, default is "*"). This value MUST match the Local-part of the "i=" tag of the DKIM- Signature header field (or its default value of the empty string if "i=" is not specified), with a single, optional "*" character matching a sequence of zero or more arbitrary characters ("wildcarding").The intent of this tag is to constrain which signing address can legitimately use this Selector.An email with a signing address that does not match the value of this tag constitutes a failed verification.Wildcarding allows matchingThe intent of this tag is to constrain which signing address can legitimately use this Selector, foraddresses such as "user+*". An empty "g=" value neverexample, when delegating a key to a third party that should only be used for special purposes. Wildcarding allows matching for addresses such as "user+*" or "*-offer". An empty "g=" value never matches any addresses. ABNF: key-g-tag = %x67 [FWS] "=" [FWS] key-g-tag-lpart key-g-tag-lpart = [dot-atom-text]["*"]["*" [dot-atom-text] ] [[NON-NORMATIVE DISCUSSION POINT: "*" is legal in a "dot- atom-text". This should probably use a different character for wildcarding. Unfortunately, the options are non-mnemonic (e.g., "@", "(", ":"). Alternatively we could insist on escaping a "*" intended as a literal "*" in the address.]] h= Acceptable hash algorithms (plain-text; OPTIONAL, defaults to allowing all algorithms). A colon-separated list of hash algorithms that might be used. Signers and Verifiers MUST support the "sha256" hash algorithm. Verifiers MUST also support the "sha1" hash algorithm. ABNF: key-h-tag = %x68 [FWS] "=" [FWS] key-h-tag-alg 0*( [FWS] ":" [FWS] key-h-tag-alg ) key-h-tag-alg = "sha1" / "sha256" / x-key-h-tag-alg x-key-h-tag-alg = hyphenated-word ; for future extension k= Key type (plain-text; OPTIONAL, default is "rsa"). Signers and verifiers MUST support the "rsa" key type. The "rsa" key type indicates that an ASN.1 DER-encoded [X.660] RSAPublicKey [RFC3447] (see sections 3.1 and A.1.1) is being used in the p= tag. (Note: the p= tag further encodes the value using the base64 algorithm.) ABNF: key-k-tag = %x76 [FWS] "=" [FWS] key-k-tag-type key-k-tag-type = "rsa" / x-key-k-tag-type x-key-k-tag-type = hyphenated-word ; for future extension n= Notes that might be of interest to a human (qp-section; OPTIONAL, default is empty). No interpretation is made by any program. This tag should be used sparingly in any key server mechanism that has space limitations (notably DNS). This is intended for use by administrators, not end users. ABNF: key-n-tag = %x6e [FWS] "=" [FWS] qp-section p= Public-key data (base64; REQUIRED). An empty value means that this public key has been revoked. The syntax and semantics of this tag value before being encoded in base64 is defined by the k= tag. INFORMATIVE RATIONALE: If a private key has been compromised or otherwise disabled (e.g., an outsourcing contract has been terminated), a signer might want to explicitly state that it knows about the selector, but all messages using that selector should fail verification. Verifiers should ignore any DKIM-Signature header fields with a selector referencing a revoked key. ABNF: key-p-tag = %x70 [FWS] "=" [ [FWS] base64string ] s= Service Type (plain-text; OPTIONAL; default is "*"). A colon- separated list of service types to which this record applies. Verifiers for a given service type MUST ignore this record if the appropriate type is not listed. Currently defined service types are: * matches all service types email electronic mail (not necessarily limited to SMTP) This tag is intended topermit signers toconstrain the use ofdelegated keys, e.g., where a company is willing to delegate the right to send mail in their name to an outsourcer, but not to send IM or make VoIP calls. (This of course presumes that thesekeysare used infor other purposes, should use of DKIM be defined by other services in thefuture.)future. ABNF: key-s-tag = %x73 [FWS] "=" [FWS] key-s-tag-type 0*( [FWS] ":" [FWS] key-s-tag-type ) key-s-tag-type = "email" / "*" / x-key-s-tag-type x-key-s-tag-type = hyphenated-word ; for future extension t= Flags, represented as a colon-separated list of names (plain- text; OPTIONAL, default is no flags set). The defined flags are: y This domain is testing DKIM. Verifiers MUST NOT treat messages from signers in testing mode differently from unsigned email, even should the signature fail to verify. Verifiers MAY wish to track testing mode results to assist the signer. s Any DKIM-Signature header fields using the "i=" tag MUST have the same domain value on the right hand side of the "@" in the "i=" tag and the value of the "d=" tag. That is, the "i=" domain MUST NOT be a subdomain of "d=". Use of this flag is RECOMMENDED unless subdomaining is required. ABNF: key-t-tag = %x74 [FWS] "=" [FWS] key-t-tag-flag 0*( [FWS] ":" [FWS] key-t-tag-flag ) key-t-tag-flag = "y" / "s" / x-key-t-tag-flag x-key-t-tag-flag = hyphenated-word ; for future extension Unrecognized flags MUST be ignored. 3.6.2 DNS binding A binding using DNS TXT records as a key service is hereby defined. All implementations MUST support this binding. 3.6.2.1 Name Space All DKIM keys are stored in a subdomain named "_domainkey". Given a DKIM-Signature field with a "d=" tag of "example.com" and an "s=" tag of "foo.bar", the DNS query will be for "foo.bar._domainkey.example.com". INFORMATIVE OPERATIONAL NOTE: Wildcard DNS records (e.g., *.bar._domainkey.example.com) do not make sense in this context and should not be used. Note also that wildcards within domains (e.g., s._domainkey.*.example.com) are not supported by the DNS. 3.6.2.2 Resource Record Types for Key Storage The DNS Resource Record type used is specified by an option to the query-type ("q=") tag. The only option defined in this base specification is "txt", indicating the use of a TXT Resource Record (RR). A later extension of this standard may define another RR type. Strings in a TXT RR MUST be concatenated together before use with no intervening white space. TXT RRs MUST be unique for a particular selector name; that is, if there are multiple records in an RRset, the results are undefined. TXT RRs are encoded as described in Section 3.6.1. 3.7 Computing the Message Hashes Both signing and verifying message signatures starts with a step of computing two cryptographic hashes over the message. Signers will choose the parameters of the signature as described in Signer Actions (Section 5); verifiers will use the parameters specified in the "DKIM-Signature" header field being verified. In the following discussion, the names of the tags in the "DKIM-Signature" header field which either exists (when verifying) or will be created (when signing) are used. Note that canonicalization (Section 3.4) is only used to prepare the email for signing or verifying; it does not affect the transmitted email in any way. Thesigner or verifiersigner/verifier MUST compute two hashes, one over the body of the message and one over the selected header fields of the message. Signers MUST compute them in the order shown. Verifiers MAY compute them in any order convenient to the verifier, provided that the result is semantically identical to the semantics that would be the case had they been computed in this order. In hash step 1, thesigner or verifiersigner/verifier MUST hash the message body, canonicalized using the body canonicalization algorithm specified in the "c=" tag and then truncated to the length specified in the "l=" tag. That hash value is then converted to base64 form and inserted into (signers) or compared to (verifiers) the "bh=" tag of theDKIM-Signature:DKIM- Signature: header field. In hash step 2, thesigner or verifiersigner/verifier MUST pass the following to the hash algorithm in the indicated order. 1. The header fields specified by the "h=" tag, in the order specified in that tag, and canonicalized using the header canonicalization algorithm specified in the "c=" tag. Each header field MUST be terminated with a single CRLF. 2. The "DKIM-Signature" header field that exists (verifying) or will be inserted (signing) in the message, with the value of the "b=" tag deleted (i.e., treated as the empty string), canonicalized using the header canonicalization algorithm specified in the "c=" tag, and without a trailing CRLF. All tags and their values in the DKIM-Signature header field are included in the cryptographic hash with the sole exception of the value portion of the "b=" (signature) tag, which MUST be treated as the null string. All tags MUST be included even if they might not be understood by the verifier. The header field MUST be presented to the hash algorithm after the body of the message rather than with the rest of the header fields and MUST be canonicalized as specified in the "c=" (canonicalization) tag. The DKIM-Signature header field MUST NOT be included in its own h= tag, although other DKIM-Signature header fields MAY be signed (see Section 4). When calculating the hash on messages that will be transmitted using base64 or quoted-printable encoding, signers MUST compute the hash after the encoding. Likewise, the verifier MUST incorporate the values into the hash before decoding the base64 or quoted-printable text. However, the hash MUST be computed before transport level encodings such as SMTP"dot-stuffing.""dot-stuffing" (the modification of lines beginning with a "." to avoid confusion with the SMTP end-of-message marker, as specified in [RFC2821]). With the exception of the canonicalization procedure described in Section 3.4, the DKIM signing process treats the body of messages as simply a string of octets. DKIM messages MAY be either in plain-text or in MIME format; no special treatment is afforded to MIME content. Message attachments in MIME format MUST be included in the content which is signed. More formally, the algorithm for the signature is: body-hash = hash-alg(canon_body) header-hash = hash-alg(canon_header || DKIM-SIG) signature = sig-alg(header-hash, key) where "sig-alg" is the signature algorithm specified by the "a=" tag, "hash-alg" is the hash algorithm specified by the "a=" tag, "canon_header" and "canon_body" are the canonicalized message header and body (respectively) as defined in Section 3.4 (excluding the DKIM-Signature header field), and "DKIM-SIG" is the canonicalized DKIM-Signature header field sans the signature value itself, but with "body-hash" included as the "bh=" tag. INFORMATIVE IMPLEMENTERS' NOTE: Many digital signature APIs provide both hashing and application of the RSA private key using a single "sign()" primitive. When using such an API the last two steps in the algorithm would probably be combined into a single call that would perform both the "hash-alg" and the "sig-alg". 3.8 Signing by Parent Domains In some circumstances, it is desirable for a domain to apply a signature on behalf of any of its subdomains without the need to maintain separate selectors (key records) in each subdomain. By default, private keys corresponding to key records can be used to sign messages for any subdomain of the domain in which they reside, e.g., a key record for the domain example.com can be used to verify messages where the signing identity (i= tag of the signature) is sub.example.com, or even sub1.sub2.example.com. In order to limit the capability of such keys when this is not intended, the "s" flag may be set in the t= tag of the key record to constrain the validity of the record to exactly the domain of the signing identity. If the referenced key record contains the "s" flag as part of the t= tag, the domain of the signing identity (i= flag) MUST be the same as that of the d= domain. If this flag is absent, the domain of the signing identity MUST be the same as, or a subdomain of, the d= domain. Key records which are not intended for use with subdomains SHOULD specify the "s" flag in the t= tag. 4. Semantics of Multiple SignaturesA signer4.1 Example Scenarios There are many reasons thatis adding a signature toa messagemerely createsmight have multiple signatures. For example, anew DKIM-Signature header, using the usual semantics ofgiven signer might sign multiple times, perhaps with different hashing or signing algorithms during a transition phase. INFORMATIVE EXAMPLE: Suppose SHA-256 is in theh= option.future found to be insufficiently strong, and DKIM usage transitions to SHA-1024. A signerMAYmight immediately signpreviously existing DKIM-Signature header fieldsusing themethod described in section Section 5.4newer algorithm, but continue to signtrace header fields. INFORMATIVE NOTE: Signers should be cognizant that signing DKIM- Signature header fields may result in signature failuresusing the older algorithm for interoperability withintermediariesverifiers that had not yet upgraded. The signer would do this by adding two DKIM-Signature header fields, one using each algorithm. Older verifiers that did not recognize SHA-1024 as an acceptable algorithm would skip thatDKIM-Signature header fields are trace header fieldssignature andunwittingly reorder them, thus breaking such signatures. INFORMATIVE NOTE: If a header field with multiple instances is signed, those header fields are always signed fromuse thebottom up. Thus, it isolder algorithm; newer verifiers could use either signature at their option, and all other things being equal might notpossibleeven attempt tosign only specific DKIM-Signature header fields. For example, ifverify themessage being signed already contains three DKIM-Signature header fields A, B, and C, it is possible toother signature. Similarly, a signer might sign a message including allof them, B and C only, or C only, but not A only, B only, Aheaders andB only, or Ano "l=" tag (to satisfy strict verifiers) andC only. When evaluatingamessagesecond time withmultiple signatures,averifier should evaluate signatures independentlylimited set of headers andon their own merits. For example, a verifier that by policy chooses notan "l=" tag (in anticipation of possible message modifications in route toaccept signatures with deprecated cryptographic algorithms should consider such signatures invalid. As with messages withother verifiers). Verifiers could then choose which signature they preferred. INFORMATIVE EXAMPLE: A verifier might receive asingle signature, verifiers are at liberty to usemessage with two signatures, one covering more of thepresencemessage than the other. If the signature covering more ofvalid signatures as an input to local policy; likewise,theinterpretationmessage verified, then the verifier could make one set ofmultiple valid signatures in combination is a localpolicydecision of the verifier. Signers SHOULD NOT remove any DKIM-Signature header fields from messages they are signing, evendecisions; ifthey knowthat signature failed but thesignatures cannot be verified. 5. Signer Actions The following steps are performed in order by signers. 5.1 Determine if the Email Should be Signed and by Whom A signer can obviously only sign email for domains for which it has a private-key and the necessary knowledgesignature covering less of thecorresponding public key and Selector information. However there are a number of other reasons beyondmessage verified, thelack ofverifier might make aprivate key whydifferent set of policy decisions. Of course, asigner could choose notmessage might also have multiple signatures because it passed through multiple signers. A common case is expected tosign an email. INFORMATIVE NOTE: Signing modules maybeincorporated into any portionthat ofthe mail system as deemed appropriate, including an MUA,aSUBMISSION server, or an MTA. Wherever implemented, signers should beware of signing (and thereby asserting responsibility for) messagessigned message thatmay be problematic. In particular, withinpasses through atrusted enclave the signing addressmailing list that also signs all messages. Assuming both of those signatures verify, a recipient mightbe derived fromchoose to accept theheader accordingmessage if either of those signatures were known tolocal policy; SUBMISSION servers might only sign messagescome fromusers that are properly authenticated and authorized.trusted sources. INFORMATIVEIMPLEMENTER ADVICE: SUBMISSION servers should not sign Received header fields if the outgoing gateway MTA obfuscates Received header fields, for exampleEXAMPLE: Recipients might choose tohide the details of internal topology. If an email cannot be signed for some reason, it is a local policy decisionwhitelist mailing lists to which they have subscribed and which have acceptable anti-abuse policies so as towhataccept messages sent todo withthatemail. 5.2 Select a private-key and corresponding selector information This specification does not define the basis by which a signer should choose which private-keylist even from unknown authors. They might also subscribe to less trusted mailing lists (e.g., those without anti-abuse protection) andSelector informationbe willing touse. Currently,accept allSelectors are equal as far as this specification is concerned, so the decision should largely be a matter of administrative convenience. Distribution and management of private-keys is also outside the scopemessages from specific authors, but insist on doing additional abuse scanning for other messages. Another related example ofthis document.multiple signers might be forwarding services, such as those commonly associated with academic alumni sites. INFORMATIVEOPERATIONS ADVICE:EXAMPLE: Asigner should not sign withrecipient might have an address at alumni.example.edu, aprivate key when the Selector containing the corresponding public keysite that has anti-abuse protection that isexpected to be revoked or removed beforesomewhat less effective than theverifier has an opportunity to validaterecipient would prefer. Such a recipient might have specific authors whose messages would be trusted absolutely, but messages from unknown authors which had passed thesignature. Theforwarder's scrutiny would have only medium trust. 4.2 Interpretation A signershould anticipatethatverifiers may choose to defer validation, perhaps until the messageisactually read by the final recipient. In particular, when rotatingadding a signature to a message merely creates a newkey pair, signing should immediately commence with the new private key andDKIM-Signature header, using theold public key should be retained for a reasonable validation interval before being removed fromusual semantics of thekey server. 5.3 Normalizeh= option. A signer MAY sign previously existing DKIM-Signature header fields using theMessagemethod described in section Section 5.4 toPrevent Transport Conversions Some messages, particularly those using 8-bit characters, are subject to modification during transit, notably conversion to 7-bit form. Such conversions will break DKIM signatures. In order to minimize the chances of such breakage, signers SHOULD convert the message to a suitable MIME content transfer encoding such as quoted-printable or base64 as described in MIME Part One [RFC2045] before signing. Such conversion is outside the scope of DKIM; the actual message SHOULDsign trace header fields. INFORMATIVE NOTE: Signers should beconverted to 7-bit MIME by an MUA or MSA prior to presentation to the DKIM algorithm. If the message is submitted to the signercognizant that signing DKIM- Signature header fields may result in signature failures withany local encodingintermediaries thatwill be modified before transmission,do not recognize thatmodification to canonical [RFC2822] form MUST be done before signing. In particular, bare CR or LF characters (used by some systems asDKIM-Signature header fields are trace header fields and unwittingly reorder them, thus breaking such signatures. For this reason, signing existing DKIM- Signature header fields is unadvised, albeit legal. INFORMATIVE NOTE: If alocal line separator convention) MUST be converted to the SMTP-standard CRLF sequence before the messageheader field with multiple instances issigned. Any conversion of this sort SHOULD be applied to the message actually sent tosigned, those header fields are always signed from therecipient(s),bottom up. Thus, it is notjust to the version presentedpossible tothe signing algorithm. More generally, the signer MUSTsign only specific DKIM-Signature header fields. For example, if the messageas it is expected to be received by the verifier rather than in some local or internal form. 5.4 Determine thebeing signed already contains three DKIM-Signature header fields A, B, and C, it is possible toSign The From header field MUST be signed (that is, included in the h= tagsign all ofthe resultingthem, B and C only, or C only, but not A only, B only, A and B only, or A and C only. A signer MAY add more than one DKIM-Signature headerfield).field using different parameters. For example, during a transition period a signer might want to produce signatures using two different hash algorithms. Signers SHOULD NOTsign an existingremove any DKIM-Signature headerfield likely tofields from messages they are signing, even if they know that the signatures cannot belegitimately modified or removedverified. When evaluating a message with multiple signatures, a verifier SHOULD evaluate signatures independently and on their own merits. For example, a verifier that by policy chooses not to accept signatures with deprecated cryptographic algorithms would consider such signatures invalid. Verifiers MAY process signatures intransit. In particular, [RFC2821] explicitly permits modification or removalany order of their choice; for example, some verifiers might choose to process signatures corresponding to the"Return-Path" headerFrom field intransit. Signers MAY include any otherthe message headerfieldsbefore other signatures. See Section 6.1 for more information about signature choices. Verifiers SHOULD ignore failed signatures as though they were not presentatin thetime of signing atmessage. Verifiers SHOULD continue to check signatures until a signature successfully verifies to thediscretionsatisfaction of thesigner. INFORMATIVE OPERATIONS NOTE: The choice of which header fields to sign is non-obvious. One strategy is to sign all existing, non- repeatable header fields. An alternative strategy isverifier. To limit potential denial-of-service attacks, verifiers MAY limit the total number of signatures they will attempt tosign only header fields thatverify. 5. Signer Actions The following steps arelikely to be displayed to or otherwiseperformed in order by signers. 5.1 Determine if the Email Should belikely to affectSigned and by Whom A signer can obviously only sign email for domains for which it has a private key and theprocessingnecessary knowledge of themessage atcorresponding public key and Selector information. However there are a number of other reasons beyond thereceiver. A third strategy islack of a private key why a signer could choose not to signonly "well known" headers. Note that verifiersan email. INFORMATIVE NOTE: Signing modules maytreat unsigned header fields with extreme skepticism, including refusing to display them tobe incorporated into any portion of theend usermail system as deemed appropriate, including an MUA, a SUBMISSION server, oreven ignorean MTA. Wherever implemented, signers should beware of signing (and thereby asserting responsibility for) messages that may be problematic. In particular, within a trusted enclave thesignature if it does not cover certain header fields. For this reasonsigningfields present inaddress might be derived from themessage such as Date, Subject, Reply-To, Sender,header according to local policy; SUBMISSION servers might only sign messages from users that are properly authenticated andall MIMEauthorized. INFORMATIVE IMPLEMENTER ADVICE: SUBMISSION servers should not sign Received header fieldsis highly advised. The DKIM-Signatureif the outgoing gateway MTA obfuscates Received headerfield is always implicitly signed and MUST NOT be included infields, for example to hide theh= tag exceptdetails of internal topology. If an email cannot be signed for some reason, it is a local policy decision as toindicate that other preexisting signatures are also signed. Signers MAY claimwhat tohave signed header fields thatdonot exist (that is, signers MAY include the header field name in the h= tag even ifwith thatheader fieldemail. 5.2 Select a Private Key and Corresponding Selector Information This specification does notexist in the message). When computing the signature, the non-existing header field MUST be treated as the null string (includingdefine theheader field name, header field value, all punctuation,basis by which a signer should choose which private key andthe trailing CRLF). INFORMATIVE RATIONALE: This allows signersSelector information toexplicitly assert the absence of a header field; if that header fielduse. Currently, all Selectors are equal as far as this specification isadded laterconcerned, so thesignature will fail. INFORMATIVE NOTE: A header field name need onlydecision should largely belisted once more than the actual number of that header field inamessage at the timematter ofsigning in order to prevent any further additions. For example, if thereadministrative convenience. Distribution and management of private keys isa single "Comments" header field atalso outside thetimescope ofsigning, listing "Comments" twice inthis document. INFORMATIVE OPERATIONS ADVICE: A signer should not sign with a private key when theh= tag is sufficient to prevent any number of Comments header fields from being appended; it is not necessary (butSelector containing the corresponding public key islegal)expected tolist "Comments" threebe revoked ormore times inremoved before theh= tag. Signers choosing to signverifier has anexisting header fieldopportunity to validate the signature. The signer should anticipate thatoccurs more than once inverifiers may choose to defer validation, perhaps until the message(such as Received) MUST sign the physically last instance of that header field inis actually read by theheader block. Signers wishingfinal recipient. In particular, when rotating tosign multiple instances of suchaheader field MUST include the header field name multiple times in the h= tag ofnew key pair, signing should immediately commence with theDKIM-Signature header field,new private key andMUST sign such header fields in orderthe old public key should be retained for a reasonable validation interval before being removed from thebottom ofkey server. 5.3 Normalize theheader field blockMessage tothe top. The signer MAY include more instances of a header field name in h= than therePrevent Transport Conversions Some messages, particularly those using 8-bit characters, areactual corresponding header fieldssubject toindicate that additional header fieldsmodification during transit, notably conversion to 7-bit form. Such conversions will break DKIM signatures. In order to minimize the chances ofthat namesuch breakage, signers SHOULDNOT be added. INFORMATIVE EXAMPLE: Ifconvert thesigner wishesmessage tosign two existing Received header fields, and the existing header contains: Received: <A> Received: <B> Received: <C> then the resulting DKIM-Signature header field should read: DKIM-Signature: ... h=Received : Received : ... and Received header fields <C> and <B> will be signeda suitable MIME content transfer encoding such as quoted-printable or base64 as described inthat order. Signers should be carefulMIME Part One [RFC2045] before signing. Such conversion is outside the scope ofsigning header fields that might have additional instances added later inDKIM; thedelivery process, since such header fields mightactual message SHOULD beinserted after the signed instanceconverted to 7-bit MIME by an MUA orotherwise reordered. Trace header fields (such as Received and DKIM- Signature) and Resent-* blocks areMSA prior to presentation to theonly fields prohibited by [RFC2822] from being reordered. INFORMATIVE ADMONITION: DespiteDKIM algorithm. If thefact that [RFC2822] permits header fieldsmessage is submitted tobe reordered (withtheexception of Received header fields), reordering of signed header fieldssigner withmultiple instances by intermediate MTAsany local encoding that willcause DKIM signatures tobebroken; such anti-social behavior shouldmodified before transmission, that modification to canonical [RFC2822] form MUST beavoided. INFORMATIVE IMPLEMENTER'S NOTE: Although not requireddone before signing. In particular, bare CR or LF characters (used bythis specification, all end-user visible header fields shouldsome systems as a local line separator convention) MUST besignedconverted toavoid possible "indirect spamming." For example, ifthe"Subject" header fieldSMTP-standard CRLF sequence before the message isnot signed, a spammer can resend a previously signed mail, replacingsigned. Any conversion of this sort SHOULD be applied to thelegitimate subject with a one-line spam. 5.5 Computemessage actually sent to the recipient(s), not just to the version presented to the signing algorithm. More generally, theMessage Hash and Signature Thesigner MUSTcomputesign the messagehashasdescribed in Section 3.7 and then signitusingis expected to be received by theselected public-key algorithm. This will resultverifier rather than ina DKIM-Signature header field which will include the body hash and a signature of the header hash, where that header includes the DKIM-Signature header field itself. Entities such as mailing list managers that implement DKIM and which modify the messagesome local orainternal form. 5.4 Determine the Header Fields to Sign The From header field(for example, inserting unsubscribe information) before retransmitting the message SHOULD check any existing signature on input andMUSTmake such modifications before re-signing the message. The signer MAY elect to limit the number of bytes of the body that willbe signed (that is, included in thehash and hence signed. The length actually hashed should be inserted in the "l="h= tag of the"DKIM-Signature" header field. 5.6 Insert theresulting DKIM-Signature headerfield Finally, the signer MUST insert the "DKIM-Signature:" header field created in the previous step prior to transmitting the email. The "DKIM-Signature"field). Signers SHOULD NOT sign an existing header fieldMUST be the same as usedlikely tocompute the hash as described above, except that the value of the "b=" tag MUSTbethe appropriately signed hash computed in the previous step, signed using the algorithm specifiedlegitimately modified or removed inthe "a=" tagtransit. In particular, [RFC2821] explicitly permits modification or removal of the"DKIM- Signature""Return-Path" header fieldand using the private key corresponding to the Selector giveninthe "s=" tag of the "DKIM-Signature" header field, as chosen above in Section 5.2 The "DKIM-Signature" MUST be inserted beforetransit. Signers MAY include any otherDKIM-Signatureheader fieldsinpresent at theheader block.time of signing at the discretion of the signer. INFORMATIVEIMPLEMENTATIONOPERATIONS NOTE: Theeasiest waychoice of which header fields toachieve thissign is non-obvious. One strategy is toinsert the "DKIM-Signature" header field at the beginning of the header block. In particular, it may be placed before any existing Receivedsign all existing, non- repeatable header fields.ThisAn alternative strategy isconsistent with treating "DKIM-Signature" as a traceto sign only headerfield. 6. Verifier Actions Since a signer MAY remove or revoke a public key at any time, it is recommendedfields thatverification occur in a timely manner with the most timely place being during acceptance by the border MTA. A borderare likely to be displayed to orintermediate MTA MAY verifyotherwise be likely to affect the processing of the messagesignature(s). An MTA who has performed verification MAY communicateat theresult ofreceiver. A third strategy is to sign only "well known" headers. Note thatverification by adding a verificationverifiers may treat unsigned headerfieldfields with extreme skepticism, including refusing to display them toincoming messages. This considerably simplifies things fortheuser, who can now use an existing mailend useragent. Most MUAs haveor even ignore theability to filter messages based on messagesignature if it does not cover certain header fields. For this reason signing fieldsor content; these filters would be used to implement whatever policypresent in theuser wishes with respect to unsigned mail. A verifying MTA MAY implement a policy with respect to unverifiable mail, regardless of whether or not it applies the verificationmessage such as Date, Subject, Reply-To, Sender, and all MIME header fields is highly advised. The DKIM-Signature header fieldtois always implicitly signedmessages. Verifiersand MUSTproduce a result that is semantically equivalent to applying the following steps in the order listed. In practice, several of these steps canNOT beperformed in parallelincluded inorder to improve performance. 6.1 Extract Signatures fromtheMessage The order in which verifiers try DKIM-Signatureh= tag except to indicate that other preexisting signatures are also signed. Signers MAY claim to have signed header fieldsisthat do notdefined; verifiersexist (that is, signers MAYtry signatures in any order they would like. For example, one implementation might prefer to tryinclude thesignaturesheader field name intextual order, whereas another might want to prefer signatures by identitiesthe h= tag even if thatmatchheader field does not exist in thecontents ofmessage). When computing the"From"signature, the non-existing header fieldover other identities. VerifiersMUSTNOT attribute ultimate meaningbe treated as the null string (including the header field name, header field value, all punctuation, and the trailing CRLF). INFORMATIVE RATIONALE: This allows signers to explicitly assert theorderabsence ofmultiple DKIM-Signaturea headerfields. In particular, there is reason to believefield; if thatsome relaysheader field is added later the signature willreorderfail. INFORMATIVE NOTE: A header field name need only be listed once more than the actual number of that headerfieldsfield inpotentially arbitrary ways. INFORMATIVE IMPLEMENTATION NOTE: Verifiers might use the order asaclue tomessage at the time of signingorderin order to prevent any further additions. For example, if there is a single "Comments" header field at theabsencetime ofany other information. However, other clues as tosigning, listing "Comments" twice in thesemanticsh= tag is sufficient to prevent any number ofmultiple signatures (such as correlatingComments header fields from being appended; it is not necessary (but is legal) to list "Comments" three or more times in thesigning host with Receivedh= tag. Signers choosing to sign an existing headerfields) may also be considered. A verifier SHOULD NOT treat a messagefield thathas one oroccurs morebad signatures and no good signatures differently from athan once in the messagewith no signature at all; such treatment is a matter(such as Received) MUST sign the physically last instance oflocal policy and is beyondthat header field in thescopeheader block. Signers wishing to sign multiple instances ofthis document. When a signature successfully verifies,such averifier will either stop processing or attempt to verify any other signatures, atheader field MUST include thediscretionheader field name multiple times in the h= tag of theimplementation. A verifier MAY limitDKIM-Signature header field, and MUST sign such header fields in order from thenumberbottom ofsignatures it triesthe header field block toavoid denial-of-service attacks. INFORMATIVE NOTE: An attacker could send messages with large numbers of faulty signatures, eachthe top. The signer MAY include more instances ofwhich would requireaDNS lookup andheader field name in h= than there are actual correspondingCPU timeheader fields toverify the message. This could be an attack on the domainindicate thatreceives the message, by slowing down the verifier by requiring it to do large numberadditional header fields ofDNS lookups and/or signature verifications. It could alsothat name SHOULD NOT bean attack against the domains listed in the signatures, essentially by enlisting innocent verifiers in launching an attack againstadded. INFORMATIVE EXAMPLE: If theDNS servers ofsigner wishes to sign two existing Received header fields, and theactual victim. Inexisting header contains: Received: <A> Received: <B> Received: <C> then thefollowing description, text reading "return status (explanation)" (where "status" is oneresulting DKIM-Signature header field should read: DKIM-Signature: ... h=Received : Received : ... and Received header fields <C> and <B> will be signed in that order. Signers should be careful of"PERMFAIL" or "TEMPFAIL") meanssigning header fields that might have additional instances added later in theverifier MUST immediately cease processing that signature. The verifier SHOULD proceed todelivery process, since such header fields might be inserted after thenext signature, if any is present,signed instance or otherwise reordered. Trace header fields (such as Received) andcompletely ignore the bad signature. IfResent-* blocks are thestatusonly fields prohibited by [RFC2822] from being reordered. In particular, since DKIM-Signature header fields may be reordered by some intermediate MTAs, signing existing DKIM- Signature header fields is"PERMFAIL",error-prone. INFORMATIVE ADMONITION: Despite thesignature failed and should notfact that [RFC2822] permits header fields to bereconsidered. Ifreordered (with thestatus is "TEMPFAIL", the signature could notexception of Received header fields), reordering of signed header fields with multiple instances by intermediate MTAs will cause DKIM signatures to beverified at this time but maybroken; such anti-social behavior should betried again later. A verifier MAY either defer the message for later processing, perhapsavoided. INFORMATIVE IMPLEMENTER'S NOTE: Although not required byqueueing it locally or issuing a 451/4.7.5 SMTP reply, or try another signature;this specification, all end-user visible header fields should be signed to avoid possible "indirect spamming." For example, ifno good signaturethe "Subject" header field isfound and anynot signed, a spammer can resend a previously signed mail, replacing the legitimate subject with a one-line spam. 5.4.1 Recommended Signature Content In order to maximize compatibility with a variety of verifiers, it is recommended that signers follow thesignatures resultedpractices outlined in this section when signing aTEMPFAIL status,message. However, these are generic recommendations applying to theverifier MAY savegeneral case; specific senders may wish to modify these guidelines as required by their unique situations. Verifiers MUST be capable of verifying signatures even if one or more of themessage for later processing. The "(explanation)"recommended header fields is notnormative text; it is provided solely for clarification. Verifiers SHOULD ignore any DKIM-Signaturesigned (with the exception of From, which must always be signed) or if one or more of the disrecommended header fieldswhereis signed. Note that verifiers do have thesignature does not validate. Verifiersoption of ignoring signatures thatare prepared to validate multiple signaturedo not cover a sufficient portion of the header or body, just as they may ignore signatures from an identity they do not trust. The following header fields SHOULDproceed to the next signature header field, should it exist. However, verifiers MAY make note ofbe included in thefact that an invalid signature wassignature, if they are presentfor consideration at a later step. INFORMATIVE NOTE: The rationale of this requirement is to permit messages that have invalid signatures but also a valid signature to work. For example, a mailing list exploder might opt to leave the original submitter signatureinplace even though the exploder knows that it is modifyingthe message being signed: o From (REQUIRED in all signatures) o Sender, Reply-To o Subject o Date, Message-ID o To, Cc o MIME-Version o Content-Type, Content-Transfer-Encoding, Content-ID, Content- Description o Resent-Date, Resent-From, Resent-Sender, Resent-To, Resent-cc, Resent-Message-ID o In-Reply-To, References o List-Id, List-Help, List-Unsubscribe, List-Subscribe, List-Post, List-Owner, List-Archive The following header fields SHOULD NOT be included insome way that will break that signature, and the exploder inserts its own signature. In this casethemessage should succeed evensignature: o Return-Path o Received o Comments, Keywords o Bcc, Resent-Bcc o DKIM-Signature Optional header fields (those not mentioned above) normally SHOULD NOT be included in thepresencesignature, because of theknown-broken signature. For each signaturepotential for additional header fields of the same name to bevalidated,legitimately added or reordered prior to verification. There are likely to be legitimate exceptions to this rule, because of thefollowing steps shouldwide variety of application- specific header fields which may beperformed in such a manner asapplied toproducearesult that is semantically equivalentmessage, some of which are unlikely toperforming them in the indicated order. 6.1.1 Validatebe duplicated, modified, or reordered. Signers SHOULD include all or nearly all of theSignature Header Field Implementers MUST meticulously validatebody content when specifying theformat and valuesbody length count (l= tag) in theDKIM-Signature header field; any inconsistency or unexpected values MUST cause the header field to be completely ignoredsignature. In particular, signers SHOULD NOT specify a body length of 0 since this may be interpreted as a meaningless signature by some verifiers. 5.5 Compute the Message Hash and Signature The signer MUST compute theverifier to return PERMFAIL (signature syntax error). Being "liberal in what you accept" is definitely a bad strategymessage hash as described inthis security context. Note however that this does not includeSection 3.7 and then sign it using theexistence of unknown tagsselected public-key algorithm. This will result in a DKIM-Signature headerfield,field whichare explicitly permitted. Verifiers MUST ignore DKIM-Signature header fields with a "v=" tag that is inconsistent with this specificationwill include the body hash andreturn PERMFAIL (incompatible version). INFORMATIVE IMPLEMENTATION NOTE: An implementation may, of course, choose to also verify signatures generated by older versionsa signature ofthis specification. If any tag listed as "required" in Section 3.5 is omitted fromtheDKIM-Signatureheaderfield, the verifier MUST ignorehash, where that header includes theDKIM- SignatureDKIM-Signature header fieldand return PERMFAIL (signature missing required tag). INFORMATIONAL NOTE: The tags listeditself. Entities such asrequired in Section 3.5 are "v=", "a=", "b=", "bh=", "d=", "h=", and "s=". Should there be a conflict between this notemailing list managers that implement DKIM andSection 3.5, Section 3.5 is normative. Ifwhich modify the"DKIM-Signature"message or a header fielddoes not contain the "i=" tag,(for example, inserting unsubscribe information) before retransmitting theverifiermessage SHOULD check any existing signature on input and MUSTbehave as thoughmake such modifications before re-signing thevaluemessage. The signer MAY elect to limit the number of bytes of the body that will be included in the hash and hence signed. The length actually hashed should be inserted in the "l=" tagwere "@d", where "d" isof thevalue from"DKIM-Signature" header field. 5.6 Insert the"d=" tag. VerifiersDKIM-Signature Header Field Finally, the signer MUSTconfirm thatinsert thedomain specified"DKIM-Signature:" header field created in the"d=" tag isprevious step prior to transmitting the email. The "DKIM-Signature" header field MUST be the same asor a parent domain ofused to compute thedomain part ofhash as described above, except that the"i=" tag. If not,value of theDKIM-Signature header field"b=" tag MUST beignored andtheverifier should return PERMFAIL (domain mismatch). Ifappropriately signed hash computed in the"h=" tag does not includeprevious step, signed using the"From" header fieldalgorithm specified in theverifier MUST ignore"a=" tag of theDKIM-Signature"DKIM- Signature" header field andreturn PERMFAIL (From field not signed). Verifiers MAY ignoreusing theDKIM-Signature header field and return PERMFAIL (signature expired) if it contains an "x=" tag andprivate key corresponding to thesignature has expired. Verifiers MAY ignoreSelector given in theDKIM-Signature"s=" tag of the "DKIM-Signature" headerfield and return PERMFAIL (unacceptable signature header) forfield, as chosen above in Section 5.2 The "DKIM-Signature" MUST be inserted before any otherreason, for example, if the signature does not sign headerDKIM-Signature fieldsthat the verifier views to be essential. As a caseinpoint, if MIME header fields are not signed, certain attacks may be possible thattheverifier would preferheader block. INFORMATIVE IMPLEMENTATION NOTE: The easiest way toavoid. 6.1.2 Getachieve this is to insert thePublic Key The public key for a signature is needed to complete"DKIM-Signature" header field at theverification process. The processbeginning ofretrieving the public key depends onthequery typeheader block. In particular, it may be placed before any existing Received header fields. This is consistent with treating "DKIM-Signature" asdefined by the "q=" tag in the "DKIM-Signature:"a trace header field.Obviously,6. Verifier Actions Since a signer MAY remove or revoke a public keyneed only be retrieved if the process of extracting the signature information is completely successful. Details of key management and representation are described in Section 3.6. The verifier MUST validate the key record and MUST ignoreat anypublic key recordstime, it is recommended thatare malformed. When validating a message, a verifier MUST perform the following stepsverification occur in amanner that is semantically the same as performing them intimely manner. In many configurations, theorder indicated (in some casesmost timely place is during acceptance by theimplementation may parallelizeborder MTA orreorder these steps, as long as the semantics remain unchanged): 1. Retrieve the public key as described in (Section 3.6) using the algorithm in the "q=" tag, the domain from the "d=" tag, and the Selector from the "s=" tag. 2. Ifshortly thereafter. In particular, deferring verification until thequery formessage is accessed by thepublic key fails to respond,end user is discouraged. A border or intermediate MTA MAY verify theverifiermessage signature(s). An MTA who has performed verification MAYdefer acceptancecommunicate the result ofthis email and return TEMPFAIL (key unavailable). Ifthat verificationis occurring during the incoming SMTP session, this MAY be achieved withby adding a451/4.7.5 SMTP reply code. Alternatively,verification header field to incoming messages. This considerably simplifies things for theverifier MAY storeuser, who can now use an existing mail user agent. Most MUAs have the ability to filter messages based on messagein the local queue for later trialheader fields orignorecontent; these filters would be used to implement whatever policy thesignature. Note that storinguser wishes with respect to unsigned mail. A verifying MTA MAY implement amessage in the local queue is subjectpolicy with respect todenial-of- service attacks. 3. If the query for the public key fails because the corresponding key record doesunverifiable mail, regardless of whether or notexist,it applies theverifierverification header field to signed messages. Verifiers MUSTimmediately return PERMFAIL (no key for signature). 4. If the query for the public key returns multiple key records, the verifier may choose one of the key records or may cycle throughproduce a result that is semantically equivalent to applying thekey records performingfollowing steps in theremainderorder listed. In practice, several of these stepson each record at the discretion ofcan be performed in parallel in order to improve performance. 6.1 Extract Signatures from theimplementer.Message The orderof the key recordsin which verifiers try DKIM-Signature header fields isunspecified. If the verifier choosesnot defined; verifiers MAY try signatures in any order they would like. For example, one implementation might prefer tocycle through the key records, thentry the"return ..." wordingsignatures inthe remainder of this section means "try the next key record, if any; if none, return to trytextual order, whereas anothersignature in the usual way." 5. If the result returned from the query does not adheremight want to prefer signatures by identities that match theformat defined in this specification, the verifier MUST ignorecontents of thekey record and return PERMFAIL (key syntax error)."From" header field over other identities. Verifiersare urgedMUST NOT attribute ultimate meaning tovalidatethesyntaxorder ofkey records carefully to avoid attempted attacks.multiple DKIM-Signature header fields. In particular,the verifier MUST ignore keys with a version code ("v=" tag)there is reason to believe thatthey do not implement. 6. Ifsome relays will reorder the"g=" tagheader fields in potentially arbitrary ways. INFORMATIVE IMPLEMENTATION NOTE: Verifiers might use thepublic key does not match the Local-part of the "i=" tagorder as a clue to signing order in themessage signature header field, the verifier MUST ignore the key record and return PERMFAIL (inapplicable key). If the Local-partabsence of any other information. However, other clues as to the"i=" tag on the message signature is not present, the g= tag must be * (valid for all addresses in the domain) orsemantics of multiple signatures (such as correlating theentire g= tag mustsigning host with Received header fields) may also beomitted (which defaults to "g=*"), otherwise theconsidered. A verifierMUST ignore the key record and return PERMFAIL (inapplicable key). Other than this test, verifiersSHOULD NOT treat a messagesignedthat has one or more bad signatures and no good signatures differently from a message with no signature at all; such treatment is akey record havingmatter of local policy and is beyond the scope of this document. When ag= tagsignature successfully verifies, a verifier will either stop processing or attempt to verify anydifferently than one without; in particular, verifiers SHOULD NOT prefer messages that seemother signatures, at the discretion of the implementation. A verifier MAY limit the number of signatures it tries tohave an individual signature by virtueavoid denial-of-service attacks. INFORMATIVE NOTE: An attacker could send messages with large numbers of faulty signatures, each of which would require ag= tag versus a domain signature. 7. IfDNS lookup and corresponding CPU time to verify the"h=" tag exists inmessage. This could be an attack on thepublic key record anddomain that receives thehash algorithm impliedmessage, by slowing down the verifier by requiring it to do large number of DNS lookups and/or signature verifications. It could also be an attack against thea= tagdomains listed in theDKIM-Signature header field is not includedsignatures, essentially by enlisting innocent verifiers in launching an attack against thecontentsDNS servers of the"h=" tag,actual victim. In the following description, text reading "return status (explanation)" (where "status" is one of "PERMFAIL" or "TEMPFAIL") means that the verifier MUSTignoreimmediately cease processing that signature. The verifier SHOULD proceed to thekey recordnext signature, if any is present, andreturn PERMFAIL (inappropriate hash algorithm). 8.completely ignore the bad signature. If thepublic key data (the "p=" tag)status isempty then this key has been revoked and"PERMFAIL", theverifier MUST treat this as a failedsignaturecheckfailed andreturn PERMFAIL (key revoked). Thereshould not be reconsidered. If the status isno defined semantic difference between"TEMPFAIL", the signature could not be verified at this time but may be tried again later. A verifier MAY either defer the message for later processing, perhaps by queueing it locally or issuing akey that has been revoked451/4.7.5 SMTP reply, or try another signature; if no good signature is found and any of the signatures resulted in akey record that has been removed. 9. IfTEMPFAIL status, thepublic key dataverifier MAY save the message for later processing. The "(explanation)" is notsuitablenormative text; it is provided solely foruse with the algorithm and key types defined byclarification. Verifiers SHOULD ignore any DKIM-Signature header fields where the"a=" and "k=" tags insignature does not validate. Verifiers that are prepared to validate multiple signature header fields SHOULD proceed to the"DKIM- Signature"next signature header field, should it exist. However, verifiers MAY make note of theverifier MUST immediately return PERMFAIL (inappropriate key algorithm). 6.1.3 Compute the Verification Given a signer andfact that an invalid signature was present for consideration at apublic key, verifyinglater step. INFORMATIVE NOTE: The rationale of this requirement is to permit messages that have invalid signatures but also a valid signatureconsists of actions semantically equivalentto work. For example, a mailing list exploder might opt to leave thefollowing steps. 1. Based on the algorithm definedoriginal submitter signature in place even though the"c=" tag,exploder knows that it is modifying thebody length specifiedmessage inthe "l=" tag,some way that will break that signature, and theheader field namesexploder inserts its own signature. In this case the message should succeed even in the"h=" tag, prepare a canonicalized versionpresence of themessage as is described in Section 3.7 (note that this version does not actually needknown-broken signature. For each signature to beinstantiated). When matching header field names in the "h=" tag againstvalidated, theactual message header field, comparisons MUSTfollowing steps should becase-insensitive. 2. Based on the algorithm indicatedperformed inthe "a=" tag, compute the message hashes from the canonical copysuch a manner asdescribed in Section 3.7. 3. Verifyto produce a result thatthe hash of the canonicalized message body computedis semantically equivalent to performing them in theprevious step matchesindicated order. 6.1.1 Validate thehash value conveyedSignature Header Field Implementers MUST meticulously validate the format and values in the"bh=" tag. IfDKIM-Signature header field; any inconsistency or unexpected values MUST cause thehash does not match,header field to be completely ignored and the verifierSHOULD ignore the signature andto return PERMFAIL(body hash did not verify). 4. Using the signature conveyed(signature syntax error). Being "liberal inthe "b=" tag, verify the signature against the header hash using the mechanism appropriate for the public key algorithm describedwhat you accept" is definitely a bad strategy inthe "a=" tag. If the signaturethis security context. Note however that this does notvalidate,include theverifier SHOULDexistence of unknown tags in a DKIM-Signature header field, which are explicitly permitted. Verifiers MUST ignorethe signatureDKIM-Signature header fields with a "v=" tag that is inconsistent with this specification and return PERMFAIL(signature did not verify). 5. Otherwise, the signature has correctly verified.(incompatible version). INFORMATIVEIMPLEMENTER'SIMPLEMENTATION NOTE:Implementations might wishAn implementation may, of course, choose toinitiate the public-key queryalso verify signatures generated by older versions of this specification. If any tag listed as "required" inparallel with calculatingSection 3.5 is omitted from thehash asDKIM-Signature header field, thepublic keyverifier MUST ignore the DKIM- Signature header field and return PERMFAIL (signature missing required tag). INFORMATIONAL NOTE: The tags listed as required in Section 3.5 are "v=", "a=", "b=", "bh=", "d=", "h=", and "s=". Should there be a conflict between this note and Section 3.5, Section 3.5 is normative. If the "DKIM-Signature" header field does notneeded untilcontain thefinal decryption"i=" tag, the verifier MUST behave as though the value of that tag were "@d", where "d" iscalculated. Implementations may also verifythesignature onvalue from themessage header before validating"d=" tag. Verifiers MUST confirm that themessage hash listeddomain specified in the"bh=""d=" taginis the same as or a parent domain of the domain part of the "i=" tag. If not, the DKIM-Signature header fieldmatches that ofMUST be ignored and theactual message body; however, ifverifier should return PERMFAIL (domain mismatch). If thebody hash"h=" tag does notmatch,include theentire signature must be considered to have failed. A body length specified in"From" header field the"l="verifier MUST ignore the DKIM-Signature header field and return PERMFAIL (From field not signed). Verifiers MAY ignore the DKIM-Signature header field and return PERMFAIL (signature expired) if it contains an "x=" tagofand the signaturelimitshas expired. Verifiers MAY ignore thenumber of bytes of the body passed toDKIM-Signature header field and return PERMFAIL (unacceptable signature header) for any other reason, for example, if theverification algorithm. All data beyond that limit issignature does notvalidated by DKIM. Hence, verifiers might treat a messagesign header fields thatcontains bytes beyond the indicated body length with suspicion, such as by truncatingthemessage atverifier views to be essential. As a case in point, if MIME header fields are not signed, certain attacks may be possible that theindicated body length, declaringverifier would prefer to avoid. 6.1.2 Get the Public Key The public key for a signatureinvalid (e.g., by returning PERMFAIL (unsigned content)), or conveyingis needed to complete thepartialverificationtoprocess. The process of retrieving thepolicy module. INFORMATIVE IMPLEMENTATION NOTE: Verifiers that truncatepublic key depends on thebody atquery type as defined by theindicated body length might pass on"q=" tag in the "DKIM-Signature:" header field. Obviously, amalformed MIME messagepublic key need only be retrieved if thesigner used the "N-4" trick (omittingprocess of extracting thefinal "--CRLF")signature information is completely successful. Details of key management and representation are described inthe informative note inSection3.4.5. Such verifiers may wish to check for this case and include a trailing "--CRLF" to avoid breaking3.6. The verifier MUST validate theMIME structure. A simple way to achieve this might be to append "--CRLF" tokey record and MUST ignore any"multipart" message withpublic key records that are malformed. When validating abody length; ifmessage, a verifier MUST perform theMIME structurefollowing steps in a manner that isalready correctly formed, this will appearsemantically the same as performing them in thepostlude and will not be displayed toorder indicated (in some cases theend user. 6.2 Communicate Verification Results Verifiers wishing to communicateimplementation may parallelize or reorder these steps, as long as theresults of verification to other parts ofsemantics remain unchanged): 1. Retrieve themail system may do sopublic key as described inwhatever manner they see fit. For example, implementations might choose to add an email header field to(Section 3.6) using themessage before passing it on. Any such header field SHOULD be inserted before any existing DKIM-Signature or preexisting authentication status header fieldsalgorithm in theheader field block. INFORMATIVE ADVICE to MUA filter writers: Patterns intended to search for results header fields to visibly mark authenticated mail for end users should verify that such header field was added by"q=" tag, theappropriate verifyingdomain from the "d=" tag, andthattheverified identity matchesSelector from theauthor identity that will be displayed by"s=" tag. 2. If theMUA. In particular, MUA filters should not be influenced by bogus results header fields added by attackers. To circumvent this attack, verifiers may wishquery for the public key fails todelete existing results header fields after verificationrespond, the verifier MAY defer acceptance of this email andbefore adding a new header field. 6.3 Interpret Results/Apply Local Policy Itreturn TEMPFAIL (key unavailable). If verification isbeyondoccurring during thescope ofincoming SMTP session, thisspecification to describe what actionsMAY be achieved with a 451/4.7.5 SMTP reply code. Alternatively, the verifiersystem should make, but an authenticated email presents an opportunity to a receiving system that unauthenticated email cannot. Specifically, an authenticated email creates a predictable identifier by which other decisions can reliably be managed, such as trust and reputation. Conversely, unauthenticated email lacks a reliable identifier that can be used to assign trust and reputation. It is reasonable to treat unauthenticated email as lacking any trust and having no positive reputation. In general verifiers SHOULD NOT reject messages solely onMAY store thebasis of a lack of signaturemessage in the local queue for later trial oran unverifiableignore the signature.However, ifNote that storing a message in theverifier does optlocal queue is subject toreject such messages, anddenial-of- service attacks. 3. If theverifier runs synchronously withquery for theSMTP session and a signature is missing orpublic key fails because the corresponding key record does notverify, the MTA SHOULD rejectexist, themessage with an error such as: 550 5.7.1 Unsigned messages not accepted 550 5.7.5 Message signature incorrectverifier MUST immediately return PERMFAIL (no key for signature). 4. Ifit is not possible to fetchthepublic key, perhaps becausequery for the public keyserver is not available, a temporary failure message MAY be generated, such as: 451 4.7.5 Unable to verify signature -returns multiple keyserver unavailable Temporary failures such as inability to accessrecords, the verifier may choose one of the keyserverrecords orother external service aremay cycle through theonly conditions that SHOULD use a 4xx SMTP reply code. In particular, cryptographic signature verification failures MUST NOT return 4xx SMTP replies. Once the signature has been verified, that information MUST be conveyed to higher level systems (such as explicit allow/white lists and reputation systems) and/or to the end user. Ifkey records performing themessage is signed on behalfremainder ofany address other than that inthese steps on each record at theFrom: header field,discretion of themail system SHOULD take pains to ensure thatimplementer. The order of theactual signing identitykey records isclear tounspecified. If thereader. TheverifierMAY treat unsigned header fields with extreme skepticism, including marking them as untrusted or even deleting them before displaychooses to cycle through theend user. Whilekey records, then thesymptoms"return ..." wording in the remainder ofa failed verification are obvious --this section means "try the next key record, if any; if none, return to try another signaturedoesn't verify -- establishingin theexact cause can be more difficult.usual way." 5. Ifa Selector cannot be found, is that because the Selector has been removed or wasthevalue changed somehow in transit? Ifresult returned from thesignature line is missing is that because it was never there, or was it removed by an over-zealous filter? For diagnostic purposes,query does not adhere to theexact reason whyformat defined in this specification, theverification fails SHOULD be made available toverifier MUST ignore thepolicy modulekey record andpossibly recorded inreturn PERMFAIL (key syntax error). Verifiers are urged to validate thesystem logs. However in termssyntax ofpresentationkey records carefully to avoid attempted attacks. In particular, theend user, the result SHOULD be presented asverifier MUST ignore keys with asimple binary result: either the email is verified or it is not.version code ("v=" tag) that they do not implement. 6. If theemail cannot be verified, then it SHOULD be rendered"g=" tag in thesame as all unverified email regardlesspublic key does not match the Local-part ofwhether it looks like it was signed or not. 7. IANA Considerations DKIM introduces some new namespaces that require IANA registry. 7.1 DKIM-Signature Tag Specifications A DKIM-Signature provides for a listthe "i=" tag in the message signature header field, the verifier MUST ignore the key record and return PERMFAIL (inapplicable key). If the Local-part of the "i=" tagspecifications. IANAon the message signature isrequested to establishnot present, theDKIM Signature Tag Specification Registry, forg= tagspecifications that canmust beused* (valid for all addresses inDKIM-Signature fieldsthe domain) or the entire g= tag must be omitted (which defaults to "g=*"), otherwise the verifier MUST ignore the key record and return PERMFAIL (inapplicable key). Other than this test, verifiers SHOULD NOT treat a message signed with a key record having a g= tag any differently than one without; in particular, verifiers SHOULD NOT prefer messages that seem to havebeen specifiedan individual signature by virtue of a g= tag versus a domain signature. 7. If the "h=" tag exists inany published RFC. The initial entriesthe public key record and the hash algorithm implied by the a= tag in theregistry comprise: +------+-----------------+ | TYPE | REFERENCE | +------+-----------------+ | v | (this document) | | a | (this document) | | b | (this document) | | bh | (this document) | | c | (this document) | | d | (this document) | | h | (this document) | | i | (this document) | | l | (this document) | | q | (this document) | | s | (this document) | | t | (this document) | | x | (this document) | | z | (this document) | +------+-----------------+ 7.2DKIM-SignatureQuery Method Registry The "q=" tag-spec, as specifiedheader field is not included inSection 3.5 provides for a listthe contents ofquery methods. IANA is requested to establishtheDKIM Query Method Registry, for mechanisms that can be used to retrieve"h=" tag, the verifier MUST ignore the keythat will permit validation processing of a message signed using DKIMrecord andhavereturn PERMFAIL (inappropriate hash algorithm). 8. If the public key data (the "p=" tag) is empty then this key has beenspecified in any published RFC. The initial entry inrevoked and theregistry comprises: +------+--------+-----------------+ | TYPE | OPTION | REFERENCE | +------+--------+-----------------+ | dns | txt | (this document) | +------+--------+-----------------+ 7.3 DKIM-Signature Canonicalization Registry The "c=" tag-spec,verifier MUST treat this asspecified in Section 3.5 provides foraspecifier for canonicalization algorithms for the headerfailed signature check andbody of the message. IANAreturn PERMFAIL (key revoked). There isrequested to establish the DKIM Canonicalization Algorithm Registry, for algorithms for convertingno defined semantic difference between amessage intokey that has been revoked and acanonical form before signing or verifying using DKIM and havekey record that has beenspecified in any published RFC. The initial entriesremoved. 9. If the public key data is not suitable for use with the algorithm and key types defined by the "a=" and "k=" tags in the "DKIM- Signature" headerregistry comprise: +---------+-----------------+ | TYPE | REFERENCE | +---------+-----------------+ | simple | (this document) | | relaxed | (this document) | +---------+-----------------+ The initial entriesfield, the verifier MUST immediately return PERMFAIL (inappropriate key algorithm). 6.1.3 Compute the Verification Given a signer and a public key, verifying a signature consists of actions semantically equivalent to the following steps. 1. Based on the algorithm defined in the "c=" tag, the bodyregistry comprise: +---------+-----------------+ | TYPE | REFERENCE | +---------+-----------------+ | simple | (this document) | | relaxed | (this document) | +---------+-----------------+ 7.4 _domainkey DNS TXT Record Tag Specifications A _domainkey DNS TXT record provides forlength specified in the "l=" tag, and the header field names in the "h=" tag, prepare alistcanonicalized version oftag specifications. IANAthe message as isrequesteddescribed in Section 3.7 (note that this version does not actually need toestablishbe instantiated). When matching header field names in theDKIM _domainkey DNS TXT Tag Specification Registry, for"h=" tagspecifications that canagainst the actual message header field, comparisons MUST beused in DNS TXT Records and that have been specifiedcase-insensitive. 2. Based on the algorithm indicated inany published RFC. The initial entriesthe "a=" tag, compute the message hashes from the canonical copy as described in Section 3.7. 3. Verify that theregistry comprise: +------+-----------------+ | TYPE | REFERENCE | +------+-----------------+ | v | (this document) | | g | (this document) | | h | (this document) | | k | (this document) | | n | (this document) | | p | (this document) | | s | (this document) | | t | (this document) | +------+-----------------+ 7.5 DKIM Key Type Registry The "k=" <key-k-tag> (as specified in Section 3.6.1) and the "a=" <sig-a-tag-k> (Section 3.5) tags provide for a listhash ofmechanisms that can be used to decode a DKIM signature. IANA is requested to establishtheDKIM Key Type Registry, for such mechanisms that have been specified in any published RFC. The initial entrycanonicalized message body computed in theregistry comprises: +------+-----------+ | TYPE | REFERENCE | +------+-----------+ | rsa | [RFC3447] | +------+-----------+ 7.6 DKIM Hash Algorithms Registry The "h=" <key-h-tag> list (specifiedprevious step matches the hash value conveyed inSection 3.6.1)the "bh=" tag. If the hash does not match, the verifier SHOULD ignore the signature and return PERMFAIL (body hash did not verify). 4. Using the"a=" <sig-a-tag-h> (Section 3.5) provide for a list of mechanisms that can be used to produce a digest of message data. IANA is requested to establishsignature conveyed in theDKIM Hash Algorithms Registry,"b=" tag, verify the signature against the header hash using the mechanism appropriate forsuch mechanisms that have been specified in any published RFC. The initial entriesthe public key algorithm described in theregistry comprise: +--------+-----------+ | TYPE | REFERENCE | +--------+-----------+ | sha1 | [SHA] | | sha256 | [SHA] | +--------+-----------+ 7.7 DKIM Service Types Registry The "s=" <key-s-tag> list (specified in Section 3.6.1) provides for a list of service types to which this selector may apply. IANA is requested"a=" tag. If the signature does not validate, the verifier SHOULD ignore the signature and return PERMFAIL (signature did not verify). 5. Otherwise, the signature has correctly verified. INFORMATIVE IMPLEMENTER'S NOTE: Implementations might wish toestablishinitiate theDKIM Service Types Registry, for service types that have been specified in any published RFC. The initial entriespublic-key query in parallel with calculating theregistry comprise: +-------+-----------------+ | TYPE | REFERENCE | +-------+-----------------+ | email | (this document) | | * | (this document) | +-------+-----------------+ 7.8 DKIM Selector Flags Registry The "t=" <key-t-tag> list (specified in Section 3.6.1) provides for a list of flags to modify interpretation ofhash as theselector. IANApublic key isrequested to establishnot needed until theDKIM Selector Flags Registry, for additional flagsfinal decryption is calculated. Implementations may also verify the signature on the message header before validating thathave been specifiedthe message hash listed inany published RFC. The initial entriesthe "bh=" tag in theregistry comprise: +------+-----------------+ | TYPE | REFERENCE | +------+-----------------+ | y | (this document) | | s | (this document) | +------+-----------------+ 7.9 DKIM-Signature Header Field IANA is requested to addDKIM-Signaturetoheader field matches that of the"Permanent Header Messages" registry foractual message body; however, if the"mail" protocol, using this document asbody hash does not match, theReference. 8. Security Considerations It has been observed that any mechanism that is introduced which attempts to stem the flow of spam is subject to intensive attack. DKIM needs toentire signature must becarefully scrutinizedconsidered toidentify potential attack vectors andhave failed. A body length specified in thevulnerability to each. See also [RFC4686]. 8.1 Misuse"l=" tag ofBody Length Limits ("l=" Tag) Body lengththe signature limits(intheformnumber ofthe "l=" tag) are subject to several potential attacks. 8.1.1 Additionbytes ofnew MIME parts to multipart/* Ifthe bodylengthpassed to the verification algorithm. All data beyond that limitdoesis notcovervalidated by DKIM. Hence, verifiers might treat aclosing MIME multipart section (includingmessage that contains bytes beyond the indicated body length with suspicion, such as by truncating thetrailing ""--CRLF"" portion), then it is possible for an attacker to intercept a properly signed multipartmessageand add a newat the indicated bodypart. Depending onlength, declaring thedetails ofsignature invalid (e.g., by returning PERMFAIL (unsigned content)), or conveying the partial verification to the policy module. INFORMATIVE IMPLEMENTATION NOTE: Verifiers that truncate the body at the indicated body length might pass on a malformed MIMEtype andmessage if theimplementation ofsigner used theverifying MTA and"N-4" trick (omitting thereceiving MUA,final "--CRLF") described in the informative note in Section 3.4.5. Such verifiers may wish to check for thiscould allow an attackercase and include a trailing "--CRLF" tochangeavoid breaking theinformation displayedMIME structure. A simple way to achieve this might be toan end user from an apparently trusted source. For example, if an attacker canappendinformation"--CRLF" to any "multipart" message with a"text/html"bodypart, they may be able to exploit a buglength; if the MIME structure is already correctly formed, this will appear insome MUAs that continue to read after a "</html>" marker,the postlude andthus display HTML text on top of already displayed text. If a message has a "multipart/ alternative" body part, they mightwill not beabledisplayed toadd a new body part that is preferred bythedisplaying MTA. 8.1.2 Additionend user. 6.2 Communicate Verification Results Verifiers wishing to communicate the results ofnew HTML contentverification toexisting content Several receiving MUA implementations do not cease display after a ""</html>"" tag. In particular, this allows attacks involving overlaying images on topother parts ofexisting text. INFORMATIVE EXAMPLE: Appendingthefollowing textmail system may do so in whatever manner they see fit. For example, implementations might choose to add anexisting, properly closedemail header field to the messagewill in many MUAs resultbefore passing it on. Any such header field SHOULD be inserted before any existing DKIM-Signature or preexisting authentication status header fields ininappropriate data being rendered on top of existing, correct data: <div style="position: relative; bottom: 350px; z-index: 2;"> <img src="http://www.ietf.org/images/ietflogo2e.gif" width=578 height=370> </div> 8.2 Misappropriated Private Key Iftheprivate key for a user is resident on their computer and is not protected by an appropriately secure mechanism, it is possibleheader field block. INFORMATIVE ADVICE to MUA filter writers: Patterns intended to search formalwareresults header fields tosendvisibly mark authenticated mailasfor end users should verify thatuser and any other user sharingsuch header field was added by thesame private key. The malware would, however,appropriate verifying domain and that the verified identity matches the author identity that will be displayed by the MUA. In particular, MUA filters should not beableinfluenced by bogus results header fields added by attackers. To circumvent this attack, verifiers may wish togenerate signed spoofs of other signers' addresses, which would aid in identification of the infected userdelete existing results header fields after verification andwould limitbefore adding a new header field. 6.3 Interpret Results/Apply Local Policy It is beyond thepossibilities for certain typesscope ofattacks involving socially- engineered messages. This threat applies mainlythis specification toMUA-based implementations; protection of private keys on serversdescribe what actions a verifier system should make, but an authenticated email presents an opportunity to a receiving system that unauthenticated email cannot. Specifically, an authenticated email creates a predictable identifier by which other decisions can reliably beeasily achieved through the use of specialized cryptographic hardware. A larger problem occurs if malware on many users' computers obtains the private keys for those usersmanaged, such as trust andtransmits them via a covert channel toreputation. Conversely, unauthenticated email lacks asite where theyreliable identifier that can beshared. The compromised users would likely not know of the misappropriation until they receive "bounce" messages from messages they are purportedused tohave sent. Many users might not understand the significance of these bounce messagesassign trust andwould not take action. One countermeasurereputation. It is reasonable touse a user-entered passphrase to encrypt the private key, although users tend to choose weak passphrasestreat unauthenticated email as lacking any trust andoften reuse them for different purposes, possibly allowinghaving no positive reputation. In general verifiers SHOULD NOT reject messages solely on the basis of a lack of signature or anattack against DKIM to be extended into other domains. Nevertheless,unverifiable signature; such rejection would cause severe interoperability problems. However, if thedecoded private key might be briefly availableverifier does opt tocompromise by malwarereject such messages (for example, whenit is entered, or might be discovered via keystroke logging. The added complexity of entering a passphrase each time one sendscommunicating with amessage would also tendpeer who, by prior agreement, agrees todiscourageonly send signed messages), and the verifier runs synchronously with the SMTP session and a signature is missing or does not verify, the MTA SHOULD useofasecure passphrase. A somewhat more effective countermeasure550/5.7.x reply code, for example: 550 5.7.1 Unsigned messages not accepted 550 5.7.5 Message signature incorrect If it is not possible tosend messages through an outgoing MTA that can authenticate the submitter using existing techniques (e.g., SMTP Authentication), possibly validatefetch themessage itself (e.g., verify thatpublic key, perhaps because theheaderkey server islegitimate and that the content passesnot available, aspam content check), and sign thetemporary failure message MAY be generated using a 451/4.7.5 reply code, such as: 451 4.7.5 Unable to verify signature - keyappropriate forserver unavailable Temporary failures such as inability to access thesubmitter address. Such an MTA can also apply controls onkey server or other external service are thevolume of outgoing mail each user is permitted to originate in order to further limit the ability of malware to generate bulk email. 8.3 Key Server Denial-of-Service Attacks Since the key servers are distributed (potentially separate for each domain),only conditions that SHOULD use a 4xx SMTP reply code. In particular, cryptographic signature verification failures MUST NOT return 4xx SMTP replies. Once thenumber of serverssignature has been verified, thatwould need toinformation MUST beattackedconveyed to higher level systems (such as explicit allow/white lists and reputation systems) and/or todefeat this mechanism on an Internet-wide basis is very large. Nevertheless, key servers for individual domains could be attacked, impedingtheverificationend user. If the message is signed on behalf ofmessages fromany address other than thatdomain. This is not significantly different fromin theability of an attacker to deny service toFrom: header field, the mailexchangers for a given domain, although it affects outgoing, not incoming, mail. A variation on this attack issystem SHOULD take pains to ensure thatif a very large amount of mail werethe actual signing identity is clear tobe sent using spoofed addresses from a given domain,thekey servers for that domain could be overwhelmedreader. The verifier MAY treat unsigned header fields withrequests. However, givenextreme skepticism, including marking them as untrusted or even deleting them before display to thelow overheadend user. While the symptoms of a failed verificationcompared with handling ofare obvious -- theemail message itself, such an attack wouldsignature doesn't verify -- establishing the exact cause can bedifficult to mount. 8.4 Attacks Against DNS Since DNS ismore difficult. If arequired binding for key services, specific attacks against DNS mustSelector cannot beconsidered. While the DNS is currently insecure [RFC3833], itfound, isexpectedthat because thesecurity problems should and will be solved by DNSSEC [RFC4033], and all users ofSelector has been removed or was theDNS will reapvalue changed somehow in transit? If thebenefit ofsignature line is missing is thatwork. Secondly, the types of DNS attacks relevant to DKIM are very costly and are far less rewarding than DNS attacks on other Internet protocols.because it was never there, or was it removed by an over-zealous filter? Forexample, attacking A records (to force users to a phishing site) is likely to be a more lucrative reason to poison DNS caches. Nonediagnostic purposes, theless,exact reason why thesecurity of DKIM is strongly tiedverification fails SHOULD be made available to thesecurity of DNS. To systematically thwart the intent of DKIM, an attacker must conduct a very costlypolicy module andvery extensive attack on many parts ofpossibly recorded in theDNS over an extended period. No one knows for sure how attackers will respond, howeversystem logs. If thecost/benefit of conducting prolonged DNS attacks of this nature is expected toemail cannot beuneconomical. Finally,verified, then it SHOULD be rendered the same as all unverified email regardless of whether it looks like it was signed or not. 7. IANA Considerations DKIMisintroduces some new namespaces that require IANA registry. In all cases, new values are assigned onlyintended asfor Standards Track RFCs approved by the IESG. 7.1 DKIM-Signature Tag Specifications A DKIM-Signature provides for a"sufficient" methodlist ofproving authenticity. Ittag specifications. IANA isnot intendedrequested toprovide strong cryptographic proof about authorship or contents. Other technologies such as OpenPGP [RFC2440] and S/MIME [RFC3851] address those requirements. A second security issue related to the DNS revolves aroundestablish theincreased DNS traffic as a consequence of fetching Selector-based data as well as fetching signing domain policy. Widespread deployment ofDKIMwill resultSignature Tag Specification Registry, for tag specifications that can be used ina significant increaseDKIM-Signature fields and that have been specified in any published RFC. The initial entries inDNS queries to the claimed signing domain. Inthecase of forgeries on a large scale, DNS servers could seeregistry comprise: +------+-----------------+ | TYPE | REFERENCE | +------+-----------------+ | v | (this document) | | asubstantial increase| (this document) | | b | (this document) | | bh | (this document) | | c | (this document) | | d | (this document) | | h | (this document) | | i | (this document) | | l | (this document) | | q | (this document) | | s | (this document) | | t | (this document) | | x | (this document) | | z | (this document) | +------+-----------------+ 7.2 DKIM-Signature Query Method Registry The "q=" tag-spec, as specified inqueries. 8.5 Replay Attacks In this attack, a spammer sendsSection 3.5 provides for amessagelist of query methods. IANA is requested to establish the DKIM Query Method Registry, for mechanisms that can bespammedused toan accomplice, which results inretrieve the key that will permit validation processing of a messagebeingsignedby the originating MTA.using DKIM and have been specified in any published RFC. Theaccomplice resends the message, includinginitial entry in theoriginal signature, toregistry comprises: +------+--------+-----------------+ | TYPE | OPTION | REFERENCE | +------+--------+-----------------+ | dns | txt | (this document) | +------+--------+-----------------+ 7.3 DKIM-Signature Canonicalization Registry The "c=" tag-spec, as specified in Section 3.5 provides for alarge numberspecifier for canonicalization algorithms for the header and body ofrecipients, possibly by sendingthemessagemessage. IANA is requested tomany compromised machines that act as MTAs. The messages, not having been modified byestablish theaccomplice,DKIM Canonicalization Algorithm Registry, for algorithms for converting a message into a canonical form before signing or verifying using DKIM and havevalid signatures. Partial solutions to this problem involvebeen specified in any published RFC. The initial entries in theuseheader registry comprise: +---------+-----------------+ | TYPE | REFERENCE | +---------+-----------------+ | simple | (this document) | | relaxed | (this document) | +---------+-----------------+ The initial entries in the body registry comprise: +---------+-----------------+ | TYPE | REFERENCE | +---------+-----------------+ | simple | (this document) | | relaxed | (this document) | +---------+-----------------+ 7.4 _domainkey DNS TXT Record Tag Specifications A _domainkey DNS TXT record provides for a list ofreputation servicestag specifications. IANA is requested toconveyestablish thefactDKIM _domainkey DNS TXT Tag Specification Registry, for tag specifications thatthe specific email address is beingcan be usedfor spam,in DNS TXT Records and thatmessages from that signer are likely to be spam. This requires a real-time detection mechanismhave been specified inorder to react quickly enough. However, such measures might be prone to abuse, if for example an attacker resent a large number of messages received from a victimany published RFC. The initial entries inorder to make them appear to be a spammer. Large verifiers might be able to detect unusually large volumes of mails withthesame signatureregistry comprise: +------+-----------------+ | TYPE | REFERENCE | +------+-----------------+ | v | (this document) | | g | (this document) | | h | (this document) | | k | (this document) | | n | (this document) | | p | (this document) | | s | (this document) | | t | (this document) | +------+-----------------+ 7.5 DKIM Key Type Registry The "k=" <key-k-tag> (as specified ina short time period. Smaller verifiers can get substantially the same volume information via existing collaborative systems. 8.6 Limits on Revoking Keys When a large domain detects undesirable behavior on the part of one of its users, it might wish to revokeSection 3.6.1) and thekey used to sign that user's messages in order to disavow responsibility"a=" <sig-a-tag-k> (Section 3.5) tags provide formessages which have not yet been verified or which are the subject ofareplay attack. However, the abilitylist ofthe domain to do somechanisms that can belimited if the same key, for scalability reasons, isused tosign messages for many other users. Mechanisms for explicitly revoking keys ondecode aper-address basis have been proposed but require further study asDKIM signature. IANA is requested totheir utility andestablish theDNS load they represent. 8.7 Intentionally malformedDKIM KeyRecords It is possibleType Registry, foran attacker to publish key recordssuch mechanisms that have been specified in any published RFC. The initial entry inDNS which are intentionally malformed, withtheintent of causing a denial-of- service attack on a non-robust verifier implementation.registry comprises: +------+-----------+ | TYPE | REFERENCE | +------+-----------+ | rsa | [RFC3447] | +------+-----------+ 7.6 DKIM Hash Algorithms Registry Theattacker could then cause a verifier to read"h=" <key-h-tag> list (specified in Section 3.6.1) and themalformed key record by sending"a=" <sig-a-tag-h> (Section 3.5) provide for amessage to onelist ofits users referencing the malformed record in a (not necessarily valid) signature. Verifiers MUST thoroughly verify all key records retrieved from DNS and be robust against intentionally as well as unintentionally malformed key records. 8.8 Intentionally Malformed DKIM-Signature header fields Verifiers MUSTmechanisms that can bepreparedused toreceive messages with malformed DKIM- Signature header fields, and thoroughly verify the header field before depending on any of its contents. 8.9 Information Leakage An attacker could determine when a particular signature was verified by usingproduce aper-message Selector and then monitoring their DNS traffic for the key lookup. This would act as the equivalentdigest ofa "web bug" for verification time rather than when themessagewas read. 8.10 Remote Timing Attacks In some cases it may be possibledata. IANA is requested toextract private keys using a remote timing attack [BONEH03]. Implementations should consider obfuscatingestablish thetiming to preventDKIM Hash Algorithms Registry, for suchattacks. 8.11 Reordered Header Fields Existing standardsmechanisms that have been specified in any published RFC. The initial entries in the registry comprise: +--------+-----------+ | TYPE | REFERENCE | +--------+-----------+ | sha1 | [SHA] | | sha256 | [SHA] | +--------+-----------+ 7.7 DKIM Service Types Registry The "s=" <key-s-tag> list (specified in Section 3.6.1) provides for a list of service types to which this selector may apply. IANA is requested to establish the DKIM Service Types Registry, for service types that have been specified in any published RFC. The initial entries in the registry comprise: +-------+-----------------+ | TYPE | REFERENCE | +-------+-----------------+ | email | (this document) | | * | (this document) | +-------+-----------------+ 7.8 DKIM Selector Flags Registry The "t=" <key-t-tag> list (specified in Section 3.6.1) provides for a list of flags to modify interpretation of the selector. IANA is requested to establish the DKIM Selector Flags Registry, for additional flags that have been specified in any published RFC. The initial entries in the registry comprise: +------+-----------------+ | TYPE | REFERENCE | +------+-----------------+ | y | (this document) | | s | (this document) | +------+-----------------+ 7.9 DKIM-Signature Header Field IANA is requested to add DKIM-Signature to the "Permanent Header Messages" registry for the "mail" protocol, using this document as the Reference. 8. Security Considerations It has been observed that any mechanism that is introduced which attempts to stem the flow of spam is subject to intensive attack. DKIM needs to be carefully scrutinized to identify potential attack vectors and the vulnerability to each. See also [RFC4686]. 8.1 Misuse of Body Length Limits ("l=" Tag) Body length limits (in the form of the "l=" tag) are subject to several potential attacks. 8.1.1 Addition of new MIME parts to multipart/* If the body length limit does not cover a closing MIME multipart section (including the trailing ""--CRLF"" portion), then it is possible for an attacker to intercept a properly signed multipart message and add a new body part. Depending on the details of the MIME type and the implementation of the verifying MTA and the receiving MUA, this could allow an attacker to change the information displayed to an end user from an apparently trusted source. For example, if an attacker can append information to a "text/html" body part, they may be able to exploit a bug in some MUAs that continue to read after a "</html>" marker, and thus display HTML text on top of already displayed text. If a message has a "multipart/ alternative" body part, they might be able to add a new body part that is preferred by the displaying MTA. 8.1.2 Addition of new HTML content to existing content Several receiving MUA implementations do not cease display after a ""</html>"" tag. In particular, this allows attacks involving overlaying images on top of existing text. INFORMATIVE EXAMPLE: Appending the following text to an existing, properly closed message will in many MUAs result in inappropriate data being rendered on top of existing, correct data: <div style="position: relative; bottom: 350px; z-index: 2;"> <img src="http://www.ietf.org/images/ietflogo2e.gif" width=578 height=370> </div> 8.2 Misappropriated Private Key If the private key for a user is resident on their computer and is not protected by an appropriately secure mechanism, it is possible for malware to send mail as that user and any other user sharing the same private key. The malware would, however, not be able to generate signed spoofs of other signers' addresses, which would aid in identification of the infected user and would limit the possibilities for certain types of attacks involving socially- engineered messages. This threat applies mainly to MUA-based implementations; protection of private keys on servers can be easily achieved through the use of specialized cryptographic hardware. A larger problem occurs if malware on many users' computers obtains the private keys for those users and transmits them via a covert channel to a site where they can be shared. The compromised users would likely not know of the misappropriation until they receive "bounce" messages from messages they are purported to have sent. Many users might not understand the significance of these bounce messages and would not take action. One countermeasure is to use a user-entered passphrase to encrypt the private key, although users tend to choose weak passphrases and often reuse them for different purposes, possibly allowing an attack against DKIM to be extended into other domains. Nevertheless, the decoded private key might be briefly available to compromise by malware when it is entered, or might be discovered via keystroke logging. The added complexity of entering a passphrase each time one sends a message would also tend to discourage the use of a secure passphrase. A somewhat more effective countermeasure is to send messages through an outgoing MTA that can authenticate the submitter using existing techniques (e.g., SMTP Authentication), possibly validate the message itself (e.g., verify that the header is legitimate and that the content passes a spam content check), and sign the message using a key appropriate for the submitter address. Such an MTA can also apply controls on the volume of outgoing mail each user is permitted to originate in order to further limit the ability of malware to generate bulk email. 8.3 Key Server Denial-of-Service Attacks Since the key servers are distributed (potentially separate for each domain), the number of servers that would need to be attacked to defeat this mechanism on an Internet-wide basis is very large. Nevertheless, key servers for individual domains could be attacked, impeding the verification of messages from that domain. This is not significantly different from the ability of an attacker to deny service to the mail exchangers for a given domain, although it affects outgoing, not incoming, mail. A variation on this attack is that if a very large amount of mail were to be sent using spoofed addresses from a given domain, the key servers for that domain could be overwhelmed with requests. However, given the low overhead of verification compared with handling of the email message itself, such an attack would be difficult to mount. 8.4 Attacks Against DNS Since DNS is a required binding for key services, specific attacks against DNS must be considered. While the DNS is currently insecure [RFC3833], these security problems are the motivation behind DNSSEC [RFC4033], and all users of the DNS will reap the benefit of that work. DKIM is only intended as a "sufficient" method of proving authenticity. It is not intended to provide strong cryptographic proof about authorship or contents. Other technologies such as OpenPGP [RFC2440] and S/MIME [RFC3851] address those requirements. A second security issue related to the DNS revolves around the increased DNS traffic as a consequence of fetching Selector-based data as well as fetching signing domain policy. Widespread deployment of DKIM will result in a significant increase in DNS queries to the claimed signing domain. In the case of forgeries on a large scale, DNS servers could see a substantial increase in queries. A specific DNS security issue which should be considered by DKIM verifiers is the name chaining attack described in section 2.3 of the DNS Threat Analysis [RFC3833]. A DKIM verifier, while verifying a DKIM-Signature header field, could be prompted to retrieve a key record of an attacker's choosing. This threat can be minimized by ensuring that name servers, including recursive name servers, used by the verifier enforce strict checking of "glue" and other additional information in DNS responses and are therefore not vulnerable to this attack. 8.5 Replay Attacks In this attack, a spammer sends a message to be spammed to an accomplice, which results in the message being signed by the originating MTA. The accomplice resends the message, including the original signature, to a large number of recipients, possibly by sending the message to many compromised machines that act as MTAs. The messages, not having been modified by the accomplice, have valid signatures. Partial solutions to this problem involve the use of reputation services to convey the fact that the specific email address is being used for spam, and that messages from that signer are likely to be spam. This requires a real-time detection mechanism in order to react quickly enough. However, such measures might be prone to abuse, if for example an attacker resent a large number of messages received from a victim in order to make them appear to be a spammer. Large verifiers might be able to detect unusually large volumes of mails with the same signature in a short time period. Smaller verifiers can get substantially the same volume information via existing collaborative systems. 8.6 Limits on Revoking Keys When a large domain detects undesirable behavior on the part of one of its users, it might wish to revoke the key used to sign that user's messages in order to disavow responsibility for messages which have not yet been verified or which are the subject of a replay attack. However, the ability of the domain to do so can be limited if the same key, for scalability reasons, is used to sign messages for many other users. Mechanisms for explicitly revoking keys on a per-address basis have been proposed but require further study as to their utility and the DNS load they represent. 8.7 Intentionally malformed Key Records It is possible for an attacker to publish key records in DNS which are intentionally malformed, with the intent of causing a denial-of- service attack on a non-robust verifier implementation. The attacker could then cause a verifier to read the malformed key record by sending a message to one of its users referencing the malformed record in a (not necessarily valid) signature. Verifiers MUST thoroughly verify all key records retrieved from DNS and be robust against intentionally as well as unintentionally malformed key records. 8.8 Intentionally Malformed DKIM-Signature header fields Verifiers MUST be prepared to receive messages with malformed DKIM- Signature header fields, and thoroughly verify the header field before depending on any of its contents. 8.9 Information Leakage An attacker could determine when a particular signature was verified by using a per-message Selector and then monitoring their DNS traffic for the key lookup. This would act as the equivalent of a "web bug" for verification time rather than when the message was read. 8.10 Remote Timing Attacks In some cases it may be possible to extract private keys using a remote timing attack [BONEH03]. Implementations should consider obfuscating the timing to prevent such attacks. 8.11 Reordered Header Fields Existing standards allow intermediate MTAs to reorder header fields. If a signer signs two or more header fields ofthe same name, this can cause spurious verification errors on otherwise legitimate messages.the same name, this can cause spurious verification errors on otherwise legitimate messages. In particular, signers that sign any existing DKIM- Signature fields run the risk of having messages incorrectly fail to verify. 8.12 RSA Attacks An attacker could create a large RSA signing key with a small exponent, thus requiring that the verification key have a large exponent. This will force verifiers to use considerable computing resources to verify the signature. Verifiers might avoid this attack by refusing to verify signatures that reference selectors with public keys having unreasonable exponents. In general, an attacker might try to overwhelm a verifier by flooding it with messages requiring verification. This is similar to other MTA denial-of-service attacks and should be dealt with in a similar fashion. 8.13 Inappropriate Signing by Parent Domains The trust relationship described in Section 3.8 could conceivably be used by a parent domain to sign messages with identities in a subdomain not administratively related to the parent. For example, the ".com" registry could create messages with signatures using an "i=" value in the example.com domain. There is no general solution to this problem, since the administrative cut could occur anywhere in the domain name. For example, in the domain "example.podunk.ca.us" there are three administrative cuts (podunk.ca.us, ca.us, and us), any of which could create messages with an identity in the full domain. INFORMATIVE NOTE: This is considered an acceptable risk for the same reason that it is acceptable for domain delegation. For example, in the example above any of the domains could potentially simply delegate "example.podunk.ca.us" to a server of their choice and completely replace all DNS-served information. 9. References 9.1 Normative References [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, November 1996. [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part Three: Message header field Extensions for Non-ASCII Text", RFC 2047, November 1996. [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. [RFC2821] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821, April 2001. [RFC2822] Resnick, P., "Internet Message Format", RFC 2822, April 2001. [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1", RFC 3447, February 2003. [RFC3490] Faltstrom, P., Hoffman, P., and A. Costello, "Internationalizing Domain Names in Applications (IDNA)", March 2003. [RFC4234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", RFC 4234, October 2005. [SHA] U.S. Department of Commerce, "Secure Hash Standard", FIPS PUB 180-2, August 2002. [X.660] "ITU-T Recommendation X.660 Information Technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER)", 1997. 9.2 Informative References [BONEH03] Proc. 12th USENIX Security Symposium, "Remote Timing Attacks are Practical", 2003, <http://www.usenix.org/ publications/library/proceedings/sec03/tech/brumley.html>. [RFC-DK] "DomainKeys specification (to be published with this RFC)", 2005. [RFC1847] Galvin, J., Murphy, S., Crocker, S., and N. Freed, "Security Multiparts for MIME: Multipart/Signed and Multipart/Encrypted", RFC 1847, October 1995. [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. Thayer, "OpenPGP Message Format", RFC 2440, November 1998. [RFC3766] Orman, H. and P. Hoffman, "Determining Strengths for Public Keys Used For Exchanging Symmetric Keys", RFC 3766, April 2004. [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the Domain Name System (DNS)", RFC 3833, August 2004. [RFC3851] Ramsdell, B., "S/MIME Version 3 Message Specification", RFC 3851, June 1999. [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, "DNS Security Introduction and Requirements", RFC 4033, March 2005. [RFC4686] Fenton, J., "Analysis of Threats Motivating DomainKeys Identified Mail (DKIM)", RFC 4686, September 2006. Authors' Addresses Eric Allman Sendmail, Inc. 6425 Christie Ave, Suite 400 Emeryville, CA 94608 USA Phone: +1 510 594 5501 Email: eric+dkim@sendmail.org URI: Jon Callas PGP Corporation 3460 West Bayshore Palo Alto, CA 94303 USA Phone: +1 650 319 9016 Email: jon@pgp.com Mark Delany Yahoo! Inc 701 First Avenue Sunnyvale, CA 95087 USA Phone: +1 408 349 6831 Email: markd+dkim@yahoo-inc.com URI: Miles Libbey Yahoo! Inc 701 First Avenue Sunnyvale, CA 95087 USA Email: mlibbeymail-mailsig@yahoo.com URI: Jim Fenton Cisco Systems, Inc. MS SJ-24/2 170 W. Tasman Drive San Jose, CA 95134-1706 USA Phone: +1 408 526 5914 Email: fenton@cisco.com URI: Michael Thomas Cisco Systems, Inc. MS SJ-9/2 170 W. Tasman Drive San Jose, CA 95134-1706 Phone: +1 408 525 5386 Email: mat@cisco.com Appendix A. Example of Use (INFORMATIVE) This section shows the complete flow of an email from submission to final delivery, demonstrating how the various components fit together. A.1 The user composes an email From: Joe SixPack <joe@football.example.com> To: Suzie Q <suzie@shopping.example.net> Subject: Is dinner ready? Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) Message-ID: <20030712040037.46341.5F8J@football.example.com> Hi. We lost the game. Are you hungry yet? Joe. A.2 The email is signed This email is signed by the example.com outbound email server and now looks like this: DKIM-Signature: a=rsa-sha256; s=brisbane; d=example.com; c=simple; q=dns/txt; i=joe@football.example.com; h=Received : From : To : Subject : Date : Message-ID; bh=jpltwNFTq83Bkjt/Y2ekyqr/+i296daNkFZSdaz8VCY=; b=bnUoMBPJ5wBigyZG2V4OG2JxLWJATkSkb9Ig+8OAu3cE2x/er+B 7Tp1a1kEwZKdOtlTHlvF4JKg6RZUbN5urRJoaiD4RiSbf8D6fmMHt zEn8/OHpTCcdLOJaTp8/mKz69/RpatVBas2OqWas7jrlaLGfHdBkt Hs6fxOzzAB7Wro=; Received: fromdsl-10.2.3.4.football.example.com [10.2.3.4]client1.football.example.com [192.0.2.1] by submitserver.example.com with SUBMISSION; Fri, 11 Jul 2003 21:01:54 -0700 (PDT) From: Joe SixPack <joe@football.example.com> To: Suzie Q <suzie@shopping.example.net> Subject: Is dinner ready? Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) Message-ID: <20030712040037.46341.5F8J@football.example.com> Hi. We lost the game. Are you hungry yet? Joe. The signing email server requires access to theprivate-keyprivate key associated with the "brisbane" Selector to generate this signature. A.3 The email signature is verified The signature is normally verified by an inbound SMTP server or possibly the final delivery agent. However, intervening MTAs can also perform this verification if they choose to do so. The verification process uses the domain "example.com" extracted from the "d=" tag and the Selector "brisbane" from the "s=" tag in the "DKIM- Signature" header field to form the DNS DKIM query for: brisbane._domainkey.example.com Signature verification starts with the physically last "Received" header field, the "From" header field, and so forth, in the order listed in the "h=" tag. Verification follows with a single CRLF followed by the body (starting with "Hi."). The email is canonically prepared for verifying with the "simple" method. The result of the query and subsequent verification of the signature is stored (in this example) in the "X-Authentication-Results" header field line. After successful verification, the email looks like this: X-Authentication-Results: shopping.example.net header.from=joe@football.example.com; dkim=pass Received: from mout23.football.example.com (192.168.1.1) by shopping.example.net with SMTP; Fri, 11 Jul 2003 21:01:59 -0700 (PDT) DKIM-Signature: a=rsa-sha256; s=brisbane; d=example.com; c=simple; q=dns/txt; i=joe@football.example.com; h=Received : From : To : Subject : Date : Message-ID; bh=jpltwNFTq83Bkjt/Y2ekyqr/+i296daNkFZSdaz8VCY=; b=bnUoMBPJ5wBigyZG2V4OG2JxLWJATkSkb9Ig+8OAu3cE2x/er+B 7Tp1a1kEwZKdOtlTHlvF4JKg6RZUbN5urRJoaiD4RiSbf8D6fmMHt zEn8/OHpTCcdLOJaTp8/mKz69/RpatVBas2OqWas7jrlaLGfHdBkt Hs6fxOzzAB7Wro=; Received: fromdsl-10.2.3.4.network.example.com [10.2.3.4]client1.football.example.com [192.0.2.1] by submitserver.example.com with SUBMISSION; Fri, 11 Jul 2003 21:01:54 -0700 (PDT) From: Joe SixPack <joe@football.example.com> To: Suzie Q <suzie@shopping.example.net> Subject: Is dinner ready? Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) Message-ID: <20030712040037.46341.5F8J@football.example.com> Hi. We lost the game. Are you hungry yet? Joe. INFORMATIVE NOTE: The key used to compute this signature is shown in Appendix C. Appendix B. Usage Examples (INFORMATIVE) DKIM signing and validating can be used in different ways, for different operational scenarios. This Appendix discusses some common examples. NOTE: Descriptions in this Appendix are for informational purposes only. They describe various ways that DKIM can be used, given particular constraints and needs. In no case are these examples intended to be taken as providing explanation or guidance concerning DKIM specification details, when creating an implementation. B.1 Alternate Submission Scenarios In the most simple scenario, a user's MUA, MSA, and Internet (boundary) MTA are all within the same administrative environment, using the same domain name. Therefore, all of the components involved in submission and initial transfer are related. However it is common for two or more of the components to be under independent administrative control. This creates challenges for choosing and administering the domain name to use for signing, and for its relationship to common email identity header fields. B.1.1 Delegated Business Functions Some organizations assign specific business functions to discrete groups, inside or outside the organization. The goal, then, is to authorize that group to sign some mail, but to constrain what signatures they can generate. DKIM Selectors (the "s=" signature tag) and granularity (the "g=" key tag) facilitate this kind of restricted authorization. Examples of these outsourced business functions are legitimate email marketing providers and corporate benefits providers. Here, the delegated group needs to be able to send messages that are signed, using the email domain of the client company. At the same time, the client often is reluctant to register a key for the provider that grants the ability to send messages for arbitrary addresses in the domain. There are multiple ways to administer these usage scenarios. In one case, the client organization provides all of the public query service (for example, DNS) administration, and in another it uses DNS delegation to enable all on-going administration of the DKIM key record by the delegated group. If the client organization retains responsibility for all of the DNS administration, the outsourcing company can generate a key pair, supplying the public key to the client company, which then registers it in the query service, using a unique Selector that authorizes a specific From header field local-part. For example, a client with the domain "example.com" could have the Selector record specify "g=winter-promotions" so that this signature is only valid for mail with a From address of "winter-promotions@example.com". This would enable the provider to send messages using that specific address and have them verify properly. The client company retains control over the email address because it retains the ability to revoke the key at any time. If the client wants the delegated group to do the DNS administration, it can have the domain name that is specified with the selector point to the provider's DNS server. The provider then creates and maintains all of the DKIM signature information for that Selector. Hence, the client cannot provide constraints on the local-part of addresses that get signed, but it can revoke the provider's signing rights by removing the DNS delegation record. B.1.2 PDAs and Similar Devices PDAs demonstrate the need for using multiple keys per domain. Suppose that John Doe wanted to be able to send messages using his corporate email address, jdoe@example.com, and his email device did not have the ability to make a VPN connection to the corporate network, either because the device is limited or because there are restrictions enforced by his Internet access provider. If the device was equipped with a private key registered for jdoe@example.com by the administrator of the example.com domain, and appropriate software to sign messages, John could sign the message on the device itself before transmission through the outgoing network of the access service provider. B.1.3 Roaming Users Roaming users often find themselves in circumstances where it is convenient or necessary to use an SMTP server other than their home server; examples are conferences and many hotels. In such circumstances a signature that is added by the submission service will use an identity that is different from the user's home system. Ideally roaming users would connect back to their home server using either a VPN or a SUBMISSION server running with SMTP AUTHentication on port 587. If the signing can be performed on the roaming user's laptop then they can sign before submission, although the risk of further modification is high. If neither of these are possible, these roaming users will not be able to send mail signed using their own domain key. B.1.4 Independent (Kiosk) Message Submission Stand-alone services, such as walk-up kiosks and web-based information services, have no enduring email service relationship with the user, but the user occasionally requests that mail be sent on their behalf. For example, a website providing news often allows the reader to forward a copy of the article to a friend. This is typically done using the reader's own email address, to indicate who the author is. This is sometimes referred to as the "Evite problem", named after the website of the same name that allows a user to send invitations to friends. A common way this is handled is to continue to put the reader's email address in the From header field of the message, but put an address owned by the email posting site into the Sender header field. The posting site can then sign the message, using the domain that is in the Sender field. This provides useful information to the receiving email site, which is able to correlate the signing domain with the initial submission email role. Receiving sites often wish to provide their end users with information about mail that is mediated in this fashion. Although the real efficacy of different approaches is a subject for human factors usability research, one technique that is used is for the verifying system to rewrite the From header field, to indicate the address that was verified. For example: From: John Doe via news@news-site.com <jdoe@example.com>. (Note that, such rewriting will break a signature, unless it is done after the verification pass is complete.) B.2 Alternate Delivery Scenarios Email is often received at a mailbox that has an address different from the one used during initial submission. In these cases, an intermediary mechanism operates at the address originally used and it then passes the message on to the final destination. This mediation process presents some challenges for DKIM signatures. B.2.1 Affinity Addresses "Affinity addresses" allow a user to have an email address that remains stable, even as the user moves among different email providers. They are typically associated with college alumni associations, professional organizations, and recreational organizations with which they expect to have a long-term relationship. These domains usually provide forwarding of incoming email, and they often have an associated Web application which authenticates the user and allows the forwarding address to be changed. However these services usually depend on the user's sending outgoing messages through their own service provider's MTA. Hence, mail that is signed with the domain of the affinity address is not signed by an entity that is administered by the organization owning that domain. With DKIM, affinity domains could use the Web application to allow users to register per-user keys to be used to sign messages on behalf of their affinity address. The user would take away the secret half of the key pair for signing, and the affinity domain would publish the public half in DNS for access by verifiers. This is another application that takes advantage of user-level keying, and domains used for affinity addresses would typically have a very large number of user-level keys. Alternatively, the affinity domain could handle outgoing mail, operating a mail submission agent that authenticates users before accepting and signing messages for them. This is of course dependent on the user's service provider not blocking the relevant TCP ports used for mail submission. B.2.2 Simple Address Aliasing (.forward) In some cases a recipient is allowed to configure an email address to cause automatic redirection of email messages from the original address to another, such as through the use of a Unix .forward file. In this case messages are typically redirected by the mail handling service of the recipient's domain, without modification, except for the addition of a Received header field to the message and a change in the envelope recipient address. In this case, the recipient at the final address' mailbox is likely to be able to verify the original signature since the signed content has not changed, and DKIM is able to validate the message signature. B.2.3 Mailing Lists and Re-Posters There is a wide range of behaviors in services that take delivery of a message and then resubmit it. A primary example is with mailing lists (collectively called "forwarders" below), ranging from those which make no modification to the message itself, other than to add a Received header field and change the envelope information, to those which add header fields, change the Subject header field, add content to the body (typically at the end), or reformat the body in some manner. The simple ones produces messages that are quite similar to the automated alias services. More elaborate systems essentially create a new message. A Forwarder which does not modify the body or signed header fields of a message is likely to maintain the validity of the existing signature. It also could choose to add its own signature to the message. Forwarders which modify a message in a way that could make an existing signature invalid are particularly good candidates for adding their own signatures (e.g., mailing-list-name@example.net). Since (re-)signing is taking responsibility for the content of the message, these signing forwarders are likely to be selective, and forward or re-sign only those messages which are received with a valid signature or some other basis for knowing that the messages being signed is not spoofed. A common practice among systems that are primarily re-distributors of mail is to add a Sender header field to the message, to identify the address being used to sign the message. This practice will remove any preexisting Sender header field as required by [RFC2822]. The forwarder applies a new DKIM-Signature header field with the signature, public key, and related information of the forwarder. Appendix C. Creating a public key (INFORMATIVE) The default signature is an RSA signed SHA256 digest of the complete email. For ease of explanation, the openssl command is used to describe the mechanism by which keys and signatures are managed. One way to generate a 1024 bit, unencryptedprivate-keyprivate key suitable for DKIM, is to use openssl like this: $ openssl genrsa -out rsa.private 1024 For increased security, the "-passin" parameter can also be added to encrypt the private key. Use of this parameter will require entering a password for several of the following steps. Servers may prefer to use hardware cryptographic support. The "genrsa" step results in the file rsa.private containing the key information similar to this: -----BEGIN RSA PRIVATE KEY----- MIICXwIBAAKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYtIxN2SnFC jxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/RtdC2UzJ1lWT947qR+Rcac2gb to/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB AoGBALmn+XwWk7akvkUlqb+dOxyLB9i5VBVfje89Teolwc9YJT36BGN/l4e0l6QX /1//6DWUTB3KI6wFcm7TWJcxbS0tcKZX7FsJvUz1SbQnkS54DJck1EZO/BLa5ckJ gAYIaqlA9C0ZwM6i58lLlPadX/rtHb7pWzeNcZHjKrjM461ZAkEA+itss2nRlmyO n1/5yDyCluST4dQfO8kAB3toSEVc7DeFeDhnC1mZdjASZNvdHS4gbLIA1hUGEF9m 3hKsGUMMPwJBAPW5v/U+AWTADFCS22t72NUurgzeAbzb1HWMqO4y4+9Hpjk5wvL/ eVYizyuce3/fGke7aRYw/ADKygMJdW8H/OcCQQDz5OQb4j2QDpPZc0Nc4QlbvMsj 7p7otWRO5xRa6SzXqqV3+F0VpqvDmshEBkoCydaYwc2o6WQ5EBmExeV8124XAkEA qZzGsIxVP+sEVRWZmW6KNFSdVUpk3qzK0Tz/WjQMe5z0UunY9Ax9/4PVhp/j61bf eAYXunajbBSOLlx4D+TunwJBANkPI5S9iylsbLs6NkaMHV6k5ioHBBmgCak95JGX GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc= -----END RSA PRIVATE KEY----- To extract the public-key component from theprivate-key,private key, use openssl like this: $ openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM This results in the file rsa.public containing the key information similar to this: -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkM oGeLnQg1fWn7/zYtIxN2SnFCjxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/R tdC2UzJ1lWT947qR+Rcac2gbto/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToI MmPSPDdQPNUYckcQ2QIDAQAB -----END PUBLIC KEY----- This public-key data (without the BEGIN and END tags) is placed in the DNS. With the signature, canonical email contents, and public key, a verifying system can test the validity of the signature. The openssl invocation to verify a signature looks like this: openssl dgst -verify rsa.public -sha256 -signature signature.file \ <input.file Once aprivate-keyprivate key has been generated, the openssl command can be used to sign an appropriately prepared email, like this: $ openssl dgst -sign rsa.private -sha256 <input.file This results in signature data similar to this when representedin Base64 [MIME] format:as a base64string: aoiDeX42BB/gP4ScqTdIQJcpAObYr+54yvctqc4rSEFYby9+omKD3pJ/TVxATeTz msybuW3WZiamb+mvn7f3rhmnozHJ0yORQbnn4qJQhPbbPbWEQKW09AMJbyz/0lsl How this signature is added to the email is discussed elsewhere in this document. The final record entered into a DNS zone file would be: brisbane IN TXT ("v=DKIM1; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ" "KBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYt" "IxN2SnFCjxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v" "/RtdC2UzJ1lWT947qR+Rcac2gbto/NMqJ0fzfVjH4OuKhi" "tdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB") Appendix D. MUA Considerations When a DKIM signature is verified, the processing system sometimes makes the result available to the recipient user's MUA. How to present this information to the user in a way that helps them is a matter of continuing human factors usability research. The tendency is to have theMUA highlightMUA highlight the address associated with this signing identity in some way, in an attempt to show the user the address from which the mail was sent. An MUA might do this with visual cues such as graphics, or it might include the address in an alternate view, or it might even rewrite the original "From:" address using the verified information. Some MUAs might indicate which header fields were protected by the validated DKIM signature. This could be done with a positive indication on the signed header fields, or with a negative indication on the unsigned header fields or by visually hiding the unsigned header fields, or some combination of these. If an MUA uses visual indications for signed header fields, the MUA probably needs to be careful not to display unsigned header fields in a way that might be construed by the end user as having been signed. If the message has an l= tag whose value does not extend to the end of the message, the MUA might also hide or mark the portion of the message body that was not signed. The aforementioned information is not intended to be exhaustive. The MUA may choose to highlight, accentuate, hide, or otherwise display any other information that may, in the opinion of theaddress associated with this signing identity in some way, in an attemptMUA author, be deemed important toshowtheuserend user. Appendix E. Acknowledgements The authors wish to thank Russ Allbery, Edwin Aoki, Claus Assmann, Steve Atkins, Rob Austein, Fred Baker, Mark Baugher, Steve Bellovin, Nathaniel Borenstein, Dave Crocker, Michael Cudahy, Dennis Dayman, Jutta Degener, Frank Ellermann, Patrik Faltstrom, Mark Fanto, Stephen Farrell, Duncan Findlay, Elliot Gillum, Olafur Gu[eth]mundsson, Phillip Hallam-Baker, Tony Hansen, Sam Hartman, Arvel Hathcock, Amir Herzberg, Paul Hoffman, Russ Housley, Craig Hughes, Cullen Jennings, Don Johnsen, Harry Katz, Murray S. Kucherawy, Barry Leiba, John Levine, Charles Lindsey, Simon Longsdale, David Margrave, Justin Mason, David Mayne, Steve Murphy, Russell Nelson, Dave Oran, Doug Otis, Shamim Pirzada, Juan Altmayer Pizzorno, Sanjay Pol, Blake Ramsdell, Christian Renaud, Scott Renfro, Neil Rerup, Eric Rescorla, Dave Rossetti, Hector Santos, Jim Schaad, theaddressSpamhaus.org team, Malte S. Stretz, Robert Sanders, Rand Wacker, Sam Weiler, and Dan Wing for their valuable suggestions and constructive criticism. The DomainKeys specification was a primary source from whichthe mail was sent. An MUA might dothiswith visual cues such as graphics, or it might include the address in an alternate view, or it might even rewrite the original "From:" address using the verified information. Some MUAs might indicate which header fields were protected by the validated DKIM signature. This couldspecification has been derived. Further information about DomainKeys is at [RFC-DK]. Appendix F. Edit History [[This section to bedoneremoved before publication.]] F.1 Changes since -ietf-07 version The following changes were made between draft-ietf-dkim-base-07 and draft-ietf-dkim-base-08: o Drop reference to "trusted third party" in section 1; it was redundant witha positive indication onexisting bullet points and created confusion. o Drop thesigned header fields,wording on re-using keys from normative to an operational note. o Add a sentence to 3.4.3 to clarify how empty or missing bodies are canonicalized. o Section 3.5, t= tag: note that a verifier MAY ignore signatures with anegative indication ontimestamp in theunsigned header fields or by visually hidingfuture. o Section 3.5, z= tag: dropped theunsigned header fields, or some combinationMUST NOT wording. o Clarify the description ofthese. If an MUA uses visual indicationsg= in section 3.6.1. o Mention that n= is not intended forsigned header fields, the MUA probably needsend-user use in section 3.6.1. o Modify wording of s= in section 3.6.1 so as tobe carefulnot imply possible future uses. o Add a reference todisplay unsigned header fieldsRFC 2821 ina way that might be construed by the end user as having been signed. If the message has an l= tag whose value does not extendsection 3.7 tothe end of the message, the MUA might also hide or mark the portiondescribe dot- stuffing. o Fairly extensive update ofthe message body that was not signed. The aforementioned informationsection 4 as requested during IESG review. o DKIM-Signature is notintendeda "trace header field" as defined by RFC 2822 (section 5.4). o Add sentence in section 5.4 tobe exhaustive. The MUA may choosediscourage signing of existing DKIM-Signature header fields. o Added section 5.4.1 describing recommended headers for signing per IESG review. o Dropped comment about presenting binary result tohighlight, accentuate, hide, or otherwise display any other informationend user in section 6.3 (out of scope, and by IESG request). o Clarify that SMTP-level rejects are discouraged, but thatmay, in the opinion ofif they are used they should use theMUA author, be deemed importantindicated reply codes (section 6.3). o Add text tothe end user. Appendix E. Acknowledgements The authors wishsection 7 (IANA Considerations) tothank Russ Allbery, Edwin Aoki, Claus Assmann, Steve Atkins, Rob Austein, Fred Baker, Mark Baugher, Steve Bellovin, Nathaniel Borenstein, Dave Crocker, Michael Cudahy, Dennis Dayman, Jutta Degener, Patrik Faltstrom, Mark Fanto, Stephen Farrell, Duncan Findlay, Elliot Gillum, Phillip Hallam-Baker, Tony Hansen, Sam Hartman, Arvel Hathcock, Amir Herzberg, Paul Hoffman, Russ Housley, Craig Hughes, Don Johnsen, Harry Katz, Murray S. Kucherawy, Barry Leiba, John Levine, Simon Longsdale, David Margrave, Justin Mason, David Mayne, Steve Murphy, Russell Nelson, Dave Oran, Doug Otis, Shamim Pirzada, Juan Altmayer Pizzorno, Sanjay Pol, Blake Ramsdell, Christian Renaud, Scott Renfro, Neil Rerup, Eric Rescorla, Dave Rossetti, Hector Santos, Jim Schaad, the Spamhaus.org team, Malte S. Stretz, Robert Sanders, Rand Wacker, Sam Weiler, and Dan Wing for their valuable suggestions and constructive criticism. The DomainKeys specification wasmake it clear that registry updates require aprimary source from which this specification has been derived. Further information about DomainKeys is at [RFC-DK]. Appendix F. Edit History [[Thisstandards-track document. o Rewrote section 8.4 per request by Security Area review. o Add sentence in section 8.11 tobe removed before publication.]] F.1emphasize that signing existing DKIM-Signature header fields may result in incorrect validation failures, as requested by Security Area review. o Added section 8.14 (RSA Attacks) based on DNS-dir review from Olafur Gu[eth]mundsson. o Added section 8.15 (Inappropriate Signing by Parent Domains). F.2 Changes since -ietf-06 version The following changes were made between draft-ietf-dkim-base-06 and draft-ietf-dkim-base-07: o Added section 8.11 regarding header reordering. o Added informative note to section 3.3 regarding use of sha256. o Added informative rationale to section 3.6.1, "p=", regarding key revocation. o Added second informative note in section 4 regarding signing multiple DKIM-Signature header fields. o Minor modification of the second informative note in section 6.1 regarding DoS attacks. o Added explicit mention of v= to section 6.1.2, step 5. o Updated paragraph 3 of section 8.4 regarding DNS attacks. o Added section 7.9 (DKIM-Signature IANA Registry) per IANA request.F.2F.3 Changes since -ietf-05 version The following changes were made between draft-ietf-dkim-base-05 and draft-ietf-dkim-base-06: o Fix an error in an example in Appendix C. o Substantial updates to Appendixes B and D. o Clarify ABNF for tag-value. o Changed SWSP (streaming white space) to LWSP (linear white space from RFC 4234); LWSP makes it clear that white space is required after a CRLF. o Add normative reference to SHA1/SHA256 FIPS publication 180-2. o Several minor edits based on AD Review. o Move discussion of not re-using a selector (i.e., changing the public key for a single selector) from informational to normative. o Assorted wordsmithing based on external review.F.3F.4 Changes since -ietf-04 version The following changes were made between draft-ietf-dkim-base-04 and draft-ietf-dkim-base-05: o Clarified definition of "plain text" in section 3.2 (issue 1316). o Added some clarification about multiple listings of non-existent header field names in h= in section 5.4 (issue 1316). o Finished filling out IANA registries in section 7 (issue 1320). o Clarified handling of bare CR and LF in section 5.3 (issue 1326). o Listed the required tags in section 6.1.1 as an informational note (issue 1330). o Changed IDNA reference from 3492 to 3490 (issue 1331). o Changed the reference for WSP to 4234; changed the definition of SWSP to exclude bare CR and LF (issue 1332).F.4F.5 Changes since -ietf-03 version The following changes were made between draft-ietf-dkim-base-03 and draft-ietf-dkim-base-04: o Re-worded Abstract to avoid use of "prove" and "non-repudiation". o Use dot-atom-text instead of dot-atom to avoid inclusion of CFWS. o Capitalize Selector throughout. o Add discussion of plain text, mentioning informatively that implementors should plan for eventual 8-bit requirements. o Drop RSA requirement of exponent of 65537 (not required, since it is already in the key) and clarify the key format. o Drop SHOULD that DKIM-Signature should precede header fields that it signs. o Mention that wildcard DNS records MUST NOT be used for selector records. o Add section 3.8 to clarify the t=s flag. o Change the list of header fields that MUST be signed to include only From. o Require that verifier check that From is in the list of signed header fields. o Drop all reference to draft-kucherawy-sender-auth-header draft. o Substantially expand Section 7 (IANA Considerations) to include initial registries. o Add section B.7 (use case: SMTP Servers for Roaming Users). o Add several examples; update some others. o Considerable minor editorial updating to clarify language, delete redundant text, fix spelling errors, etc. Still to be resolved: o How does "simple" body canonicalization interact with BINARYMIME data? o Deal with "relaxed" body canonicalizations, especially in regard to bare CRs and NLs. o How to handle "*" in g= dot-atom-text (which allows "*" as a literal character). o The IANA Considerations need to be completed and cleaned up.F.5F.6 Changes since -ietf-02 version The following changes were made between draft-ietf-dkim-base-02 and draft-ietf-dkim-base-03: o Section 5.2: changed key expiration text to be informational; drop "seven day" wording in favor of something vaguer. o Don't indicate that the "i=" tag value should be passed to the key lookup service; this can be added as an extension if required. o Move Section 6.6 (MUA Considerations) to be Appendix D and modify it to avoid any hint of normative language. o Soften the DKIM_STAT_ language in section 6 so that it doesn't appear normative. This involved using only PERMFAIL and TEMPFAIL as status, with parenthetical explanations. o Restructured section 6 to make it clearer which steps apply on a per-signature basis versus a per-message basis. o Clarification of "signing identity" in several places. o Clarification that DKIM-Signature header fields being signed by another DKIM-Signature header field should be treated as a normal header field (i.e., their "b=" field is unchanged). o Change ABNF on a= tag to separate the public key algorithm from the hash algorithm. o Add t=s flag in key record to disallow subdomains in the i= tag relative to the d= tag of the DKIM-Signature header field. o Add a new definition for "dkim-quoted-printable", which is a simple case of quoted-printable from RFC2045. dkim-quoted- printable requires that all white space in the original text be escaped, and all unescaped white space in the encoded field should be ignored to allow arbitrary wrapping of the header fields which may contain the content. o Use dkim-quoted-printable as the encoding used in z= rather than referring to RFC2045, since they are different. o Rewrite description of g= tag in the key record. o Deleted use of Domain in ABNF, which permits address-literals; define domain-name to act in stead.F.6F.7 Changes since -ietf-01 version The following changes were made between draft-ietf-dkim-base-01 and draft-ietf-dkim-base-02: o Change wording on "x=" tag in DKIM-Signature header field regarding verifier handling of expired signatures from MUST to MAY (per 20 April Jabber session). Also, make it clear that received time is to be preferred over current time if reliably available. o Several changes to limit wording that would intrude into verifier policy. This is largely changing statements such as "... MUST reject the message" to "... MUST consider the signature invalid." o Drop normative references to ID-DKIM-RR, OpenSSL, PEM, and Stringprep. o Change "v=" tag in DKIM-Signature from "MUST NOT" to "MUST"; the version number is 0.2 for this draft, with the expectation that the first official version will be "v=1". (Per 18 May Jabber session.) o Change "q=dns" query access method to "q=dnstxt" to emphasize the use of the TXT record. The expectation is that a later extension will define "q=dnsdkk" to indicate use of a DKK record. (Per 18 May Jabber session.) o Several typos fixed, including removing a paragraph that implied that the DKIM-Signature header field should be hashed with the body (it should not).F.7F.8 Changes since -ietf-00 version The following changes were made between draft-ietf-dkim-base-00 and draft-ietf-dkim-base-01: o Added section 8.9 (Information Leakage). o Replace section 4 (Multiple Signatures) with much less vague text. o Fixed ABNF for base64string. o Added rsa-sha256 signing algorithm. o Expanded several examples. o Changed signing algorithm to use separate hash of the body of the message; this is represented as the "bh=" tag in the DKIM- Signature header field. o Changed "z=" tag so that it need not have the same header field names as the "h=" tag. o Significant wordsmithing.F.8F.9 Changes since -allman-01 version The following changes were made between draft-allman-dkim-base-01 and draft-ietf-dkim-base-00: o Remove references to Sender Signing Policy document. Such consideration is implicitly included in Section 6.3. o Added ABNF for all tags. o Updated references (still includes some references to expired drafts, notably ID-AUTH-RES. o Significant wordsmithing.F.9F.10 Changes since -allman-00 version The following changes were made between draft-allman-dkim-base-00 and draft-allman-dkim-base-01: o Changed "c=" tag to separate out header from body canonicalization. o Eliminated "nowsp" canonicalization in favor of "relaxed", which is somewhat less relaxed (but more secure) than "nowsp". o Moved the (empty) Compliance section to the Sender Signing Policy document. o Added several IANA Considerations. o Fixed a number of grammar and formatting errors. Intellectual Property Statement The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79. Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr. The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org. The IETF has been notified of intellectual property rights claimed in regard to some or all of the specification contained in this document. For more information consult the online list of claimed rights. Disclaimer of Validity This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Copyright Statement Copyright (C) The Internet Society(2006).(2007). This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights. Acknowledgment Funding for the RFC Editor function is currently provided by the Internet Society.