<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' []>
<rfc ipr="trust200902" category="exp" docName="draft-ietf-tcpinc-tcpeno-02">
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc private=""?>
<?rfc topblock="yes"?>
<?rfc comments="no"?>
<front>
<title abbrev="tcpeno">TCP-ENO: Encryption Negotiation Option</title>

<author initials="A." surname="Bittau" fullname="Andrea Bittau">
<organization>Stanford University</organization>
<address>
<postal>
<street>353 Serra Mall, Room 288</street>
<city>Stanford, CA</city>
<code>94305</code>
<country>US</country>
<region></region>
</postal>
<phone></phone>
<email>bittau@cs.stanford.edu</email>
<uri></uri>
</address>
</author>
<author initials="D." surname="Boneh" fullname="Dan Boneh">
<organization>Stanford University</organization>
<address>
<postal>
<street>353 Serra Mall, Room 475</street>
<city>Stanford, CA</city>
<code>94305</code>
<country>US</country>
<region></region>
</postal>
<phone></phone>
<email>dabo@cs.stanford.edu</email>
<uri></uri>
</address>
</author>
<author initials="D." surname="Giffin" fullname="Daniel B. Giffin">
<organization>Stanford University</organization>
<address>
<postal>
<street>353 Serra Mall, Room 288</street>
<city>Stanford, CA</city>
<code>94305</code>
<country>US</country>
<region></region>
</postal>
<phone></phone>
<email>dbg@scs.stanford.edu</email>
<uri></uri>
</address>
</author>
<author initials="M." surname="Handley" fullname="Mark Handley">
<organization>University College London</organization>
<address>
<postal>
<street>Gower St.</street>
<city>London</city>
<code>WC1E 6BT</code>
<country>UK</country>
<region></region>
</postal>
<phone></phone>
<email>M.Handley@cs.ucl.ac.uk</email>
<uri></uri>
</address>
</author>
<author initials="D." surname="Mazieres" fullname="David Mazieres">
<organization>Stanford University</organization>
<address>
<postal>
<street>353 Serra Mall, Room 290</street>
<city>Stanford, CA</city>
<code>94305</code>
<country>US</country>
<region></region>
</postal>
<phone></phone>
<email>dm@uun.org</email>
<uri></uri>
</address>
</author>
<author initials="E." surname="Smith" fullname="Eric W. Smith">
<organization>Kestrel Institute</organization>
<address>
<postal>
<street>3260 Hillview Avenue</street>
<city>Palo Alto, CA</city>
<code>94304</code>
<country>US</country>
<region></region>
</postal>
<phone></phone>
<email>eric.smith@kestrel.edu</email>
<uri></uri>
</address>
</author>
<date year="2016" month="June" day="30"/>

<area>Internet</area>
<workgroup></workgroup>
<keyword>tcp</keyword>
<keyword>encryption</keyword>


<abstract>
<t>Despite growing adoption of TLS <xref target="RFC5246"/>, a significant fraction of
TCP traffic on the Internet remains unencrypted.  The persistence of
unencrypted traffic can be attributed to at least two factors.  First,
some legacy protocols lack a signaling mechanism (such as a <spanx style="verb">STARTTLS</spanx>
command) by which to convey support for encryption, making incremental
deployment impossible.  Second, legacy applications themselves cannot
always be upgraded, requiring a way to implement encryption
transparently entirely within the transport layer.  The TCP Encryption
Negotiation Option (TCP-ENO) addresses both of these problems through
a new TCP option kind providing out-of-band, fully backward-compatible
negotiation of encryption.
</t>
</abstract>


</front>

<middle>

<section anchor="requirements-language" title="Requirements language">
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL NOT&quot;,
&quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;MAY&quot;, and &quot;OPTIONAL&quot; in this
document are to be interpreted as described in <xref target="RFC2119"/>.
</t>
</section>

<section anchor="introduction" title="Introduction">
<t>Many applications and protocols running on top of TCP today do not
encrypt traffic.  This failure to encrypt lowers the bar for certain
attacks, harming both user privacy and system security.  Counteracting
the problem demands a minimally intrusive, backward-compatible
mechanism for incrementally deploying encryption.  The TCP Encryption
Negotiation Option (TCP-ENO) specified in this document provides such
a mechanism.
</t>
<t>Introducing TCP options, extending operating system interfaces to
support TCP-level encryption, and extending applications to take
advantage of TCP-level encryption all require effort.  To the greatest
extent possible, the effort invested in realizing TCP-level encryption
today needs to remain applicable in the future should the need arise
to change encryption strategies.  To this end, it is useful to
consider two questions separately:
</t>
<t>
<list style="numbers">
<t>How to negotiate the use of encryption at the TCP layer, and</t>
<t>How to perform encryption at the TCP layer.</t>
</list>
</t>
<t>This document addresses question 1 with a new TCP option, ENO.
TCP-ENO provides a framework in which two endpoints can agree on one
among multiple possible TCP encryption <spanx style="emph">specs</spanx>.  For future
compatibility, encryption specs can vary widely in terms of wire
format, use of TCP option space, and integration with the TCP header
and segmentation.  However, ENO abstracts these differences to ensure
the introduction of new encryption specs can be transparent to
applications taking advantage of TCP-level encryption.
</t>
<t>Question 2 is addressed by one or more companion documents describing
encryption specs.  While current specs enable TCP-level traffic
encryption today, TCP-ENO ensures that the effort invested to deploy
today's specs will additionally benefit future specs.
</t>

<section anchor="design-goals" title="Design goals">
<t>TCP-ENO was designed to achieve the following goals:
</t>
<t>
<list style="numbers">
<t>Enable endpoints to negotiate the use of a separately specified
TCP encryption <spanx style="emph">spec</spanx>.</t>
<t>Transparently fall back to unencrypted TCP when not supported by
both endpoints.</t>
<t>Provide out-of-band signaling through which applications can better
take advantage of TCP-level encryption (for instance, by improving
authentication mechanisms in the presence of TCP-level encryption).</t>
<t>Provide a standard negotiation transcript through which specs can
defend against tampering with TCP-ENO.</t>
<t>Make parsimonious use of TCP option space.</t>
<t>Define roles for the two ends of a TCP connection, so as to name
each end of a connection for encryption or authentication purposes
even following a symmetric simultaneous open.</t>
</list>
</t>
</section>
</section>

