<?xml version="1.0" encoding="US-ASCII"?>
<?rfc toc="yes"?>
<!-- generate a table of contents -->
<?rfc symrefs="yes"?>
<!-- use anchors instead of numbers for references -->
<?rfc sortrefs="yes" ?>
<!-- alphabetize the references -->
<?rfc compact="yes" ?>
<!-- conserve vertical whitespace -->
<?rfc subcompact="no" ?>
<!-- but keep a blank line between list items -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC8174 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml">
<!ENTITY RFC8447 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8447.xml">
<!ENTITY RFC8126 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8126.xml">
<!ENTITY RFC5746 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5746.xml">
<!ENTITY I-D.ietf-tls-rfc8446bis PUBLIC "" "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-tls-rfc8446bis.xml">
<!ENTITY I-D.ietf-tls-rfc8447bis PUBLIC "" "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-tls-rfc8447bis.xml">
<!ENTITY I-D.sy-tls-resumption-group PUBLIC "" "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.sy-tls-resumption-group.xml">
<!ENTITY I-D.ietf-tls-tls13-cert-with-extern-psk PUBLIC "" "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-tls-tls13-cert-with-extern-psk.xml">
<!ENTITY I-D.ietf-tls-cross-sni-resumption PUBLIC "" "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-tls-cross-sni-resumption.xml">
<!ENTITY I-D.kampanakis-tls-scas-latest PUBLIC "" "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.kampanakis-tls-scas-latest.xml">
]>

