<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
     There has to be one entity for each item to be referenced. 
     An alternate method (rfc include) is described in the references. -->

<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC5246 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml">
<!ENTITY RFC3264 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3264.xml">
<!ENTITY RFC6066 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6066.xml">
<!ENTITY RFC5077 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5077.xml">
<!ENTITY I-D.narten-iana-considerations-rfc2434bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.narten-iana-considerations-rfc2434bis.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="std" docName="draft-ietf-tls-applayerprotoneg-00" ipr="trust200902">
  <!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN" 
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->

  <front>
    <!-- The abbreviated title is used in the page header - it is only necessary if the 
         full title is longer than 39 characters -->

    <title abbrev="TLS App Layer Protocol Negotiation Ext">Transport Layer Security (TLS) Application Layer Protocol Negotiation Extension</title>

    <!-- add 'role="editor"' below for the editors if appropriate -->

    <author fullname="Stephan Friedl" initials="S.F."
            surname="Friedl">
      <organization>Cisco Systems, Inc.</organization>

      <address>
        <postal>
          <street>170 West Tasman Drive</street>

          <!-- Reorder these if your country does things differently -->

          <city>San Jose</city>

          <region>CA</region>

          <code>95134</code>

          <country>USA</country>
        </postal>

        <phone>(720)562-6785</phone>

        <email>sfriedl@cisco.com</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

    <author fullname="Andrei Popov" initials="A.P."
            surname="Popov">
      <organization>Microsoft Corp.</organization>

      <address>
        <postal>
          <street>One Microsoft Way</street>

          <!-- Reorder these if your country does things differently -->

          <city>Redmond</city>

          <region>WA</region>

          <code>98052</code>

          <country>USA</country>
        </postal>

        <email>andreipo@microsoft.com</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

    <date month="April" year="2013" />

    <!-- If the month and year are both specified and are the current ones, xml2rfc will fill 
         in the current day for you. If only the current year is specified, xml2rfc will fill 
	 in the current day and month for you. If the year is not the current one, it is 
	 necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the 
	 purpose of calculating the expiry date).  With drafts it is normally sufficient to 
	 specify just the year. -->

    <!-- Meta-data Declarations -->

    <area>General</area>

    <workgroup>Network Working Group</workgroup>

    <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.  
	 If this element is not present, the default is "Network Working Group",
         which is used by the RFC Editor as a nod to the history of the IETF. -->

    <keyword>draft</keyword>

    <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->

    <abstract>
      <t>
      This document describes a Transport Layer Security (TLS) extension for application layer protocol 
      negotiation within the TLS handshake.  For instances in which the TLS connection is established over 
      a well known TCP/IP port not associated with the desired application layer protocol, this extension 
      allows the application layer to negotiate which protocol will be used within the TLS session.
      </t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>Currently, the Next Protocol Negotiation extension (NPN) is used to establish a <xref target="spdy">SPDY</xref> protocol 
      session within a TLS <xref target="RFC5246">RFC 5246</xref> session on port 443.  NPN is not 
      specific to SPDY and can be used to negotiate sessions for a wide variety of protocols within
      the TLS handshake.</t>
      
      <t>NPN seeks to provide a reliable mechanism for application developers to establish secure sessions for
      arbitrary protocols without interference from firewalls, HTTP proxies and MITM proxies.  It addresses
      this goal by introducing a protocol negotiation process into the TLS handshake under the constraints that
      no additional roundtrips be added to the handshake and that the final protocol selection be opaque to the
      network carrying the TLS session. Within the NPN extension, it is the server that first generates and 
      transmits an offer of supported protocols to the client.  The offer is sent as part of the TLS ServerHello 
      message before the [ChangeCipherSpec] subprotocol has been started, therefore the list of protocols 
      supported by the server is transmitted in plaintext.  The client chooses a protocol which may or may not 
      appear in the offer from the server and then responds with the definitive protocol selection answer.  
      The client response is sent after the [ChangeCipherSpec] subprotocol has been initiated, so the protocol
      selected is encrypted in the client response.</t>
      
      <t>In many other application layer protocol negotiation processes, it is the client that first sends an offer
      of protocols it supports to the server.  The server then selects the protocol to be used in the
      session and includes this answer in the response.  <xref target="RFC3264">RFC 3264</xref> describes a 
      SDP based offer/answer model which is not proscriptive in terms of which party generates the offer, 
      however in practice it is typically the client generating the offer and the server replying with the answer.  
      This permits the server to act as the definitive entity for selection of the application layer protocol.</t>
      
      <t>This draft proposes an alternative formulation of the NPN protocol which 1) brings the offer/answer negotiation
      into alignment with the majority of other application layer protocol negotiation standards, 2) allows certificate
      selection based on the application protocol and 3) makes the definitive protocol selection answer from the server
      visible to the network, when the parties so desire.</t>
    </section>

    <section title="Requirements Language">
      <t>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 <xref
      target="RFC2119">RFC 2119</xref>.
      </t>
    </section>

    <section title="Application Layer Protocol Negotiation">

      <section title="The Application Layer Protocol Negotiation Extension">
        <t>
        A new extension type ("application_layer_protocol_negotiation(16)") is defined and MAY be included by the client in
        its "ClientHello" message.
        </t>
      
        <figure>
        <artwork align="left"><![CDATA[
enum {
	application_layer_protocol_negotiation(16), (65535)
} ExtensionType;
        ]]></artwork>
		</figure>

        <t>The "extension_data" field of the ("application_layer_protocol_negotiation(16)") extension SHALL contain a "ProtocolNameList" value.</t>

        <figure>
        <artwork align="left"><![CDATA[
opaque ProtocolName<1..2^8-1>;

struct {
	ProtocolName protocol_name_list<2..2^16-1>
} ProtocolNameList;
        ]]></artwork>
		</figure>

	<t>"ProtocolNameList" contains the list of protocols advertised by the client, in descending order of preference. Protocols are named by IANA 
		registered, opaque, non-empty byte strings. Implementations MUST ensure that an empty string is not included and that no byte strings 
		are truncated.</t>

	<t>Experimental protocol names, which are not registered by IANA, will start with the following sequence of bytes: 0x65, 0x78, 0x70 ("exp").</t>

        <t>Servers that receive a client hello containing the "application_layer_protocol_negotiation" extension, MAY 
        	return a suitable protocol selection response to the client.  The server will ignore any protocol name that 
		it does not recognize.  A new ServerHello extension type ("application_layer_protocol_negotiation(16)") MAY be returned to the client within 
		the extended ServerHello message.  The "extension_data" field of the ("application_layer_protocol_negotiation(16)") extension SHALL be 
		structured the same as described above for the client "extension_data", except that the "ProtocolNameList" MUST contain exactly one 
		"ProtocolName".
		</t>
        
        <t>The additional content associated with this extension MUST be included in the hash calculations associated
        with the "Finished" messages.</t>
        
        <t>
        Therefore, a full handshake with the "application_layer_protocol_negotiation" extension in the ClientHello and ServerHello messages
		has the following flow (contrast with section 7.3 of <xref target="RFC5246">RFC 5246</xref>):
        </t>
        
      <figure align="center" anchor="full_handshake">

        <artwork align="left"><![CDATA[
Client                                              Server

ClientHello                     -------->       ServerHello
  (ALPN extension &                               (ALPN extension &
   list of protocols)                              selected protocol)
                                                Certificate*
                                                ServerKeyExchange*
                                                CertificateRequest*
                                <--------       ServerHelloDone
Certificate*
ClientKeyExchange
CertificateVerify*
[ChangeCipherSpec]
Finished                        -------->
                                                [ChangeCipherSpec]
                                <--------       Finished
Application Data                <------->       Application Data
            ]]></artwork>

      </figure>
      
      <t>
      An abbreviated handshake with the "application_layer_protocol_negotiation" 
	  extension has the following flow:
	  </t>
	  
      <figure align="center" anchor="abbreviated_handshake">

        <artwork align="left"><![CDATA[
Client                                              Server

ClientHello                     -------->       ServerHello
  (ALPN extension &                               (ALPN extension &
   list of protocols)                              selected protocol)
                                                [ChangeCipherSpec]
                                <--------       Finished
[ChangeCipherSpec]
Finished                        -------->
Application Data                <------->       Application Data
            ]]></artwork>

      </figure>
        
		<t>Unlike many other TLS extensions, this extension does not establish properties of the session,
		only of the connection.  When session resumption or session tickets <xref target="RFC5077">RFC 5077</xref>
		are used, the previous contents of this extension are irrelevant and only the values in the new 
		handshake messages are considered.</t>
		
      </section>

      <section title="Protocol Selection">
      
        <t>It is expected that a server will have a list of protocols that it supports, in preference order, 
        and will only select a protocol if the client supports it.  In that case, the server SHOULD select
        the most highly preferred protocol it supports which is also advertised by the client.  In the event
        that the server supports no protocols that the client advertises, then the server SHALL respond
        with a fatal "no_application_protocol" alert.</t>

        <figure>
        <artwork align="left"><![CDATA[
enum {
	no_application_protocol(120),
	(255)
} AlertDescription;
        ]]></artwork>
		</figure>

	<t>The "no_application_protocol" fatal alert is only defined for the "application_layer_protocol_negotiation" extension and MUST NOT 
	be sent unless the server has received a ClientHello message containing this extension.</t>

        <t>The protocol identified in the "application_layer_protocol_negotiation" extension type in the ServerHello SHALL be definitive for
        the connection.  The server SHALL NOT respond with a selected protocol and subsequently use a different
        protocol for application data exchange.</t>
        
      </section>

    </section>

    <section title="Design Considerations">
      <t>
      The ALPN extension is intended to follow the typical design of TLS protocol extensions.  Specifically,
		the negotiation is performed entirely within the client/server hello exchange in accordance with
		established TLS architecture.  The "application_layer_protocol_negotiation" ServerHello extension is intended to
		be definitive for the connection and is sent in plaintext to permit network elements to provide
		differentiated service for the connection when the TCP/IP port number is not definitive for the
		application layer protocol to be used in the connection.  By placing ownership of protocol selection 
		on the server, ALPN facilitates scenarios in which certificate selection or connection rerouting 
		may be based on the negotiated protocol.
      </t>

		<t>Finally, by managing protocol selection in the clear as part of the handshake, ALPN avoids introducing 
		false confidence with respect to the the ability to hide the negotiated protocol in advance of establishing the connection.
		If hiding the protocol is required, then renegotiation after connection establishment, which would provide true
		TLS security guarantees, would be a preferred methodology.
		</t>

		<t>A namespace will be assigned for experimental protocols, comprising byte strings which start with the following 
		sequence of bytes: 0x65, 0x78, 0x70 ("exp"). Assignments in this namespace do not need IANA registration.
		</t>
    </section>

    <section title="Security Considerations">
      <t>
      The ALPN extension does not impact the security of TLS session establishment or application data exchange.  ALPN
      serves to provide an externally visible marker for the application layer protocol associated with the TLS
      connection.  Historically, the application layer protocol associated with a connection could be ascertained from
      the TCP/IP port number in use.  
      </t>

      <t>
      Encrypting the selected application protocol information and sending it before the Finished messages are exchanged,
      as done in NPN, does not provide confidentiality guarantees due to the possibility of man-in-the-middle attacks.
      </t>
    </section>

    <section title="IANA Considerations">
      
      <t>
		The IANA has updated its Registry of TLS ExtensionType Values to include the following entry:
		</t>
		
		<t> - 16	application_layer_protocol_negotiation</t>
        
      <t>
		This document also requires the IANA to create a registry of Application Layer Protocol Negotiation 
		protocol byte strings, initially containing the following entries:
		</t>

      <t> - "http/1.1": HTTP/1.1 [RFC2616];</t>

      <t> - "http/2.0": HTTP/2.0;</t>

      <t> - "spdy/1": (obsolete) SPDY version 1;</t>

      <t> - "spdy/2": SPDY version 2;</t>

      <t> - "spdy/3": SPDY version 3.</t>
        
    <t>We propose that this new registry be created in a new page entitled: "Application Layer Protocol Negotiation (ALPN) Protocol IDs" beneath the
	existing heading of "Transport Layer Security (TLS)".</t>
	</section>
  
    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>
      This document benefitted specifically from the NPN extension draft authored by Adam Langley of Google and
      from discussions with Tom Wesselman and Cullen Jennings both of Cisco.
      </t>
    </section>
  </middle>


  <!--  *****BACK MATTER ***** -->

  <back>
    <!-- References split into informative and normative -->

    <!-- There are 2 ways to insert reference entries from the citation libraries:
     1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
     2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
        (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

     Both are cited textually in the same manner: by using xref elements.
     If you use the PI option, xml2rfc will, by default, try to find included files in the same
     directory as the including file. You can also define the XML_LIBRARY environment variable
     with a value containing a set of directories to search.  These can be either in the local
     filing system or remote ones accessed by http (http://domain/dir/... ).-->

    <references title="Normative References">
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->
      &RFC2119;
      
      &RFC5246;
      
      &RFC3264;
      
      &RFC6066;

    </references>

    <references title="Informative References">
      <!-- Here we use entities that we defined at the beginning. -->
      
      &RFC5077;
      
     <!-- A reference written by by an organization not a person. -->

      <reference anchor="spdy">
        <front>
          <title>SPDY Protocol (Internet Draft)</title>

          <author initials="M" surname="Belshe">
            <organization></organization>
          </author>

          <author initials="R" surname="Peon">
            <organization></organization>
          </author>

          <date year="2012" />
        </front>
      </reference>

    </references>

  </back>
</rfc>