<section anchor="terminology" title="Terminology">
<t>We define the following terms, which are used throughout this
document:
</t>
<t>
<list style="hanging">
<t hangText="SYN segment">
<vspace />
A TCP segment in which the SYN flag is set</t>
<t hangText="ACK segment">
<vspace />
A TCP segment in which the ACK flag is set (which includes most
segments other than an initial SYN segment)</t>
<t hangText="non-SYN segment">
<vspace />
A TCP segment in which the SYN flag is clear</t>
<t hangText="SYN-only segment">
<vspace />
A TCP segment in which the SYN flag is set but the ACK flag is
clear</t>
<t hangText="SYN-ACK segment">
<vspace />
A TCP segment in which the SYN and ACK flags are both set</t>
<t hangText="Active opener">
<vspace />
A host that sends a SYN-only segment.  With the BSD socket API,
this occurs when an application calls <spanx style="verb">connect</spanx>.  In client-server
configurations, active openers are typically clients.</t>
<t hangText="Passive opener">
<vspace />
A host that does not send a SYN-only segment (only a SYN-ACK
segment).  With the BSD socket API, this occurs following a call to
<spanx style="verb">listen</spanx>.  In client-server configurations, passive openers are
typically servers.</t>
<t hangText="Simultaneous open">
<vspace />
The act of symmetrically establishing a TCP connection between two
active openers (both of which call <spanx style="verb">connect</spanx> with BSD sockets).
Each host of a simultaneous open sends both a SYN-only and a
SYN-ACK segment.  Simultaneous open is less common than asymmetric
open, but can be used for NAT traversal by peer-to-peer
applications <xref target="RFC5382"/>.</t>
<t hangText="Encryption spec">
<vspace />
A separate document specifying an approach to encrypting TCP
traffic in conjunction with TCP-ENO.</t>
<t hangText="Spec identifier">
<vspace />
A unique 7-bit value in the range 0x20-0x7f that IANA has assigned
to an encryption spec.</t>
<t hangText="Negotiated [encryption] spec">
<vspace />
The single encryption spec governing a TCP connection, as
determined by the protocol specified in this document.</t>
</list>
</t>
</section>

<section anchor="tcpeno-specification" title="TCP-ENO specification">
<t>TCP-ENO extends TCP connection establishment to enable encryption
opportunistically.  It uses a new TCP option kind to negotiate one
among multiple possible encryption specs--separate documents
describing how to do actual traffic encryption.  The negotiation
involves hosts exchanging sets of supported specs, where each spec is
represented by a <spanx style="emph">suboption</spanx> within a larger TCP option in the
offering host's SYN segment.
</t>
<t>If TCP-ENO succeeds, it yields the following information:
</t>
<t>
<list style="symbols">
<t>A negotiated encryption spec, represented by a unique 7-bit spec
identifier,</t>
<t>A few extra bytes of suboption data from each host, if needed by the
spec,</t>
<t>A negotiation transcript that the negotiated spec must
cryptograhpically authenticate,</t>
<t>Role assignments designating one endpoint &quot;host A&quot; and the other
endpoint &quot;host B&quot;, and</t>
<t>A few bits indicating whether or not the application at each end
knows it is using TCP-ENO.</t>
</list>
</t>
<t>If TCP-ENO fails, encryption is disabled and the connection falls back
to traditional unencrypted TCP.
</t>
<t>The remainder of this section provides the normative description of
the TCP ENO option and handshake protocol.
</t>

<section anchor="eno-option" title="ENO option">
<t>TCP-ENO employs an option in the TCP header <xref target="RFC0793"/>.  There are
two equivalent kinds of ENO option, shown in <xref target="fig:option"/>.
<xref target="iana-considerations"/> specifies which of the two kinds is permissible
and/or preferred.
</t>

<figure anchor="fig:option" align="center" title="Two equivalent kinds of TCP-ENO option
"><artwork align="center">
byte    0     1     2             N+1   (N+2 bytes total)
     +-----+-----+-----+--....--+-----+
     |Kind=|Len= |                    |
     | 69  | N+2 | contents (N bytes) |
     +-----+-----+-----+--....--+-----+

byte    0     1     2     3     4             N+3   (N+4 bytes total)
     +-----+-----+-----+-----+-----+--....--+-----+
     |Kind=|Len= |   ExID    |                    |
     | 253 | N+4 | 69  | 78  | contents (N bytes) |
     +-----+-----+-----+-----+-----+--....--+-----+
</artwork></figure>
<t>The contents of an ENO option can take one of two forms.  A SYN form,
illustrated in <xref target="fig:eno"/>, appears only in SYN segments.  A non-SYN
form, illustrated in <xref target="fig:minimal"/>, appears only in non-SYN segments.
The SYN form of ENO acts as a container for one or more suboptions,
labeled <spanx style="verb">Opt_0</spanx>, <spanx style="verb">Opt_1</spanx>, ... in <xref target="fig:eno"/>.  The non-SYN form, by its
presence, acts as a one-bit acknowledgment, with the actual contents
ignored by ENO.  Particular encryption specs MAY assign additional
meaning to the contents of non-SYN ENO options.  When a negotiated
spec does not assign such meaning, the contents of a non-SYN ENO
option SHOULD be zero bytes.
</t>

<figure anchor="fig:eno" align="center" title="SYN form of ENO
"><artwork align="center">
byte    0     1     2     3                     ... N+1
     +-----+-----+-----+-----+--...--+-----+----...----+
     |Kind=|Len= |Opt_0|Opt_1|       |Opt_i|   Opt_i   |
     | 69  | N+2 |     |     |       |     |   data    |
     +-----+-----+-----+-----+--...--+-----+----...----+

