TOC |
|
A third party authorization label (TPA-Label) is a DNS-based extension for DKIM ADSP records that allow domains in the From header to authorize acceptable third-party signatures. This approach allows autonomous and unilateral authorizations for a range of third-party domains using scalable, individual DNS transactions. The extended scope of DKIM signing practice assertions supplants more difficult to administer transparent authorization schemes. Alternatives for facilitating third-party authorizations currently necessitate coordination between two or more domains to synchronously set up selector/key DNS records, DNS zone delegations, and/or a regular exchange of public/private keys.
Checking TPA-Label Resource Records for signing practices may infrequently occur when a
message is not compliant with restrictive ADSP policies, where an Author Domain Signature is
either missing or invalid. When a third-party signature is found, TPA-Label Resource Record
transactions offer an efficient means for Author Domains to authorize specific third-party
signing domains. Recipients are afforded a method to determine whether authorization exists
in situations where other modes of authorization are impractical. TPA-Label Resource Records
permit Author Domains a means to selectively influence message handling, for messages
otherwise lacking valid Author Domain signatures.
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] (Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.).
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.
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.”
This Internet-Draft will expire on December 29, 2010.
Copyright (c) 2010 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
1.
Introduction
2.
Language and Terminology
2.1.
Terms Imported from other DKIM Specifications:
2.2.
Terms Defined by this Specification:
2.2.1.
Third Party Signature
2.2.2.
Third Party Signer
2.2.3.
TPA-Label Listed Domain, TPA-LLD
2.2.4.
Author's Domain Acceptable Third-Party Signature
2.2.5.
Author's Domain Acceptable Third-Party Service
3.
Combinatorial ADSP "dkim=" Values.
3.1.
tpa-sig
3.2.
tpa-path
4.
TPA-Label Resource Record Authorization Considerations
5.
Evaluating the Third-party Signing Domain or Service
5.1.
Third Party Authentication
5.1.1.
Third Party Authentication - Web Email Provider with Subscriber Pingbacks
5.1.2.
Third Party Authentication - Closed Mailing List Example
5.1.3.
Third Party Authentication - Open Mailing List Example
5.1.4.
Third Party Authentication Example - Sender Header Field
5.1.5.
Services Lacking DKIM Signatures
6.
DNS Representation
7.
TPA-Label and Tag Syntax Definitions
8.
TPA-Label Generation
9.
TPA-Label TXT Resource Record Structure
9.1.
TPA-Label Resource Record Scope Syntax
9.1.1.
TPA-Label Listed Domain Authorization
9.1.2.
Header Dependent Authorizations
9.1.3.
MailFrom Parameter
9.1.4.
SMTP Host domains
10.
Authorized Signing Domain
11.
TPA-Label Resource Record Query Transactions
12.
TPA-Label Resource Record Compliance Assessment
13.
IANA Considerations
13.1.
Author Domain Signing Practices (ADSP) Parameters
13.2.
Email Authentication Method Registry
13.3.
Email Authentication Result Names Registry
13.4.
Third Party Authorizations Labels Registry
13.5.
Third Party Authorizations Scope Registry
14.
Security Considerations
14.1.
Benefits to Recipients
14.2.
Risks to Recipients
14.3.
Benefits to Author Domains
14.4.
Risks to Author Domains
14.5.
Benefits to Third Party Signers
14.6.
Risks caused by Third Party Signers
14.7.
SHA-1 Collisions
14.8.
DNS Limits
15.
Acknowledgements
16.
References
16.1.
Normative References
16.2.
Informative References
Appendix A.
DNS Example of TPA-Label Resource Record placement
Appendix B.
C code for label generation
§
Authors' Addresses
TOC |
A transparent method for DKIM authorization represents sharing a number of details between the domain owner, and one or more providers of email and DNS. Since there are many ways in which such authorizations could be accomplished, it is unlikely standardized formats will be developed to exchange necessary, and at times, sensitive information. In addition, when there is a security breach and authorization is transparent, the wrong party might be held accountable for content they may have never seen nor logged. The TPA-Label Resource Record supports a simple authorization method that keeps visible which administrative entity signed a message, and whether an Author Domain authorized the signature. The authorization record may also impose additional header requirements.
Tens of thousands of domains of various financial institutions are frequently being phished. Phishing creates a nuisance for those who aren't expecting these messages, and a threat for those who then interact with them. Whenever institutions employ DKIM and utilize various third-party services, the integrity of their Author Domain Signature might be affected. Some assert less stringent Author Domain Signing Policies on subdomains to accommodate the affect of third-party services, as suggested by [I‑D.ietf‑dkim‑mailinglists] (Kucherawy, M., “DKIM And Mailing Lists,” June 2010.) section 4.1, that recommends use of subdomains to assert less restrictive ADSP policies.
As currently structured, ADSP does not offer an alternative to using more domains, where only some are protected by a restrictive policy. It lacks a simple method to retain an authentication and authorization acceptance condition while using third party services. This limitation forces use of a strategy that increases those being deceived by phishing attempts. This is because people often do not understand the significance of URI hierarchy, and become confused or insensitive to domain changes. APWG phishing trends, [apwg‑globalphishingsurvey‑2H2009] (Anti-Phishing Working Group, “Global Phishing Survey: Trends and Domain Name Use 2H2009,” May 2009.) page 18, indicates phishing commonly uses subdomains in a URL to fool potential victims.
Deterrents that utilize some authorized originating header are ineffective. These headers often remain invisible to recipients, and contain domains being exploited for periods measured in hours, in an avoidance of a Wack-A-Mole like response. Even long term reputations remain problematic due to the intermix of messages from compromised accounts. Few recipients inspect the stack of message headers, or are able to draw useful conclusions from a profusion of unfriendly information. However, many recipients deal with abuse by sorting messages into groups based upon an assumed source found in a few headers.
Retaining authentication and authorization for the From, Sender, and List-ID headers, and ensuring third-party inclusion of a Sender or List-ID header, enhances protections afforded from source sorting to reduce susceptibility to being deceived by look-alike phishing attempts. However, when subdomains assert less stringent policies that omit authentication, these messages might be combined with those having more stringent policies when sorting is based upon parent domains. Consistently using the same domain avoids confusion that might otherwise be exploited to deceive recipients.
ADSP represents an open registry which offers domain specific guidance for DKIM acceptance criteria, when determining whether messages should be delivered, refused or discarded. However, appropriate actions become unclear whenever third-party services are involved. For example, it is not clear whether ADSP "dkim=all" assertions include third-party services that could potentially damage Author-Domain signatures. Although ADSP warns of a potential for disruption, specific handling recommendations are limited to "dkim=discardable". Administrative domains that assert all of their outbound messages are signed offer significant forensic value. However, the handling for their messages lacking an Author Domain Signature with an ADSP "dkim=all" assertion remains unclear.
This document describes how any Author Domain publishing ADSP records defined in [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.), can autonomously authorize DKIM signatures [RFC4871] (Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, J., and M. Thomas, “DomainKeys Identified Mail (DKIM) Signatures,” May 2007.) (updated by [RFC5672] (Crocker, D., “RFC 4871 DomainKeys Identified Mail (DKIM) Signatures -- Update,” August 2009.)) by specific domains. TPA-Label listed domains offer secondary signing practices for additional ADSP compliance options, whenever no Author Domain Signature is present within the message. The intended purpose of TPA-Label Resource Records is to improve acceptance rates of genuine messages, to minimize domain use, to minimize success rates for phishing, and to minimize a recipient's administrative costs.
TPA-Label Resource Records authorize third-party signing domains and services to extend DKIM compliance options for signing practices defined by [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.). TPA-Label listed domains, TPA-LLD, are to be considered equivalent to the authorizing Author Domain when assessing compliance with ADSP. The TXT resource records, associated with TPA-Label, start with the 'dkim' tag as defined by [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.) for signing practices, and may contain tags specifically defined for TPA-Label Resource Records.
TOC |
TOC |
A "Valid Signature" is any signature on a message that correctly verifies using the procedure described in Section 6.1 of [RFC4871] (Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, J., and M. Thomas, “DomainKeys Identified Mail (DKIM) Signatures,” May 2007.).
"Author Address" is defined in Section 2.3 of [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.).
"Author Domain" is defined in section 2.4 of [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.).
"Alleged Author" is defined in Section 2.5 of [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.).
"Author Domain Signature" is defined in Section 2.7 of [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.)
TOC |
TOC |
A "Third Party Signature" is a Valid Signature that does not qualify as an Author Domain Signature.
Editor's Note: While this term is defined in Section 6.3 of [RFC5863] (Hansen, T., Siegel, E., Hallam-Baker, P., and D. Crocker, “DomainKeys Identified Mail (DKIM) Development, Deployment, and Operations,” May 2010.) and in Section 2 of [RFC5016] (Thomas, M., “Requirements for a DomainKeys Identified Mail (DKIM) Signing Practices Protocol,” October 2007.), this definition is in terms of the Author Domain Signature and avoids statements about any header field dependencies.
TOC |
A "Third Party Signer" is a signer that adds a valid DKIM signature that references a domain with the 'd=' tag in the DKIM-Signature header field that is not the Author Domain.
TOC |
TPA-Label Listed Domain, TPA-LLD, is a TXT resource record that can be referenced with a TPA-Label within an Author Domain. When a "tpa" tag exists within the TXT resource record located at the TPA-Label, the referenced domain must be within a listed domain. When the "tpa" tag does not exist, the referenced domain is presumed listed. The "scope" tag may stipulate the existence of additional headers or which email elements are to confirm an administrative domain of a service before being authorized to act on behalf of the Author Domain. Following [RFC5321] (Klensin, J., “Simple Mail Transfer Protocol,” October 2008.), domain name comparisons, as well as TPA-Labels, are case insensitive.
TOC |
An "Author's Domain Acceptable Third-Party Signature" is a Valid Signature in which the domain name of the DKIM signing entity, i.e., the 'd=' tag in the DKIM-Signature header field, is the domain name referenced in the TPA-Label Resource Record published by the Author Domain with a scope of 'F', 'S', or 'L'. For 'S' and 'L' scopes, the respective Sender header or a List-ID identifier of the List-ID header must exist for either scope and contain a domain within the TPA-LLD for authorization to be valid.
TOC |
An "Author's Domain Acceptable Third-Party Service" is a service that is able to confirm the administrative domain with either forward or reverse DNS references from either the client host name (EHLO/HELO) or the return path (Mail From) as determined by the presence of the 'H' and 'M' scopes respectively. For additional 'S' or 'L' scopes, the respective Sender header or a List-ID identifier of the List-ID header must exist for either scope and contain a domain within the TPA-LLD for authorization to be valid.
TOC |
This document defines two new values listed with the ADSP "dkim" tag in addition to those defined in [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.) section 4.2.1. These values can append to those currently defined, or used separately. When used separately, the value "all" is to be assumed to prefix the new values when recognized, otherwise the value "unknown" will be assumed. It is not recommended to use any new value in conjunction with "discardable", because when not understood, a message that depends upon different handling might become lost.
TOC |
The ADSP dkim= value "tpa-sig" indicates that TPA-Labels will offer a comprehensive list of Author's Domain Acceptable Third-Party Signatures that may include header requirements. When there is no valid Author Domain Signature or Author's Domain Acceptable Third-Party Signature, the Author Domain recommends these messages be refused.
TOC |
The ADSP dkim= value "tpa-path" indicates that TPA-Labels will offer a comprehensive list of Author's Domain Acceptable Third-Party Signatures and Authorized Third-Party Services that may include header requirements.
The "tpa-path" is used to accommodate third party services lacking DKIM signatures, the confirmed path of the message determined by either the client host name (EHLO/HELO) or the return path (Mail From). The permitted path element's domain is authorized by a TPA-Label Resource Record with the scope of 'H' or 'M' respectively. Such messages are then in compliance with the Author Domain's asserted Signing Policies. The leaf of the host name (left most label) may need to be omitted when checking for TPA-Label Resource Record authorization.
When there is no valid Author Domain Signature, or Author's Domain Acceptable Third-Party Signature, or Author's Domain Acceptable Third-Party Service, the Author Domain recommends these messages be refused.
ADSP defends domains against spoofing. Any subdomain of a domain publishing an ADSP with the "dkim" tag value containing "tpa-sig" or "tpa-path" not also publishing an MX resource record, should be assumed to have published the same ADSP records there as well.
TOC |
When an Author Domain is not within the DKIM signing domain, the TPA-LLD scheme can extend ADSP signing practice compliance. The TPA-LLD scheme with an 'F', 'S', or 'L' scope permits a contained Third Party Signature to be treated as an Author Domain Signature. The 'H' and 'M' scopes permit acceptance based upon confirmation of either the client host name (EHLO/HELO) or the return path (Mail From) respectively. For 'S' and 'L' scopes, the respective Sender header or a List-ID identifier of the List-ID header must exist for either scope and contain a domain within the TPA-LLD for authorization to be valid. This allows Author Domains a means to extend restrictive policy compliance. The TPA-LLD scheme for offering valid authorization only requires DNS publications be made by the Author Domain, even when signing domains and the Author Domain differ. This approach avoids a need to exchange DKIM key related information.
Extended authorization will not ensure all possible spoofing is prevented. However, by permitting broader use of restrictive policies, this should generally reduce the level of spoofing over what might be otherwise allowed. Authorized third party messages should not receive annotations that indicate the message contains authenticated identities. The TPA-LLD scope should include the 'S' or 'L' scope where appropriate to allow recipients a means to isolate different message sources.
The TPA-LLD scheme plays the role of only providing acceptable signatures or services which might be suitable for non-critical messages, with the goal of improving delivery acceptance, such as those from specific mailing-lists. Before TPA-LLD authorization is deployed, the Author Domain should be assured by domains being authorized that appropriate measures are in place to authenticate those who are submitting messages.
The "dkim=" tag within the TPA-Label Resource Record is expected to normally contain a copy
of the value asserted by the ADSP Resource Record "dkim" tag. When the TPA-Label Resource
Record "dkim" tag value differs, and the message is compliant with the "scope" and "ad" tag
values, the TPA-Label Resource Record "dkim" tag value overrides the ADSP Resource Record
"dkim" tag value. Use of "tpa-path" should selectively override the ADSP "tpa-sig" only
where needed.
TOC |
An Author Domain deploying a TPA-Label Resource Record does so on a trust basis. Reasons for deploying TPA-Label Resource Records might be to allow deployment of more stringent ADSP records while also utilizing third-party signatures or services.
When an authorized Third Party Signer does not employ DKIM authentication with ADSP or does not include Authentication-Results headers, this could allow authorizations to be exploited.
TOC |
The Author Domain SHOULD ensure the Authorization Scope of the TPA-Label Resource Record is authenticated. There are a number of ways email can be authenticated, and different authentication mechanisms validate different parts of the email. The following are examples of how authorization might work.
TOC |
The Author Domain "example.com" wants to deploy a TPA-Label Resource Record to permit their traveling agents the use of "webmail.example.net" services. This email provider has a closed user policy and adds DKIM signatures to messages on behalf of the "webmail.example.net" domain.
The closed user policy of "webmail.example.net" permits subscribers to post messages with Author Domains that are not "webmail.example.net" in the From header fields, only when control of the Author Address has been validated by a response to an encoded "pingback" email. The "webmail.example.net" service also establishes accounts to authenticate all users sending messages through their service. Therefore, the referenced TPA-Label Resource Record can include an 'F' scope value to authorize Author Domain messages signed by this Third-Party Signer.
TOC |
The Author Domain wants to deploy a TPA-Label Resource Record for a mailing list with a closed posting policy that redistributes email in a way which breaks Author Domain Signatures, but adds a DKIM signature on behalf of the mailing list domain and includes an Authentication-Results header field for posted messages. The closed posting policy is enforced by requiring subscribers to validate their control of their Author Address by responding to encoded "pingback" email sent to this address.
Since the mailing list management always verifies control of the Author Address, and is configured to include Authentication-Results headers, and includes a List-ID header, the referenced TPA-Label Resource Record can include an 'L' scope value to permit Author Domain messages containing an authorized List-ID domain to be signed by this Third-Party Signer.
TOC |
The Author Domain wants to deploy a TPA-Label Resource Record for a mailing list with an open posting policy that redistributes email in a way that breaks Author Domain Signatures, but that adds a DKIM signature on behalf of the mailing list domain and includes an Authentication-Results header field for posted messages. The open posting policy will refuse messages lacking Author Domain Signatures for domains that have deployed an ADSP signing practice of "dkim=all" or "dkim=discardable".
Since the list management always refuses to post an Author Address lacking a Author Domain Signature when the domain has deployed an ADSP record with an "dkim=all" or "dkim=discardable", and is configured to include Authentication-Results headers, and includes a List-ID header, the referenced TPA-Label Resource Record can include an 'L' scope value to permit Author Domain messages containing an authorized List-ID domain to be signed by this Third-Party Signer.
TOC |
Author Domain "example.com" wishes to temporarily employ the service agency "temp.example.org" to handle overflow secretarial support. The agency "temp.example.org" sends email on behalf of the executive staff of "example.com" and adds the Sender header field of "secretary@temp.example.org" in the email. Since "temp.example.org" only allows its own staff to email through its server which adds "temp.example.org" DKIM signatures, a TPA-LLD can include the "temp.example.org" domain with an 'S' scope to specifically authorize messages containing the Sender header field to help ensure these messages are not handled as phishing attempts.
TOC |
TOC |
There is likely little interest for an otherwise uninvolved domain to receive a massive number of bogus messages being returned as feedback. Often the purpose of feedback is to discover compromised systems or accounts actively being exploited in some manner. Unless there is evidence that the Author Domain either handled or authorized the handling of the message, only statistics and samples should be reported to the associated Autonomous System, and perhaps to the Author Domain when an interest is expressed.
The 'H' and 'M' scopes available within the TPA-LLD records allow the Author Domain to be associated with SMTP Clients publicly transmitting messages, and/or the Mail return path when these domains differ, and when DKIM is not employed by the third-party service. In this case, appropriate DSN or abuse reporting to the Author Domain is better assured as a result. The correspondence between SMTP Client hosts and Mail return path can be affirmed by the TPA-LLD scheme with a scope of 'H' or 'M' that might be used to categorize feedback data or confirm DSN destinations.
Services that depend only upon path authorizations, will permit other domains to spoof the Author Domain, and yet obtain acceptance. During such events, the Author Domain might need to retract their authorization from the service. For this reason, "tpa-path" authorization should only be used as a carefully monitored interim solution.
TOC |
Author Domain "example.com" makes use of invite services. This service does not utilize DKIM, where the host name given by the EHLO command is "invite.example.net". The Author Domain can authorize the domain "invite.example.net" or "example.net" with the scope of 'H' to improve acceptance of messages that are sent on behalf of "example.com" from this outbound server.
TOC |
Author Domain "example.com" makes use of tell-a-friend services. This service does not utilize DKIM with their own return path as "customer@taf.example.net" in the SMTP exchange. The Author Domain can authorize the domain "taf.example.net" with the scope of 'M' to improve acceptance of messages that are on behalf of "example.com" from this outbound server.
TOC |
Those using the "tpa-path" value should not authorize domains requiring more than a
few DNS transactions to confirm a domain. Those implementing this ADSP extension
should also limit the number of DNS transactions that might be attempted, or this
could negatively impact unrelated domains when evaluating path related
protocols.
Editor's Note: This option was added for better coverage during initial deployment of DKIM and ADSP. Earlier efforts to employ SRV records to resolve the SMTP client failed adoption.
Current experimental path protocols combine into a single set of all IPv4 and IPv6 addresses for all outbound servers handling a domain's messages. To aggregate this potentially large set of resources, path protocols provide up to one hundred and eleven separate DNS transactions. One to obtain the initial record, one for each of the ten permitted mechanisms, which may in turn require up to ten transactions to resolve the mechanism's target list.
Path protocol libraries expand macros containing email address local-parts as locations for subsequent resource records. This allows a cached path related resource record to produce a new set of DNS transactions whenever the local-part of a spam campaign changes.
TOC |
The receiver obtains domain authorizations with a DNS query for an IN class TXT TPA-Label resource record located below the location specified in [RFC4871] (Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, J., and M. Thomas, “DomainKeys Identified Mail (DKIM) Signatures,” May 2007.) section 7.4 and the label "_tpa.". The TPA-Label itself is generated by processing the domain in question, which normally matches the DKIM signature's "d=" parameter. A TPA-Label Resource Record is published adjacent to the [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.) conventional ADSP record, for example below "_tpa._domainkey.<Author-Domain>". The Author Domain provides authorization for other domains with the existence of a TPA-Label TXT resource record. When a "tpa" tag value exists, it must include the referenced domain for authorization to be valid. Authorization to act on behalf of the Author Domain can also be limited by the "scope" tag value for specific message elements.
An Author Domain may wish to delegate the listing of third-party services to a different administrative domain. Ideally, this would be accomplished by delegating the _tpa._domainkey.<Author-Domain> zone to the administrative entity handling publication of TPA-Label Resource Records. This delegation could also be done unilaterally with a DNAME resource record published at _tpa._domainkey.<Author-Domain>.
Character-strings contained within the TXT resource record are concatenated into forming a
single string. A character-string is a single length octet followed by that number of
characters treated as binary information.
The TPA-Label Resource Records should be located at these domains:
<tpa-label>._tpa._domainkey.<Author-Domain>.
TOC |
"base32" function is defined in [RFC4648] (Josefsson, S., “The Base16, Base32, and Base64 Data Encodings,” October 2006.).
"sha1" function is defined in [FIPS.180‑2.2002] (National Institute of Standards and Technology, “Secure Hash Standard,” August 2002.).
"lcase" converts upper-case ALPHA characters to lower-case.
"signing-domain" is the "d=" tag value defined in Section 3.5 of [RFC4871] (Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, J., and M. Thomas, “DomainKeys Identified Mail (DKIM) Signatures,” May 2007.).
Augmented BNF for Syntax Specifications:
asterisk = %x2A ; "*" dash = %x2D ; "-" dot = %x2E ; "." underscore = %x5F ; "_" ANY = asterisk dot ; "*." dns-char = ALPHA / DIGIT / dash id-prefix = ALPHA / DIGIT label = id-prefix [*61dns-char id-prefix] sldn = label dot label base-char = (dns-char / underscore) domain = *(label dot) sldn tpa-label = underscore base32( sha1( lcase(signing-domain)))
TOC |
The TPA-Label is created from the hash value returned by the "sha1" function of the
signing-domain expressed in lower case ASCII. The hash is then converted to a base32
character set, with the resulting label prefixed with an underscore. Any terminating period
is not included with the signing-domain, as indicated by the ABNF definition.
Note: No newline character, 0x0A, is to be appended to the end of the domain name, as might occur with the command line generation of sha1 values. For example, these command line appended newlines are avoided by using the 'echo -n" option.
TOC |
Every TPA-Label TXT resource record MUST start with an outbound signing-practices tag, so the first four characters of the record are lowercase "dkim", followed by optional whitespace and "=". In addition to the tags defined by [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.), TPA-Label syntax descriptions for additional tags follow the tag-value syntax described in section 4.2.1 of [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.) and section 3.2 of [RFC4871] (Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, J., and M. Thomas, “DomainKeys Identified Mail (DKIM) Signatures,” May 2007.). Unrecognized tags and tags with illegal values MUST be ignored. In the ABNF below, the WSP token is inherited from [RFC5322] (Resnick, P., Ed., “Internet Message Format,” October 2008.). The ALPHA and DIGIT tokens are imported from [RFC5234] (Crocker, D. and P. Overell, “Augmented BNF for Syntax Specifications: ABNF,” January 2008.).
The tags used in TPA-Label resource records are as follows:
Tag | Function |
---|---|
scope= | Authorization Scope List (as-list) |
tpa= | Authorized Domains List (ad-list) |
TPA-Label Extended Tags |
Scope Values | Field or Parameter |
---|---|
F | From (Author) Header |
L | List-ID |
S | Sender Header |
M | MailFrom |
H | SMTP Host |
TPA-Label Scope Values |
TOC |
scope= Authorization Scope List (Optional). This tag defines a list of scoping assertions for various email-address locations within the message. Only recognized scope values offer any form of ADSP authorization.
scope = "F" / "L" / "S" / "M" / "H"
as-list = "scope" [WSP] "=" [WSP] scope 0*([WSP] ":" [WSP] scope)
TOC |
TOC |
The "F" scope asserts that messages carrying the Author Domain within the From header
field are authorized to be signed by the TPA-LLD.
TOC |
TOC |
The "L" scope asserts that authorization is valid only when a List-ID identifier of
the List-ID header field [RFC2919] (Chandhok, R. and G. Wenger, “List-Id: A Structured Field and Namespace for the Identification of Mailing Lists,” March 2001.) is within the TPA-LLD.
TOC |
The "S" scope asserts that authorization is valid only when the domain in the Sender
header is within the TPA-LLD.
TOC |
When combined, the scopes 'L' and 'S' require that either a List-ID identifier of the List-ID header field or the Sender header must contain a domain within the TPA-LLD for the authorization to be valid.
TOC |
The "M" scope asserts that an email-address domain, that is within a TPA-LLD used in
the [RFC5321] (Klensin, J., “Simple Mail Transfer Protocol,” October 2008.) MAIL command is authorized.
TOC |
The "H" scope asserts that host names given in [RFC5321] (Klensin, J., “Simple Mail Transfer Protocol,” October 2008.) EHLO or HELO
commands within TPA-LLD is authorized.
TOC |
tpa= Authorized Signing Domain list. (optional) This tag, when present, MUST repeat all or portions of the domain encoded within the TPA-Label Resource Record. This option ensures the proper handling of possible hash collisions. When a domain is prefixed with the "*." ANY label, then all subdomains of this domain are to be considered included within the list. When the 'tpa' tag is not present or has no value, it should be assumed to compare with the domain used to generate the TPA-Label.
ad = [ANY] domain
ad-list = "tpa" [WSP] "=" [WSP] ad 0*([WSP] ":" [WSP] ad)
TOC |
The discovery of TPA-Label resource records need not be subsequent to the discovery of the ADSP record specified by [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.). However, when no ADSP record is discovered or when it does not contain a "dkim" tag value of either "tpa-sig" or "tpa-path", the verifier MAY assume that no TPA-Label Resource Records have been published. Otherwise, when there is a Third Party Signature without any Author Domain Signature, the discovery of TPA-Label Resource Records should be attempted.
TOC |
The signing practice compliance assessment of Third Party Signatures is a discretionary operation performed by the verifier. Messages that have valid Author Domain Signatures are already considered to result in a pass. When a verifier decides to assess compliance for Third Party Signatures with an Author Domain ADSP "dkim" tag value "tpa-sig" or "tpa-path", then, checked in succession, one of the following sets of conditions MUST be met for the result to be considered a pass.
For Third Party Signatures, the following represents the set of "tpa-sig" assessment conditions to be checked:
Meeting all the conditions in this set results in a "tpa-sig" pass, where subsequent checks
are then skipped.
For Third Party Services where the Author Domain ADSP "dkim" tag value contains "tpa-path", and where the preceding assessment conditions were not met, then the following represents "tpa-path" assessment conditions to be checked:
One of three possible TXT Resource Records are checked in succession. These are referenced
by an 'H' related TPA-Label created either from the domain given by [RFC5321] (Klensin, J., “Simple Mail Transfer Protocol,” October 2008.)
EHLO or HELO command, this domain with left-most label omitted, or by an 'M' related
email-address domain within the [RFC5321] (Klensin, J., “Simple Mail Transfer Protocol,” October 2008.) MAIL command.
The TXT record discovery process continues until a TPA-Label TXT Resource Record Structure is found where:
Meeting all four conditions in this set, and confirming the domain, results in a "tpa-path"
pass.
When the TPA-Label TXT Resource Record can not be retrieved due to some error that is likely transient in nature, as specified in [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.) Section 4.3. such as "SERVFAIL" for example, the result of the TPA-Label Resource Record compliance assessment is "temperror".
When the TPA-Label TXT Resource Record retrieval returns a DNS "NOERROR", but not with a single record, the result of the TPA-Label Resource Record compliance assessment is "permerror".
When the TPA-Label TXT Resource Record can not be retrieved with a DNS "NXDOMAIN",the
result of the TPA-Label Resource Record compliance assessment is "nxdomain".
The following pass conditions are combined to provide a single pass value.
TOC |
TOC |
To accommodate the extensions to ADSP Signing Practices, the IANA Registry "ADSP Outbound Signing Practices" defined by Section 4.2.1 of [RFC5617] (Allman, E., Fenton, J., Delany, M., and J. Levine, “DomainKeys Identified Mail (DKIM) Author Domain Signing Practices (ADSP),” August 2009.) needs the following elements to be added:
Note to RFC EDITOR: This is currently located at:
http://www.iana.org/assignments/adsp-parameters/adsp-parameters.xhtml
Type | Reference |
---|---|
tpa-sig | [THIS DOCUMENT] |
tpa-path | [THIS DOCUMENT] |
TPA-Label Resource Record validation Method |
TOC |
To accommodate the method derived from TPA-Label Resource Record processing, the IANA Registry "Email Authentication Method" defined by Section 6.2 of [RFC5451] (Kucherawy, M., “Message Header Field for Indicating Message Authentication Status,” April 2009.) needs the following elements to be added:
Note to RFC EDITOR: This is currently located at:
http://www.iana.org/assignments/email-auth/email-auth.xhtml#email-auth-methods
Method | Defined | ptype | property | value |
---|---|---|---|---|
tpa-lld | [THIS DOCUMENT] | header | d | value of signature "d" tag. The dkim method results from [RFC5451] (Kucherawy, M., “Message Header Field for Indicating Message Authentication Status,” April 2009.) should also be included in a Authenticated Results header field |
scope | value of scope (Third Party Authorizations Scope Registry) tag. (When 'scope' contains 'H', the iprev (Kucherawy, M., “Message Header Field for Indicating Message Authentication Status,” April 2009.) [RFC5451] (Section 3) method results should also be included in the Authenticated-Results header field) | |||
ca-scope | The scopes (Third Party Authorizations Scope Registry) with a compliance assessment as pass | |||
tpa | Value of tpa (Authorized Signing Domain) tag at time of compliance assessment |
TPA-Label Resource Record validation Method |
TOC |
To accommodate the results derived from TPA-Label Resource Record processing, the IANA Registry "Email Authentication Method" defined by Section 6.3 of [RFC5451] (Kucherawy, M., “Message Header Field for Indicating Message Authentication Status,” April 2009.) needs the following elements added:
Note to RFC EDITOR: This is currently located at: http://www.iana.org/assignments/email-auth/email-auth.xhtml#email-auth-result-names
code | method | meaning |
---|---|---|
none | tpa-lld | No TPA-Label was published |
pass | tpa-lld | section Section 12 (TPA-Label Resource Record Compliance Assessment) |
tempfail | tpa-lld | section Section 12 (TPA-Label Resource Record Compliance Assessment) |
permfail | tpa-lld | section Section 12 (TPA-Label Resource Record Compliance Assessment) |
unknown | tpa-lld | The TPA-Label Resource Record had a tag/value of "dkim=unknown" and the Third Party Signature failed its compliance assessment. |
discard | tpa-lld | The TPA-Label Resource Record had a tag/value of dkim=discard and the Third Party Signature failed its compliance assessment. |
fail | tpa-lld | The TPA-Label Resource Record had a tag/value of dkim=all and the Third Party Signature failed to its compliance assessment. |
nxdomain | tpa-lld | When obtaining the TPA-Label Resource Record, DNS indicated this domain does not exist. |
Other value defined in the IANA ADSP Outbound Signing Practices Registry | tpa-lld | The TPA-Label Resource Record had a tag/value of dkim={other value} and the Third Party Signature failed its compliance assessment. |
TPA-Label Resource Record complaince assessment Results |
TOC |
Names of tags that are valid in TPA-Label Resource Records with the exception of experimental tags Section 9 (TPA-Label TXT Resource Record Structure) MUST be registered in this created IANA registry.
New entries are assigned only for values that have been documented in a published RFC that has had IETF Review, per IANA CONSIDERATIONS (Narten, T. and H. Alvestrand, “Guidelines for Writing an IANA Considerations Section in RFCs,” May 2008.) [RFC5226].
Each tag registered must correspond to a definition.
The initial set of values for this registry is:
tag | defined | definition |
---|---|---|
dkim | Section 9 (TPA-Label TXT Resource Record Structure) | As per IANA Registry ADSP Outbound Signing Practices |
scope | Section 9.1 (TPA-Label Resource Record Scope Syntax) | Section 13.5 (Third Party Authorizations Scope Registry) |
tpa-sig | Section 10 (Authorized Signing Domain) | List of authorized domains |
tpa-path | Section 10 (Authorized Signing Domain) | List of authorized domains |
TPA-Label Resource Record compliance assessment Results |
TOC |
Values that correspond to Section 9.1 (TPA-Label Resource Record Scope Syntax) MUST be registered in this created registry:
New entries are assigned only for values that have been documented in a published RFC that has had IETF Review, per IANA CONSIDERATIONS (Narten, T. and H. Alvestrand, “Guidelines for Writing an IANA Considerations Section in RFCs,” May 2008.) [RFC5226].
Each value registered must correspond to a definition.
The initial set of values for this registry is:
TPA-Label Resource Record compliance assessment Results |
TOC |
This draft extends signing practices for [RFC4871] (Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, J., and M. Thomas, “DomainKeys Identified Mail (DKIM) Signatures,” May 2007.) where most generic DKIM Signature related security matters are discussed. Additional considerations are also included in [I‑D.ietf‑dkim‑mailinglists] (Kucherawy, M., “DKIM And Mailing Lists,” June 2010.). Security considerations for the TPA-LLD scheme are mostly related to attempts on the part of malicious senders to falsely represent themselves as other senders, often in an attempt to defraud either the recipient or the alleged originator.
Additional security considerations regarding DKIM signing practices may be found in the DKIM threat analysis [RFC4686] (Fenton, J., “Analysis of Threats Motivating DomainKeys Identified Mail (DKIM),” September 2006.).
TOC |
The verifier, after finding either an Author's Domain Acceptable Third-Party Signature or Author's Domain Acceptable Third-Party Service in a message, will have significantly greater confidence in the Third-Party, than when no TPA-Label Resource Record is obtained. This enhanced confidence may, at the recipients' discretion, cause a message to be delivered to the recipient without further source related assessment.
TOC |
The decisions a recipient makes in regard to message filtering based on TPA-Label Resource Records are likely to depend on the system integrity of the Third Party with respect to the Authentication (see Section 5.1 (Third Party Authentication)) and the provided scope labels. When the 'H' or 'M' scoped element is not authenticated by the Third Party or a domain is not confirmed, there is a risk of accepting potentially spoofed messages. When there is no out-of-band authentication confirming the sender, Authentication-Results headers then play an important role. Without proper Authentication-Results handling by the third-party, there is also risk of accepting potentially spoofed messages.
With this specification, third party signatures have verifiable value. When implementing the compliance assessment of third party signatures and TPA-Label Resource Records, implementers need to consider the possibility that a Bad Actor will send the recipient a message with a large number of valid DKIM Signatures. Verifying all of these may consume a large amount of processing resources such that it may be worth checking the existence of a TPA-Label Resource Record first. Section 11 (TPA-Label Resource Record Query Transactions) describes a quick check to see if TPA-Label Resource Records may exist. Additionally validating DKIM signatures and obtaining related resource records might be limited to known trustworthy domains.
TOC |
TPA-Label resource records can replace domain delegations, selector/key record mirroring, or key exchanges. A significant number of details are associated with selector/key records. These details include user limitations, suitable services, key resource record's Time-To-Live, revocation and update procedures, and how the DKIM Signature header field's 'i=' semantics are to be applied. In addition, services that depend upon DKIM keys are better secured by not delegating these DKIM keys, where instead the TPA-LLD scheme allows Author Domains an ability to limit the scope of their authorizations, while also not being mistaken for having authenticated the entity submitting the message.
TPA-Label Resource Records convey which domains are authoritative even when they are not the Author Domain. However, authorized domains are unable to utilize the DKIM signature's 'i=' semantics to directly assert which identifiers on whose behalf a signature was added. As such, no domain should be authorized unless it is trusted to ensure the Alleged Author of an email undergoes authentication that offers acceptable protections for the Author Domain. For example, such authentication might ensure submitting entities have demonstrated receipt of "pingback" messages sent to the Author Address contained within the messages being signed.
By deploying TPA-Label Resource Records, Author Domains benefit when recipients assess signing practice compliance by using the TPA-LLD scheme. These recipients will be less likely to drop the Author Domain's genuine messages, whenever the Author Domain attempts to restrict acceptance. Restricting acceptance of non-compliant messages is the basic motivation for publishing ADSP records. In addition, recipients are more likely to validate Authorized Third Party Domain Signatures.
Broader use of restrictive ADSP policies provides a better likelihood of being able to eliminate a greater range of non-compliant messages, in addition to improving acceptance from authorized sources. With authorization, scope labels allow the Author Domain to control message attributes even from the authorized third parties.
Signing domains having good reputations referenced by a TPA-LLD might therefore provide a means to safely extend limited compliance assessment resources to otherwise unknown domains or SMTP Clients.
TOC |
As indicated in Section 5 (Evaluating the Third-party Signing Domain or Service), there is ultimately a trust of the third party domain to do the right thing and not generate, or allow others to generate, messages that falsely appear to be from the Author Domain. The authentication methods in place for different email elements need to be carefully reflected in the scope of the TPA records.
By authorizing mailing lists with TPA-Label Resource Records, this could cause a loss of confidentiality in mailing list participation by the Author Domain. This might help Bad Actors deduce which subscription related email the Author Domain may receive. Because of the hashing function in generating the TPA-label, anyone wishing to discover which domains are being authorized, has to probe each TPA-label based on the exact signing domain. In addition, service organizations or community groups are able to share comprehensive lists which means, even though the domain has been authorized, that in itself does not mean the Author Domain is exchanging messages with the authorized domain.
TOC |
Third Party Signers benefit by allowing those using their service, the autonomy to authorize their service without needing to exchange DKIM key related details. This is particularly useful for mailing lists.
TOC |
As mentioned before, Third Party Signers need to authenticate messages from Author Domains. This authentication provides a safety mechanism for the Author Domain and their recipients. The Third Party may not be aware of the authentication value or the message elements involved and make changes without understanding the impact this may have upon targeted Author Domains and their recipients. For example, the Third Party might stop DKIM signing or stop applying Authentication-Results headers. The unexpected exposure might enable wide spread abuse and prove detrimental for both the Author Domain and their recipients.
TOC |
The use of the SHA-1 hash algorithm does not represent a security concern. The hash simply ensures a deterministic domain-name size is achieved. Unexpected collisions can be detected and handled by using the extended TPA-Label Resource Record "tpa=" option. The use of TPA-Label Resource Records without the TPA-Label "tpa=" options does present an opportunity for an adversary to attempt to find a hash collision. Message spoofing outside the realm of DKIM protection is likely easier to achieve than finding hash collisions. There is minimal risk of TPA-Labels colliding. Listing 3 x 10^45 domains has less than a 0.1 percent risk of any two domain labels colliding.
TOC |
Use of the TPA-Label Resource Records, rather than simply listing the authorized domain, ensures the DNS record size is independent of the Third Party Domain. The typical domain name size has been steadily increasing. This increase has been caused by domain names that encode international character sets. Perhaps soon there will be a futher increase spurred by an expanse of TLDs having larger international labels.
The maximum domain name size allowed, per [RFC1034] (Mockapetris, P., “Domain names - concepts and facilities,” November 1987.) Section 3, is 255 bytes (or octets). Each label has a byte for its length. Every domain name has a right most label representing the root with a zero length, for another byte. A scheme that concatenates a listed domain with the publishing domain, separated by some conventional label, reduces the maximal domain name in half, where the conventional label reduces this further.
If "_tpa." were used as the conventional label with a simple listing method, the maximum domain name size this supports would be 122 bytes. The suffix for TPA-Labels is "_tpa.domainkey." which consumes 16 bytes. The TPA-Label itself consumes 34 bytes. A domain that publishes the TPA labels in their domain, would then have 205 bytes available for their Author Domain. Since an Author's Domain Acceptable Third-Party Service might not implement DKIM, the TPA-Label is still able to authorize any domain name with a valid length. As a result, the maximum allowable Author Domain is increased by 83 bytes or 68% over simple name concatenation.
Normally, DNS messages should not exceed 512 bytes as per Section 2.3.4 of [RFC1035] (Mockapetris, P., “Domain names - implementation and specification,” November 1987.). Using TPA-Label Resource Records in the DNS, as described by this
document, consumes a consistent 50 bytes, in addition to the domain name publishing the
TPA-Labels. With this being constant, a limit can be determined as a constraint to
resource record size, to ensure a response does not exceed the maximum DNS message size.
DNS servers that add additional resource records, for nameservers as an example, will
further reduce available resource record capacity. Domains publishing TPA-Labels exceeding
the DNS message limit will need to rely on recipients using TCP for DNS retrieval, or
EDNS0 [RFC2671] (Vixie, P., “Extension Mechanisms for DNS (EDNS0),” August 1999.) for extended DNS lengths.
TOC |
Frank Ellermann, Michael Deutschmann, Jeff MacDonald, and Wietse Venema.
TOC |
TOC |
TOC |
TOC |
#### # Practices for Example.com email domain using example.com, isp.com, # and example.com.isp.com as signing domains. #### #### 5322.From authorization for 3P domains #### ## "isp.com" TPA-Label Resource Record ## _HTIE4SWL3L7G4TKAFAUA7UYJSS2BTEOV._tpa._domainkey.example.com. IN TXT "dkim=all tpa-sig; tpa=isp.com; scope=F;" #### 5322.Sender/List-ID authorization for 3P domains #### ## "example.com.isp.com" TPA-Label Resource Record ## _6MEHLQLKWAL5HQREXWDN2TBXAJ6VZ44B._tpa._domainkey.example.com. IN TXT "dkim=all tpa-sig; tpa=*.isp.com; scope=L:S;"
TOC |
The following utility can be compiled as tpa-label.c using the following:
gcc -lcrypto tpa-label.c -o tpa-label
/* * TPA-Label generation utility * Copyright (C) 2010 The IETF Trust & and the persons identified as * the document authors. All rights reserved. * Redistributions of source code must retain the above copyright * notice and the following disclaimer. * * 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. * 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, THE IETF TRUST 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. */ #include <stdio.h> #include <sys/types.h> #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <openssl/sha.h> #define TPA_LABEL_VERSION 102 #define MAX_DOMAIN_NAME 256 #define MAX_FILE_NAME 1024 static char base32[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; static char sign_on[] = {"%s v%d.%02d Copyright (C) (2009) The IETF Trust & Douglas Otis\n"}; char err_cmd[] =\ "ERR: Command error with [%s]\n"; char use_txt[]=\ "Usage: tpa-label [-i domain_input_file] [-o label_output_file][-v]\n"; char help_txt[]=\ "The options are as follows:\n"\ "-i domain name input. Defaults to stdin. Removes trailing '.'\n"\ "-o TPA-Label output. Defaults to stdout.\n"\ "-v Specifies Verbose Mode.\n\n"; static void usage(void); /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void usage(void) { (void) fprintf(stderr, "\n%s%s", use_txt, help_txt); exit(1); } /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ int main (int argc, char * argv[]) { int ret_val, in_mode, out_mode, verbose, done, i, j, k; char ch; unsigned int len; unsigned long long b_5; char in_fn[MAX_FILE_NAME], out_fn[MAX_FILE_NAME]; unsigned char in_buf[MAX_DOMAIN_NAME + 2]; unsigned char sha_res[20], tpa_label[33]; FILE *in_file, *out_file; ret_val = in_mode = out_mode = verbose = done = 0; len = 0; while ((ch = getopt(argc, argv, "i:o:v")) != -1) { switch (ch) { case 'i': in_mode = 1; /* input from file */ (void) strncpy(in_fn, optarg, sizeof(in_fn)); in_fn[sizeof(in_fn) - 1] = '\0'; break; case 'o': out_mode = 1; /* out to file */ (void) strncpy(out_fn, optarg, sizeof(out_fn)); out_fn[sizeof(out_fn) - 1] = '\0'; break; case 'v': verbose = 1; break; case '?': default: (void) usage(); break; } }; if (in_mode) { if ((in_file = fopen(in_fn, "r")) == NULL) { (void) fprintf(stderr, "ERR: Error opening [%s] input file.\n", in_fn); exit(2); } } else { in_file = stdin; } if (out_mode) { if ((out_file = fopen(out_fn, "w")) == NULL) { (void) fprintf(stderr, "ERR: Error opening [%s] output file.\n", out_fn); exit(3); } } else { out_file = stdout; } if (out_mode && verbose) { (void) printf(sign_on, "tpa-label utility", TPA_LABEL_VERSION / 100, TPA_LABEL_VERSION % 100); } for (i = 0; i < MAX_DOMAIN_NAME && !done; i++) { if ((ch = fgetc(in_file)) == EOF) { ch = 0; } else if (ch == '\n' || ch == '\r') { ch = 0; } in_buf[i] = tolower(ch); if (ch == 0) { len = i; /* string length */ done = 1; } } if (!done) { (void) fprintf(stderr, "ERR: Domain name too long.\n"); exit (4); } if (len && in_buf[len - 1] == '.') /* remove any trailing "." */ { len--; in_buf[len] = 0; /* replace trailing "." with 0 */ } in_buf[len] = 0; /* terminate string */ if (len < 2) { (void) fprintf(stderr, "ERR: Domain name [%s] too short with %d length.\n", in_buf, len); exit (5); } SHA1(in_buf, len, sha_res); if (verbose) { printf("Normalized Domain = [%s] %d, SHA-1 = ", in_buf, len); for (i = 0; i < 20; i++) { printf("%02x", sha_res[i]); } printf("\nTPA-Label: 5 bit intervals left to right.\n"); } /* process sha1 results 4 times by 40 bits (0 to 160) */ for (i = 0, j = 0; i < 4 ; i++) { b_5 = (unsigned long long) sha_res[(i * 5)] << 32; b_5 |= (unsigned long long) sha_res[(i * 5) + 1] << 24; b_5 |= (unsigned long long) sha_res[(i * 5) + 2] << 16; b_5 |= (unsigned long long) sha_res[(i * 5) + 3] << 8; b_5 |= (unsigned long long) sha_res[(i * 5) + 4]; if (verbose) { printf(" {%010llX}->", b_5); } for (k = 35; k >= 0; k-= 5, j++) /* convert 40 bits (5x8) */ { tpa_label[j] = base32[(b_5 >> k) & 0x1F]; if (verbose) { printf(" %02X:%c", (unsigned int)(b_5 >> k) & 0x1F, tpa_label[j]); } } if (verbose) { printf ("\n"); } } if (verbose) { printf("\n"); } tpa_label[j] = 0; /* terminate label string */ fprintf(out_file, "_%s", tpa_label); printf("\n"); /* close */ if (out_mode) { if (fclose (out_file) != 0) { (void) fprintf(stderr, "ERR: Unable to close %s output file.\n", out_fn); ret_val = 6; } } if (in_mode) { if (fclose (in_file) != 0) { (void) fprintf(stderr, "ERR: Unable to close %s input file.\n", in_fn); ret_val = 7; } } return (ret_val); }
TOC |
Douglas Otis | |
Trend Micro | |
10101 N. De Anza Blvd | |
Cupertino, CA 95014 | |
USA | |
Phone: | +1.408.257-1500 |
Email: | doug_otis@trendmicro.com |
Daniel Black | |
Canberra ACT | |
Australia | |
Email: | daniel.subs@internode.on.net |