<rfc category="std" docName="draft-ietf-tls-tlsflags-17" ipr="trust200902">
    <front>
        <title abbrev="TLS Flags">A Flags Extension for TLS 1.3</title>
        <author initials="Y." surname="Nir" fullname="Yoav Nir">
            <organization>Dell Technologies</organization>
            <address>
                <postal>
                    <street>9 Andrei Sakharov St</street>
                    <city>Haifa</city>
                    <code>3190500</code>
                    <country>Israel</country>
                </postal>
                <email>ynir.ietf@gmail.com</email>
            </address>
        </author>
        <date/>
        <area>Security</area>
        <workgroup>TLS</workgroup>
        <abstract>
            <t> A number of extensions are proposed in the TLS working group that carry no interesting
                information except the 1-bit indication that a certain optional feature is supported. Such
                extensions take 4 octets each. This document defines a flags extension that can provide such
                indications at an average marginal cost of 1 bit each. More precisely, it provides as many flag
                extensions as needed at 4  + the order of the last set bit divided by 8.</t>
        </abstract>
    </front>
    <middle>
        <section anchor="intro" title="Introduction">
            <t> Since the publication of TLS 1.3 (<xref target="I-D.ietf-tls-rfc8446bis" />) there have been several proposals
                for extensions to this protocol, where the presence of the content-free extension in both the
                ClientHello and either the ServerHello or EncryptedExtensions indicates nothing except either
                support for the optional feature or an intent to use the optional feature. Examples:<list
                style="symbols">
                <t> An extension that allows the server to tell the client that cross-SNI resumption is
                    allowed: <xref target="I-D.sy-tls-resumption-group" />.</t>
                <t> An extension that is used to negotiate support for authentication using both certificates
                    and external PSKs: <xref target="I-D.ietf-tls-tls13-cert-with-extern-psk" />.</t>
                <t> The post_handshake_auth extension from the TLS 1.3 base document indicates that the client
                    is willing to perform post-handshake authentication.</t>
            </list></t>
            <t> This document proposes a single extension called tls_flags that can enumerate such flag
                extensions and allowing both client and server to indicate support for optional features in a
                concise way.</t>
            <t> None of the current proposed extensions allow for indication of support in ServerHello (SH), 
                EncryptedExtensions (EE), Certificate (CT), or HelloRetryRequest (HRR) without first being 
                indicated in ClientHello (CH). Similarly, none of the current proposed extensions allow for an
                indication of support in the client-side Certificate (CT) message without first being indicated 
                in the server's CertificateRequest (CR) message. This restriction is enforced by the rules in 
                <xref target="rules"/>.</t> 
            <section anchor="mustshouldmay" title="Requirements and Other Notation">
                <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
                    BCP 14 <xref target="RFC2119"/> <xref target="RFC8174" /> when, and only when, they appear
                    in all capitals, as shown here.</t>
                <t> The term "flag extension" is used to denote an extension where the extension_data field is
                    always zero-length in a particular context, and the presence of the extension denotes
                    either support for some feature or the intent to use that feature.</t>
                <t> The term "flag-type feature" denotes an optional TLS 1.3 feature the support for which is
                    negotiated using a flag extension, whether that flag extension is its own extension or a
                    value in the extension defined in this document.</t>
            </section>
        </section>
        <section anchor="extension" title="The tls_flags Extension">
            <t>This document defines the following extension code point:</t>
            <figure> 
                <artwork><![CDATA[
   enum {
      ...
      tls_flags(TBD),
      (65535)
   } ExtensionType;
                ]]></artwork>
            </figure>
            <t> This document also defines the data for this extension as a variable-length bit string,
                allowing for the encoding of up to 2040 features.</t>  
            <figure> 
                <artwork><![CDATA[
   struct {
      opaque flags<1..255>;
   } FlagExtensions;
                ]]></artwork>
            </figure>
            <t> The FlagExtensions field contains 8 flags in each octet. The length of the extension is the minimal length that
                allows it to encode all of the present flags. Within each octet, the bits are packed such that
                the first bit is the least significant bit and the eighth bit is the most significant. Using zero-based indexing, the first octet holds flags 0-7, the
                second octet holds bits 8-15 and so on. For example, if we want to encode only flag
                number zero, the FlagExtension field will be 1 octet long, that is encoded as follows:</t>
                <figure><artwork><![CDATA[
   00000001
                ]]></artwork></figure>
            <t> If we want to encode flags 1 and 5, the field will still be 1 octet long:</t>
                <figure><artwork><![CDATA[
   00100010
                ]]></artwork></figure>
            <t> If we want to encode flags 3, 5, and 23, the field will have to be 3 octets long:</t>
                <figure><artwork><![CDATA[
   00101000 00000000 10000000
                ]]></artwork></figure>
            <t> An implementation that receives an all-zero value for this extension or a value that contains 
                trailing zero bytes MUST generate a fatal illegal_parameter alert.</t>
            <t> Note that this document does not define any particular bits for this string. That is left to
                the protocol documents such as the ones in the examples from the previous section. Such
                documents will have to define which bit to set to show support.</t>
        </section>
        <section anchor="rules" title="Rules for The Flags Extension">
            <t> Any TLS implementation that intends to propose or indicate support for a flag extension SHALL send this
                extension with the relevant bits set.</t>
            <t> This specification does not require every flag extension to be acknowledged. Acknowledging 
                   a flag extension is typically needed to inform the peer proposing the extension that the other 
                   side understands and supports the extension, but some extensions do not require this
                   acknowledgement.</t>
            <t> For a flag that does require a response, the only proper response is the same flag in a flags extension. This extension 
		MUST NOT be used to specify extensions where the response is a proper extension with content.</t>
            <t>A
                flag proposed by the client in ClientHello (CH) that requires acknowledgement SHOULD be acknowledged in either ServerHello (SH), in 
                EncryptedExtensions (EE), in Certificate (CT), or in HelloRetryRequest (HRR) as the corresponding flag document specifies. 
                Similarly, a flag proposed by the server in the CertificateRequest (CR) message that requires acknowledgement SHOULD be acknowledged in the client's
                Certificate (CT) message. A flag proposed by the server in the NewSessionTicket (NST) message is never 
                acknowledged as there is not client-side response message.</t>
            <t> Multiple flags can be proposed or acknowledged in the same extension.</t>
            <t> In all of the above cases, a flag MUST NOT be acknowledged in SH, EE, CT, or HRR without first having been
                proposed in CH or CR. Unsolicited flags may appear only in CH, CR, and NST.
                An endpoint that receives an unsolicited flag in another message (HRR, SH, EE, or CT)
                MUST generate a fatal illegal_parameter alert.</t>
            <t> A client that supports this extension and at least one flag extension SHALL send this extension 
                with the flags field having bits set only for those extensions that it intends to set. It MUST 
                NOT send this extension with a length of zero.</t> 
            <t> An implementation that receives an invalid tls_flags extension MUST terminate the TLS handshake with a
                fatal illegal_parameter alert.</t>
	    <section anchor="zrtt" title="Interaction with the 0-RTT Handshake">
	        <t> The 0-RTT handshake, defined in section 2.3 of <xref target="I-D.ietf-tls-rfc8446bis" />, has a ClientHello message, 
		    a ServerHello message, and an EncryptedExtensions message. Those can include the tls_flags extension
		    just as they can in a regular handshake.</t>
		<t> Future flag extensions MUST define their interaction with 0-RTT, just as other extensions are required to. </t>
	    </section>
        </section>
        <section anchor="iana" title="IANA Considerations">
            <t> IANA is requested to assign a new value from the TLS ExtensionType Values registry:
                <list style="symbols">
                    <t> The Extension Name should be tls_flags</t>
                    <t> The TLS 1.3 value should be CH,SH,HRR,EE,CR,CT,NST</t>
		    <t> The DTLS-Only value should be N</t>
                    <t> The Recommended value should be Y</t>
                    <t> The Reference should be this document</t>
                </list>
            </t>
            <t> IANA is also requested to create a new registry under the TLS namespace with name "TLS Flags"
                and the following fields:
                <list style="symbols">
                   <t> Value, which is a number between 0 and 2039. All potential values are available for
                       assignment.</t>
                   <t> Flag Name, which is a string</t>
                   <t> Message, which like the "TLS 1.3" field in the ExtensionType registry contains the
                       abbreviations of the messages that may contain the flag: CH, SH, EE, etc.</t>
                   <t> Recommended, which is a Y/N/D value; see <xref target="I-D.ietf-tls-rfc8447bis" section="3"/>.</t>
                   <t> Reference, which is a link to the document defining this flag.</t>
                </list>
            </t>
            <t> The policy for this shall be "Specification Required" as described in <xref
                target="RFC8126" section="4.6"/> with the exception of flags numbered from 0-15, which follow 
	        the "Standards Action" policy (<xref target="RFC8126" section="4.9"/>). 
                Designated expert(s) are advised to follow the advice in 
                <xref target="RFC8447" section="17"/> when reviewing registration requests.
            </t>
            <t> The initial contents of the registry shall be one entry, as follows:
                <list style="symbols">
                    <t> Value shall be 8 </t>
                    <t> Flag Name shall be resumption_across_names </t>
                    <t> Message shall be NST </t>
                    <t> Recommended shall be set to no (N) </t>
                    <t> The reference shall the the RFC-to-be <xref target="I-D.ietf-tls-cross-sni-resumption"/>.</t>
                </list>
            </t>
        </section>
        <section anchor="sec" title="Security Considerations">
            <t> The extension described in this document provides a more concise way to express data that could
                otherwise be expressed in individual extensions. It does not send in the clear any information
                that would otherwise be sent encrypted, nor vice versa. For this reason this extension is
                neutral as far as security is concerned.</t>
            <t> Extension authors should be aware that acknowledging flags in a tls_flags extension of the 
                ServerHello and HelloRetryRequest messages expose this response to passive observers. Unless there is a special 
                reason to place the response in the ServerHello, most flags should go in other (encrypted) messages.</t>
        </section>
        <section title="Acknowledgements">
            <t> The idea for writing this was expressed at the mic during the TLS session at IETF 104 by Eric
                Rescorla.</t>
            <t> The current bitwise formatting was suggested on the mailing list by Nikos
                Mavrogiannopoulos.</t>
            <t> Improvement to the encoding were suggested by Ilari Liusvaara, who also asked for a better 
                explanation of the semantics of missing extensions.</t>
            <t> Useful comments received from Martin Thomson, including the suggestion to eliminate the option
                to have the server send unsolicited flag types and the rules for where unsolicited flags can appear.</t>
        </section>
    </middle>
    <back>
        <references title="Normative References">
            &RFC2119;
            &RFC8174;
            &I-D.ietf-tls-rfc8446bis;
            &RFC8447;
            &I-D.ietf-tls-rfc8447bis;	 
        </references>
        <references title="Informative References">
            &RFC8126;
            &RFC5746;
            &I-D.sy-tls-resumption-group;
            &I-D.ietf-tls-tls13-cert-with-extern-psk;
            &I-D.ietf-tls-cross-sni-resumption;
        </references>
        <section anchor="changelog" title="Change Log">
            <t> RFC EDITOR: PLEASE REMOVE THIS SECTION AS IT IS ONLY MEANT TO AID THE WORKING GROUP IN TRACKING
                CHANGES TO THIS DOCUMENT.</t>
	    <t> draft-ietf-tls-tlsflags-15 text improvement by Bob Beck</t>
            <t> draft-ietf-tls-tlsflags-13 align with 8446bis and 8447bis</t>
            <t> draft-ietf-tls-tlsflags-02 set the maximum number of flags to 2048, and added guidance for
                the IANA experts.</t>
            <t> draft-ietf-tls-tlsflags-01 allows server-only flags and allows the client to send an empty 
                extension. Also modified the packing order of the bits.</t>
            <t> draft-ietf-tls-tlsflags-00 had the same text as draft-nir-tls-tlsflags-02, and was re-submitted
                as a working group document following the adoption call.</t>
            <t> Version -02 replaced the fixed 64-bit string with an unlimited bitstring, where only the 
                necessary octets are encoded.</t>
            <t> Version -01 replaced the enumeration of 8-bit values with a 64-bit bitstring.</t>
            <t> Version -00 was a quickly-thrown-together draft with the list of supported features encoded as
                an array of 8-bit values.</t>
        </section>
    </back>
</rfc>