byte    0     1     2     3     4     5                     ... N+3
     +-----+-----+-----+-----+-----+-----+--...--+-----+----...----+
     |Kind=|Len= |   ExID    |Opt_0|Opt_1|       |Opt_i|   Opt_i   |
     | 253 | N+4 | 69  | 78  |     |     |       |     |   data    |
     +-----+-----+-----+-----+-----+-----+--...--+-----+----...----+
</artwork></figure>

<figure anchor="fig:minimal" align="center" title="Non-SYN form of ENO, where N MAY be 0
"><artwork align="center">
byte   0     1     2     N+1
    +-----+-----+-----...----+
    |Kind=|Len= |  ignored   |
    | 69  | N+2 | by TCP-ENO |
    +-----+-----+-----...----+

byte   0     1     2     3     4     N+3
    +-----+-----+-----+-----+-----...----+
    |Kind=|Len= |   ExID    |  ignored   |
    | 253 | N+4 | 69  | 78  | by TCP-ENO |
    +-----+-----+-----+-----+-----...----+
</artwork></figure>
<t>Every suboption starts with a byte of the form illustrated in
<xref target="fig:subopt"/>.  The high bit <spanx style="verb">v</spanx>, when set, introduces suboptions with
variable-length data.  When <spanx style="verb">v = 0</spanx>, the byte itself constitutes the
entirety of the suboption.  The 7-bit value <spanx style="verb">cs</spanx> expresses one of:
</t>
<t>
<list style="symbols">
<t>Global configuration data (discussed in <xref target="general-suboptions"/>),</t>
<t>Suboption data length for the next suboption (discussed in
<xref target="specifying-suboption-data-length"/>), or</t>
<t>An offer to use a particular encryption spec detailed in a separate
document.</t>
</list>
</t>

<figure anchor="fig:subopt" align="center" title="Format of initial suboption byte
"><artwork align="center">
bit   7   6   5   4   3   2   1   0
    +---+---+---+---+---+---+---+---+
    | v |            cs             |
    +---+---+---+---+---+---+---+---+

    v  - non-zero for use with variable-length suboption data
    cs - global configuration option or encryption spec identifier
</artwork></figure>
<t><xref target="tab:subopt"/> summarizes the meaning of initial suboption bytes.
Values of <spanx style="verb">cs</spanx> greater than or equal to 0x20 are spec identifiers,
while those below 0x20 are shared between general suboptions and
length bytes.  When <spanx style="verb">v = 0</spanx>, the initial suboption byte constitutes
the entirety of the suboption and all information is expressed by the
7-bit value <spanx style="verb">cs</spanx>, which can be a spec identifier or general suboption.
When <spanx style="verb">v = 1</spanx>, it indicates a suboption with one or more bytes of
suboption data.  Only spec identifiers may have suboption data, not
general suboptions.  Hence, bytes with <spanx style="verb">v = 1</spanx> and <spanx style="verb">cs &lt; 0x20</spanx> are not
general suboptions but rather length bytes governing the length of the
next suboption.  In the absence of a length byte, a spec identifier
suboption with <spanx style="verb">v = 1</spanx> has suboption data extending to the end of the
TCP option.
</t>
<texttable anchor="tab:subopt" title="Initial suboption byte values
">
<ttcol align="left">cs</ttcol>
<ttcol align="left">v</ttcol>
<ttcol align="left">Meaning</ttcol>

<c>0x00-0x1f</c><c>0</c><c>General suboption (<xref target="general-suboptions"/>)</c>
<c>0x00-0x1f</c><c>1</c><c>Length byte (<xref target="specifying-suboption-data-length"/>)</c>
<c>0x20-0x7f</c><c>0</c><c>Encryption spec without suboption data</c>
<c>0x20-0x7f</c><c>1</c><c>Encryption spec followed by suboption data</c>
</texttable>
<t>A SYN segment MUST contain at most one ENO TCP option.  If a SYN
segment contains more than one ENO option, the receiver MUST behave as
though the segment contained no ENO options and disable encryption.
An encryption spec MAY define the use of multiple ENO options in a
non-SYN segment.  For non-SYN segments, ENO itself only distinguishes
between the presence or absence of ENO options; multiple ENO options
are interpreted the same as one.
</t>
</section>

<section anchor="general-suboptions" title="General suboptions">
<t>Suboptions 0x00-0x1f are used for general conditions that apply
regardless of the negotiated encryption spec.  A TCP SYN segment MUST
include at most one ENO suboption in this range.  A receiver MUST
ignore all but the first suboption in this range so as to anticipate
future revisions of ENO that assign new meaning to bits in subsequent
general suboptions.  The value of a general suboption byte is
interpreted as a bitmask, illustrated in <xref target="fig:config"/>.
</t>

<figure anchor="fig:config" align="center" title="Format of the general option byte
"><artwork align="center">
bit   7   6   5   4   3   2   1   0
    +---+---+---+-------+---+---+---+
    | 0 | 0 | 0 |  zz   | m | a | b |
    +---+---+---+-------+---+---+---+

    b   - Passive role bit
    a   - Application-aware bit
    m   - Middleware signaling bit
    zz  - Zero bits (reserved for future use)
</artwork></figure>
<t>The fields of the bitmask are interpreted as follows:
</t>
<t>
<list style="hanging">
<t hangText="b">
<vspace />
The passive role bit MUST be 1 for all passive openers.  For active
openers, it MUST default to 0, but implementations SHOULD provide an
API through which an application can set <spanx style="verb">b = 1</spanx> before calling
<spanx style="verb">connect</spanx>.  (Manual configuration of <spanx style="verb">b</spanx> is necessary for simultaneous
open.)</t>
<t hangText="a">
<vspace />
The application-aware bit <spanx style="verb">a</spanx> is an out-of-band signal indicating
that the application on the sending host is aware of TCP-ENO and has
been extended to alter its behavior in the presence of encrypted TCP.
Implementations MUST set this bit to 0 by default, and SHOULD provide
an API through which applications can change the value of the bit as
well as examine the value of the bit sent by the remote host.
Implementations SHOULD furthermore support a <spanx style="emph">mandatory</spanx>
application-aware mode in which TCP-ENO is automatically disabled if
the remote host does not set <spanx style="verb">a = 1</spanx>.</t>
<t hangText="m">
<vspace />
The middleware bit <spanx style="verb">m</spanx> functions similarly to the application-aware
bit <spanx style="verb">a</spanx>.  It is available for middleware such as shared libraries
needing out-of-band signaling to improve the security of legacy
applications.  Implementations MUST set this bit to 0 by default and
SHOULD provide an API through which software can change the value.
Unlike the application-aware <spanx style="verb">a</spanx> bit, no mandatory mode is needed for
the middleware bit.</t>
<t hangText="zz">
<vspace />
The <spanx style="verb">zz</spanx> bits are reserved for future revisions of TCP-ENO.  They
MUST be set to zero in sent segments and MUST be ignored in received
segments.</t>
</list>
</t>
<t>A SYN segment without an explicit general suboption has an implicit
general suboption of 0x00.  Because passive openers MUST always set <spanx style="verb">b
= 1</spanx>, they cannot rely on this implicit 0x00 byte and MUST include an
explicit general suboption in the ENO options of their SYN-ACK
segments.
</t>
</section>

<section anchor="tcpeno-roles" title="TCP-ENO roles">
<t>TCP-ENO uses abstract roles to distinguish the two ends of a TCP
connection.  These roles are determined by the <spanx style="verb">b</spanx> bit in the general
suboption.  The host that sent an implicit or explicit suboption with
<spanx style="verb">b = 0</spanx> plays the &quot;A&quot; role.  The host that sent <spanx style="verb">b = 1</spanx> plays the &quot;B&quot;
role.
</t>
<t>If both sides of a connection set <spanx style="verb">b = 1</spanx> (which can happen if the
active opener misconfigures <spanx style="verb">b</spanx> before calling <spanx style="verb">connect</spanx>), or both
sides set <spanx style="verb">b = 0</spanx> (which can happen with simultaneous open), then
TCP-ENO MUST be disabled and the connection MUST fall back to
unencrypted TCP.
</t>
<t>Encryption specs SHOULD refer to TCP-ENO's A and B roles to specify
asymmetric behavior by the two hosts.  For the remainder of this
document, we will use the terms &quot;host A&quot; and &quot;host B&quot; to designate the
hosts with A and B roles, respectively, in a connection.
</t>
</section>

<section anchor="specifying-suboption-data-length" title="Specifying suboption data length">
<t>An encryption spec MAY optionally specify the use of one or more bytes
of suboption data.  The presence of such data is indicated by setting
<spanx style="verb">v = 1</spanx> in the initial suboption byte (see <xref target="fig:subopt"/>).  By
default, suboption data extends to the end of the TCP option.  Hence,
if only one suboption requires data, the most compact way to encode it
is to place it last in the ENO option, after all one-byte suboptions.
As an example, in <xref target="fig:eno"/>, the last suboption, <spanx style="verb">Opt_i</spanx>, has
suboption data and thus requires <spanx style="verb">v = 1</spanx>; however, the suboption data
length can be implicit in the total length of the TCP option.
</t>
<t>When a suboption with data is not last in an ENO option, the sender
MUST explicitly specify the suboption data length for the receiver to
know where the next suboption starts.  The sender does so by preceding
the suboption with a length byte.
</t>
<t><xref target="fig:marker"/> shows the format of a length byte.  It encodes a 5-bit
value <spanx style="verb">nnnnn</spanx>.  Adding one to <spanx style="verb">nnnnn</spanx> yields the length of the
suboption data not including the length byte and initial spec
identifier byte.  Hence, a length byte can designate a suboption
carrying anywhere from 1 to 32 bytes of suboption data (inclusive).
</t>

<figure anchor="fig:marker" align="center" title="Format of a length byte
"><artwork align="center">
bit   7   6   5   4   3   2   1   0
    +---+---+---+-------------------+
    | 1   0   0         nnnnn       |
    +---+---+---+-------------------+

    nnnnn - 5-bit value encoding (length - 1)
</artwork></figure>
<t>A suboption preceded by a length byte MUST be a spec identifier
(<spanx style="verb">cs &gt;= 0x20</spanx>) and MUST have <spanx style="verb">v =
1</spanx>. <xref target="fig:suboption-with-length-byte"/> shows an example of such a
suboption.
</t>

<figure anchor="fig:suboption-with-length-byte" align="center" title="Suboption with length byte
"><artwork align="center">
byte    0      1       2      nnnnn+2  (nnnnn+3 bytes total)
     +------+------+-------...-------+
     |length| spec | suboption data  |
     | byte |ident.| (nnnnn+1 bytes) |
     +------+------+-------...-------+

     length byte     - specifies nnnnn
     spec identifier - MUST have v = 1 and cs &gt;= 0x20
     suboption data  - length specified by nnnnn+1
</artwork></figure>
<t>If the octet following a length byte has the high bit clear (meaning
<spanx style="verb">v = 0</spanx>), then the length byte and following octet together are
interpreted as a length word, as shown in <xref target="fig:marker-word"/>.  The
length word encodes an 8-bit value corresponding to one less than the
suboption data length.  As with length bytes, spec identifiers MUST
have <spanx style="verb">v = 1</spanx>.
</t>

<figure anchor="fig:marker-word" align="center" title="Format of a length word
"><artwork align="center">
bit   15  14  13  12  11  10  9   8   7   6   5   4   3   2   1   0
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | 1   0   0       zzzz      | m | 0 |            nnnnnnn        |
    +---+---+---+-------------------+---+---------------------------+

    nnnnnnn - 7 least significant bits of 8-bit value (length - 1)
    m       - Most significant bit of 8-bit value (length - 1)
    zzzz    - Bits that MUST be zero (reserved for future use)
</artwork></figure>
<t>The <spanx style="verb">zzzz</spanx> bits in a length word MUST be set to 0 by a sender.  If a
host receives a length word in which the <spanx style="verb">zzzz</spanx> bits are not all 0, it
MUST ignore the entire received ENO option and disable encryption.
Similarly, if a length byte or word in a received SYN segment
indicates that a TCP-ENO suboption would extend beyond the end of the
ENO TCP option, the receiver MUST behave as though the received SYN
segment contained no TCP-ENO option and disable encryption.
</t>
</section>

<section anchor="the-negotiated-spec" title="The negotiated spec">
<t>A spec identifier <spanx style="verb">cs</spanx> is <spanx style="emph">valid</spanx> for a connection when:
</t>
<t>
<list style="numbers">
<t>Each side has sent a suboption for <spanx style="verb">cs</spanx> in its SYN-form ENO option,</t>
<t>Any suboption data in these <spanx style="verb">cs</spanx> suboptions is valid according to
the spec and satisfies any runtime constraints, and</t>
<t>If one host sends multiple suboptions with <spanx style="verb">cs</spanx>, then such
repetition is well-defined by the encryption spec.</t>
</list>
</t>
<t>The <spanx style="emph">negotiated encryption spec</spanx> is the last valid spec identifier in
host B's SYN-form ENO option.  This means host B specifies suboptions
in order of increasing priority, while host A does not influence spec
priority.
</t>
<t>A passive opener (which is always host B) sees the remote host's SYN
segment before constructing its own SYN-ACK.  Hence, a passive opener
SHOULD include only one spec identifier in SYN-ACK segments and SHOULD
ensure this spec identifier is valid.  However, simultaneous open or
implementation considerations can prevent host B from offering only
one encryption spec.
</t>
</section>

<section anchor="tcpeno-handshake" title="TCP-ENO handshake">
<t>A host employing TCP-ENO for a connection MUST include an ENO option
in every TCP segment sent until either encryption is disabled or the
host receives a non-SYN segment.
</t>
<t>A host MUST disable encryption, refrain from sending any further ENO
options, and fall back to unencrypted TCP if any of the following
occurs:
</t>
<t>
<list style="numbers">
<t>Any segment it receives up to and including the first received ACK
segment does not contain an ENO option,</t>
<t>The SYN segment it receives does not contain a valid spec
identifier, or</t>
<t>It receives a SYN segment with an incompatible general suboption.
(Specifically, incompatible means the two hosts set the same <spanx style="verb">b</spanx>
value or the connection is in mandatory application-aware mode and
the remote host set <spanx style="verb">a = 0</spanx>.)</t>
</list>
</t>
<t>Hosts MUST NOT alter SYN-form ENO options in retransmitted segments,
or between the SYN and SYN-ACK segments of a simultaneous open, with
two exceptions for an active opener.  First, an active opener MAY
unilaterally disable ENO (and thus remove the ENO option) between
retransmissions of a SYN-only segment.  (Such removal could be useful
if middleboxes are dropping segments with the ENO option.)  Second, an
active opener performing simultaneous open MAY include no TCP-ENO
option in its SYN-ACK if the received SYN caused it to disable
encryption according to the above rules (for instance because role
negotiation failed).
</t>
<t>Once a host has both sent and received an ACK segment containing an
ENO option, encryption MUST be enabled.  Once encryption is enabled,
hosts MUST follow the encryption protocol of the negotiated spec and
MUST NOT present raw TCP payload data to the application.  In
particular, data segments MUST contain ciphertext or key agreement
messages as determined by the negotiated spec, and MUST NOT contain
plaintext application data.
</t>
</section>

<section anchor="negotiation-transcript" title="Negotiation transcript">
<t>To defend against attacks on encryption negotiation itself, encryption
specs need a way to reference a transcript of TCP-ENO's negotiation.
In particular, an encryption spec MUST fail with high probability if
its selection resulted from tampering with or forging initial SYN
segments.
</t>
<t>TCP-ENO defines its negotiation transcript as a packed data structure
consisting of two TCP-ENO options exactly as they appeared in the TCP
header (including the TCP option kind, TCP option length byte, and,
for option kind 253, the bytes 69 and 78 as illustrated in
<xref target="fig:option"/>).  The transcript is constructed from the following, in
order:
</t>
<t>
<list style="numbers">
<t>The TCP-ENO option in host A's SYN segment, including the kind and
length bytes.</t>
<t>The TCP-ENO option in host B's SYN segment, including the kind and
length bytes.</t>
</list>
</t>
<t>Note that because the ENO options in the transcript contain length
bytes as specified by TCP, the transcript unambiguously delimits A's
and B's ENO options.
</t>
</section>
</section>

<section anchor="requirements-for-encryption-specs" title="Requirements for encryption specs">
<t>Though TCP-ENO affords spec authors a large amount of design
flexibility, to abstract spec differences away from applications
requires fitting them all into a coherent framework.  As such, any
encryption spec claiming an ENO spec identifier MUST satisfy the
following normative list of properties.
</t>
<t>
<list style="symbols">
<t>Specs MUST protect TCP data streams with authenticated encryption.</t>
<t>Specs MUST define a session ID whose value identifies the TCP
connection and, with overwhelming probability, is unique over all
time if either host correctly obeys the spec.  <xref target="session-ids"/>
describes the requirements of the session ID in more detail.</t>
<t>Specs MUST NOT permit the negotiation of any encryption algorithms
with significantly less than 128-bit security.</t>
<t>Specs MUST NOT allow the negotiation of null cipher suites, even for
debugging purposes.  (Implementations MAY support debugging modes
that allow applications to extract their own session keys.)</t>
<t>Specs MUST NOT depend on long-lived secrets for data
confidentiality, as implementations SHOULD provide forward secrecy
some bounded, short time after the close of a TCP connection.</t>
<t>Specs MUST protect and authenticate the end-of-file marker
traditionally conveyed by TCP's FIN flag when the remote application
calls <spanx style="verb">close</spanx> or <spanx style="verb">shutdown</spanx>.  However, end-of-file MAY be conveyed
though a mechanism other than TCP FIN.  Moreover, specs MAY permit
attacks that cause TCP connections to abort, but such an abort MUST
raise an error that is distinct from an end-of-file condition.</t>
<t>Specs MAY disallow the use of TCP urgent data by applications, but
MUST NOT allow attackers to manipulate the URG flag and urgent
pointer in ways that are visible to applications.</t>
</list>
</t>

<section anchor="session-ids" title="Session IDs">
<t>Each spec MUST define a session ID that uniquely identifies each
encrypted TCP connection.  Implementations SHOULD expose the session
ID to applications via an API extension.  Applications that are aware
of TCP-ENO SHOULD incorporate the session ID value and TCP-ENO role (A
or B) into any authentication mechanisms layered over TCP encryption
so as to authenticate actual TCP endpoints.
</t>
<t>In order to avoid replay attacks and prevent authenticated session IDs
from being used out of context, session IDs MUST be unique over all
time with high probability.  This uniqueness property MUST hold even
if one end of a connection maliciously manipulates the protocol in an
effort to create duplicate session IDs.  In other words, it MUST be
infeasible for a host, even by deviating from the encryption spec, to
establish two TCP connections with the same session ID to remote hosts
obeying the spec.
</t>
<t>To prevent session IDs from being confused across specs, all session
IDs begin with the negotiated spec identifier--that is, the last valid
spec identifier in host B's SYN segment.  If the <spanx style="verb">v</spanx> bit was 1 in host
B's SYN segment, then it is also 1 in the session ID.  However, only
the first byte is included, not the suboption data.  <xref target="fig:sessid"/>
shows the resulting format.  This format is designed for spec authors
to compute unique identifiers; it is not intended for application
authors to pick apart session IDs.  Applications SHOULD treat session
IDs as monolithic opaque values and SHOULD NOT discard the first byte
to shorten identifiers.
</t>

<figure anchor="fig:sessid" align="center" title="Format of a session ID
"><artwork align="center">
byte    0     1     2        N-1    N
     +-----+------------...------------+
     | sub-| collision-resistant hash  |
     | opt | of connection information |
     +-----+------------...------------+
</artwork></figure>
<t>Though specs retain considerable flexibility in their definitions of
the session ID, all session IDs MUST meet certain minimum
requirements.  In particular:
</t>
<t>
<list style="symbols">
<t>The session ID MUST be at least 33 bytes (including the one-byte
suboption), though specs may choose longer session IDs.</t>
<t>The session ID MUST depend in a collision-resistant way on fresh
data contributed by both sides of the connection.</t>
<t>The session ID MUST depend in a collision-resistant way on any
public keys, public Diffie-Hellman parameters, or other public
asymmetric cryptographic parameters that are employed by the
encryption spec and have corresponding private data that is known by
only one side of the connection.</t>
<t>Unless and until applications disclose information about the session
ID, all but the first byte MUST be computationally indistinguishable
from random bytes to a network eavesdropper.</t>
<t>Applications MAY chose to make session IDs public.  Therefore, specs
MUST NOT place any confidential data in the session ID (such as data
permitting the derivation of session keys).</t>
<t>The session ID MUST depend on the negotiation transcript specified
in <xref target="negotiation-transcript"/> in a collision-resistant way.</t>
</list>
</t>
</section>
</section>

<section anchor="examples" title="Examples">
<t>This subsection illustrates the TCP-ENO handshake with a few
non-normative examples.
</t>

<figure anchor="fig:handshake" align="center" title="Three-way handshake with successful TCP-ENO negotiation
"><artwork align="center">
(1) A -&gt; B:  SYN      ENO&lt;X,Y&gt;
(2) B -&gt; A:  SYN-ACK  ENO&lt;b=1,Y&gt;
(3) A -&gt; B:  ACK      ENO&lt;&gt;
[rest of connection encrypted according to spec for Y]
</artwork></figure>
<t><xref target="fig:handshake"/> shows a three-way handshake with a successful TCP-ENO
negotiation.  The two sides agree to follow the encryption spec
identified by suboption Y.
</t>

<figure anchor="fig:bad-handshake" align="center" title="Three-way handshake with failed TCP-ENO negotiation
"><artwork align="center">
(1) A -&gt; B:  SYN      ENO&lt;X,Y&gt;
(2) B -&gt; A:  SYN-ACK
(3) A -&gt; B:  ACK
[rest of connection unencrypted legacy TCP]
</artwork></figure>
<t><xref target="fig:bad-handshake"/> shows a failed TCP-ENO negotiation.  The active
opener (A) indicates support for specs corresponding to suboptions X
and Y.  Unfortunately, at this point one of several things occurs:
</t>
<t>
<list style="numbers">
<t>The passive opener (B) does not support TCP-ENO,</t>
<t>B supports TCP-ENO, but supports neither of specs X and Y, and so
does not reply with an ENO option,</t>
<t>B supports TCP-ENO, but has the connection configured in mandatory
application-aware mode and thus disables ENO because A's SYN
segment does not set the application-aware bit, or</t>
<t>The network stripped the ENO option out of A's SYN segment, so B
did not receive it.</t>
</list>
</t>
<t>Whichever of the above applies, the connection transparently falls
back to unencrypted TCP.
</t>

<figure anchor="fig:filter" align="center" title="Failed TCP-ENO negotiation because of network filtering
"><artwork align="center">
(1) A -&gt; B:  SYN      ENO&lt;X,Y&gt;
(2) B -&gt; A:  SYN-ACK  ENO&lt;b=1,X&gt; [ENO stripped by middlebox]
(3) A -&gt; B:  ACK
[rest of connection unencrypted legacy TCP]
</artwork></figure>
<t><xref target="fig:filter"/> Shows another handshake with a failed encryption
negotiation.  In this case, the passive opener B receives an ENO
option from A and replies.  However, the reverse network path from B
to A strips ENO options.  Hence, A does not receive an ENO option from
B, disables ENO, and does not include a non-SYN form ENO option when
ACKing the other host's SYN segment.  The lack of ENO in A's ACK
segment signals to B that the connection will not be encrypted.  At
this point, the two hosts proceed with an unencrypted TCP connection.
</t>

<figure anchor="fig:simultaneous" align="center" title="Simultaneous open with successful TCP-ENO negotiation
"><artwork align="center">
(1) A -&gt; B:  SYN      ENO&lt;Y,X&gt;
(2) B -&gt; A:  SYN      ENO&lt;b=1,X,Y,Z&gt;
(3) A -&gt; B:  SYN-ACK  ENO&lt;Y,X&gt;
(4) B -&gt; A:  SYN-ACK  ENO&lt;b=1,X,Y,Z&gt;
[rest of connection encrypted according to spec for Y]
</artwork></figure>
<t><xref target="fig:simultaneous"/> shows a successful TCP-ENO negotiation with
simultaneous open.  Here the first four segments MUST contain a
SYN-form ENO option, as each side sends both a SYN-only and a SYN-ACK
segment.  The ENO option in each host's SYN-ACK is identical to the
ENO option in its SYN-only segment, as otherwise connection
establishment could not recover from the loss of a SYN segment.  The
last valid spec in host B's ENO option is Y, so Y is the negotiated
spec.
</t>
</section>

<section anchor="design-rationale" title="Design rationale">
<t>This section describes some of the design rationale behind TCP-ENO.
</t>

<section anchor="future-developments" title="Future developments">
<t>TCP-ENO is designed to capitalize on future developments that could
alter trade-offs and change the best approach to TCP-level encryption
(beyond introducing new cipher suites).  By way of example, we discuss
a few such possible developments.
</t>
<t>Various proposals exist to increase option space in TCP
<xref target="I-D.ietf-tcpm-tcp-edo"/><xref target="I-D.briscoe-tcpm-inspace-mode-tcpbis"/><xref target="I-D.touch-tcpm-tcp-syn-ext-opt"/>.
If SYN segments gain large options, it becomes possible to fit public
keys or Diffie-Hellman parameters into SYN segments.  Future
encryption specs can take advantage of this by performing key
agreement directly within suboption data, both simplifying protocols
and reducing the number of round trips required for connection setup.
</t>
<t>New revisions to socket interfaces <xref target="RFC3493"/> could involve library
calls that simultaneously have access to hostname information and an
underlying TCP connection.  Such an API enables the possibility of
authenticating servers transparently to the application, particularly
in conjunction with technologies such as DANE <xref target="RFC6394"/>.  The
middleware bit <spanx style="verb">m</spanx> in general suboptions enables a middleware library
to indicate to the peer that it wishes to engage in an authentication
protocol before turning the TCP connection over to the application.
Different middleware authentication protocols can employ unique
identifiers to multiplex the <spanx style="verb">m</spanx> bit.
</t>
<t>TLS can currently only be added to legacy applications whose protocols
accommodate a STARTTLS command or equivalent.  TCP-ENO, because it
provides out-of-band signaling, opens the possibility of future TLS
revisions being generically applicable to any TCP application.
</t>
</section>

<section anchor="handshake-robustness" title="Handshake robustness">
<t>Incremental deployment of TCP-ENO depends critically on failure cases
devolving to unencrypted TCP rather than causing the entire TCP
connection to fail.
</t>
<t>Because some network paths drop ENO options in one direction only, a
host must know not just that the peer supports encryption, but that
the peer has received an ENO option.  To this end, ENO disables
encryption unless it receives an ACK segment bearing an ENO option.
To stay robust in the face of dropped segments, hosts must continue to
include non-SYN form ENO options in segments until such point as they
have received a non-SYN segment from the other side.
</t>
<t>One particularly pernicious middlebox behavior found in the wild is
load balancers that echo unknown TCP options found in SYN segments
back to an active opener.  The passive role bit <spanx style="verb">b</spanx> in general
suboptions ensures encryption will always be disabled under such
circumstances, as sending back a verbatim copy of an active opener's
SYN-form ENO option always causes role negotiation to fail.
</t>
</section>

<section anchor="suboption-data" title="Suboption data">
<t>Encryption specs can employ suboption data for session caching, cipher
suite negotiation, or other purposes.  However, TCP currently limits
total option space consumed by all options to only 40 bytes, making it
impractical to have many suboptions with data.  For this reason, ENO
optimizes the case of a single suboption with data by inferring the
length of the last suboption from the TCP option length.  Doing so
saves one byte.
</t>
</section>

<section anchor="passive-role-bit" title="Passive role bit">
<t>TCP-ENO, associated encryption specs, and applications all have
asymmetries that require an unambiguous way to identify one of the two
connection endpoints.  As an example, <xref target="negotiation-transcript"/>
specifies that host A's ENO option comes before host B's in the
negotiation transcript.  As another example, an application might need
to authenticate one end of a TCP connection with a digital signature.
To ensure the signed message cannot not be interpreted out of context
to authenticate the other end, the signed message would need to
include both the session ID and the local role, A or B.
</t>
<t>A normal TCP three-way handshake involves one active and one passive
opener.  This asymmetry is captured by the default configuration of
the <spanx style="verb">b</spanx> bit in the general suboption.  With simultaneous open, both
hosts are active openers, so TCP-ENO requires that one host manually
configure <spanx style="verb">b = 1</spanx>.  An alternate design might automatically break the
symmetry to avoid this need for manual configuration.  However, all
such designs we considered either lacked robustness or consumed
precious bytes of SYN option space even in the absence of simultaneous
open.  (One complicating factor is that TCP does not know it is
participating in a simultaneous open until after it has sent a SYN
segment.  Moreover, with packet loss, one host might never learn it
has participated in a simultaneous open.)
</t>
</section>

<section anchor="option-kind-sharing" title="Option kind sharing">
<t>This draft does not specify the use of ENO options beyond the first
few segments of a connection.  Moreover, it does not specify the
content of ENO options in non-SYN segments, only their presence.  As a
result, any use of option kind 69 (or option kind 253 with ExID
0x454E) after the SYN exchange does not conflict with this document.
Because in addition ENO guarantees at most one negotiated spec per
connection, encryption specs will not conflict with one another or ENO
if they use ENO's option kind for out-of-band signaling in non-SYN
segments.
</t>
</section>
</section>

<section anchor="experiments" title="Experiments">
<t>This document has experimental status because TCP-ENO's viability
depends on middlebox behavior that can only be determined <spanx style="emph">a
posteriori</spanx>.  Specifically, we must determine to what extent
middleboxes will permit the use of TCP-ENO.  Once TCP-ENO is deployed,
we will be in a better position to gather data on two types of
failure:
</t>
<t>
<list style="numbers">
<t>Middleboxes downgrading TCP-ENO connections to unencrypted TCP.
This can happen if middleboxes strip unknown TCP options or if they
terminate TCP connections and relay data back and forth.</t>
<t>Middleboxes causing TCP-ENO connections to fail completely.  This
can happen if applications perform deep packet inspection and start
dropping segments that unexpectedly contain ciphertext.</t>
</list>
</t>
<t>The first type of failure is tolerable since TCP-ENO is designed for
incremental deployment anyway.  The second type of failure is more
problematic, and, if prevalent, will require the development of
techniques to avoid and recover from such failures.
</t>
</section>

<section anchor="security-considerations" title="Security considerations">
<t>An obvious use case for TCP-ENO is opportunistic encryption--that is,
encrypting some connections, but only where supported and without any
kind of endpoint authentication.  Opportunistic encryption protects
against undetectable large-scale eavesdropping.  However, it does not
protect against detectable large-scale eavesdropping (for instance, if
ISPs terminate and proxy TCP connections or simply downgrade them to
unencrypted).  Moreover, it emphatically does not protect against
targeted attacks that employ trivial spoofing to redirect a specific
high-value connection to a man-in-the-middle attacker.
</t>
<t>Achieving stronger security with TCP-ENO requires verifying session
IDs.  Any application relying on ENO for communications security MUST
incorporate session IDs into its endpoint authentication.  By way of
example, an authentication mechanism based on keyed digests (such
Digest Access Authentication <xref target="RFC7616"/>) can be extended to include
the role and session ID in the input of the keyed digest.  Where
necessary for backwards compatibility, applications SHOULD use the
application-aware bit to negotiate the inclusion of session IDs in
authentication.
</t>
<t>Because TCP-ENO enables multiple different encryption specs to
coexist, security could potentially be only as strong as the weakest
available spec.  In particular, if session IDs do not depend on the
TCP-ENO transcript in a strong way, an attacker can undetectably
tamper with ENO options to force negotiation of a deprecated and
vulnerable spec.  To avoid such problems, specs SHOULD compute session
IDs using only well-studied and conservative hash functions.  That
way, even if other parts of a spec are vulnerable, it is still
intractable for an attacker to induce identical session IDs at both
ends after tampering with ENO contents in SYN segments.
</t>
<t>Implementations MUST NOT send ENO options unless they have access to
an adequate source of randomness <xref target="RFC4086"/>.  Without secret
unpredictable data at both ends of a connection, it is impossible for
encryption specs to achieve confidentiality and forward secrecy.
Because systems typically have very little entropy on bootup,
implementations might need to disable TCP-ENO until after system
initialization.
</t>
<t>With a regular three-way handshake (meaning no simultaneous open), the
non-SYN form ENO option in an active opener's first ACK segment MAY
contain N &gt; 0 bytes of spec-specific data, as shown in <xref target="fig:minimal"/>.
Such data is not part of the TCP-ENO negotiation transcript, and hence
MUST be separately authenticated by the encryption spec.
</t>
</section>

<section anchor="iana-considerations" title="IANA Considerations">
<t>[This section is a placeholder, as David Black has offered to help
rewrite it.]
</t>
<t>Implementations MUST NOT use option kind 69 unless and until it is
assigned to TCP-ENO by IANA.  In the meantime, implementations MUST
use experimental option 253 <xref target="RFC6994"/>, to which IANA has assigned
ExID 0x454E (encoded by decimal bytes 69, 78 in <xref target="fig:option"/>).
Conversely, after IANA assigns a dedicated option kind to TCP-ENO, the
use of option 253 is deprecated.
</t>
<t>IANA will need to maintain an ENO suboption registry mapping suboption
<spanx style="verb">cs</spanx> values to encryption specs.
</t>
</section>

<section anchor="acknowledgments" title="Acknowledgments">
<t>We are grateful for contributions, help, discussions, and feedback
from the TCPINC working group, including Marcelo Bagnulo, David Black,
Bob Briscoe, Jana Iyengar, Tero Kivinen, Mirja Kuhlewind, Yoav Nir,
Christoph Paasch, Eric Rescorla, and Kyle Rose.  This work was funded
by DARPA CRASH and the Stanford Secure Internet of Things Project.
</t>
</section>

</middle>
<back>
<references title="Normative References">
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.0793.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4086.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6994.xml"?>
</references>
<references title="Informative References">
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.briscoe-tcpm-inspace-mode-tcpbis.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-tcpm-tcp-edo.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.touch-tcpm-tcp-syn-ext-opt.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3493.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5246.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5382.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6394.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7616.xml"?>
</references>

</back>
</rfc>
