<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' []>
<rfc ipr="trust200902" category="exp" docName="draft-bittau-tcpinc-tcpeno-01">
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="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>
</postal>
<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>
</postal>
<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>
</postal>
<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>
</postal>
<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>
</postal>
<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>
</postal>
<email>eric.smith@kestrel.edu</email>
<uri></uri>
</address>
</author>
<date year="2015" month="August" day="10"/>

<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>While the need for encryption is immediate, future developments could
alter trade-offs and change the best approach to TCP-level encryption
(beyond introducing new cipher suites).  For example:
</t>
<t>
<list style="symbols">
<t>Increased 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"/>
could reduce round trip times and simplify protocols.</t>
<t>API revisions to socket interfaces <xref target="RFC3493"/> could benefit from
integration with TCP-level encryption, particularly if combined with
technologies such as DANE <xref target="RFC6394"/>.</t>
<t>The forthcoming TLS 1.3 <xref target="I-D.ietf-tls-tls13"/> standard could
reach more applications given an out-of-band, backward-compatible
mechanism for enabling encryption.</t>
<t>TCP fast open <xref target="RFC7413"/>, as it gains more widespread adoption and
middlebox acceptance, could potentially benefit from tailored
encryption support.</t>
<t>Cryptographic developments that either shorten or lengthen the
minimal key exchange messages required could affect how such
messages are best encoded in TCP segments.</t>
</list>
</t>
<t>Introducing TCP options, extending operating system interfaces to
support TCP-level encryption, and extending applications to take
advantage of TCP-level encryption will all require effort.  To the
greatest extent possible, this effort ought to remain applicable if
the need arises 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 option called TCP-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.  A companion document, the TCPINC encryption spec,
addresses question 2.  TCPINC enables TCP-level traffic encryption
today.  TCP-ENO ensures that the effort invested to deploy TCPINC can
benefit future encryption specs should a different approach at some
point be preferable.
</t>
<t>At a lower level, 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
encryption <spanx style="emph">spec</spanx>.</t>
<t>Transparently fall back to unencrypted TCP when not supported by
both endpoints.</t>
<t>Provide 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 break
the symmetry of simultaneous open and uniquely name each end of a
connection for authentication purposes.</t>
</list>
</t>
</section>

<section anchor="the-tcpeno-option" title="The TCP-ENO option">
<t>TCP-ENO is a TCP option used during connection establishment to
negotiate how to encrypt traffic.  As an option, TCP-ENO can be
deployed incrementally.  Legacy hosts unaware of the option simply
ignore it and never send it, causing traffic to fall back to
unencrypted TCP.  Similarly, middleboxes that strip out unknown
options including TCP-ENO will downgrade connections to plaintext
without breaking them.  Of course, downgrading makes TCP-ENO
vulnerable to active attackers, but appropriately modified
applications can protect themselves by considering the state of
TCP-level encryption during authentication, as discussed in
<xref target="security-considerations"/>.
</t>
<t>The ENO option takes two forms.  In TCP segments with the SYN flag
set, it acts as a container for a series of one or more suboptions, as
shown in <xref target="fig:eno"/>.  In non-SYN segments, ENO conveys only a single
bit of information, namely an acknowledgment that the sender received
an ENO option in the other host's SYN segment.  (Such acknowledgments
enable graceful fallback to unencrypted TCP in the event that a
middlebox strips ENO options in one direction.)  <xref target="fig:minimal"/>
illustrates the non-SYN form of the ENO option.  We refer to this form
as an ACK-only ENO option.  Encryption specs MAY include extra bytes
in an ACK-only ENO option, but TCP-ENO itself MUST ignore them.  In
accordance with TCP <xref target="RFC0793"/>, the first two bytes of the ENO option
always consist of the kind (ENO) and the total length of the option.
</t>

<figure anchor="fig:eno" align="center" title="TCP-ENO option in SYN segment (MUST contain at least one
suboption)
"><artwork align="center">
byte    0     1     2     3            2+i  3+i ... N-1
     +-----+-----+-----+-----+--...--+-----+----...----+
     |Kind=|Len= |Opt_0|Opt_1|       |Opt_i|   Opt_i   |
     | ENO |  N  |     |     |       |     |   data    |
     +-----+-----+-----+-----+--...--+-----+----...----+
</artwork></figure>

<figure anchor="fig:minimal" align="center" title="ACK-only TCP-ENO option in non-SYN segment
"><artwork align="center">
byte    0     1                0     1     2     N-1
     +-----+-----+          +-----+-----+-----...----+
     |Kind=|Len= |          |Kind=|Len= |  ignored   |
     | ENO |  2  |    OR    | ENO |  N  | by TCP-ENO |
     +-----+-----+          +-----+-----+-----...----+
</artwork></figure>
<t>Every suboption starts with a byte of the form illustrated in
<xref target="fig:subopt"/>.  The seven-bit value <spanx style="verb">cs</spanx> specifies the meaning of the
suboption.  Each value of <spanx style="verb">cs</spanx> either specifies general parameters
(discussed in <xref target="general-suboptions"/>) or indicates the willingness to
use a specific encryption spec detailed in a separate document.
</t>

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

    v  - 1 when suboption followed by variable-length data
    cs - 7-bit global configuration option or encryption spec
</artwork></figure>
<t>The high bit <spanx style="verb">v</spanx> in a suboption's first byte specifies whether or not
the suboption is followed by variable-length data.  If <spanx style="verb">v</spanx> is 0, the
suboption consists of only the one byte.  If <spanx style="verb">v</spanx> is 1, then the
suboption is followed by variable-length data.  Suboption data MAY be
used for session caching, cipher suite negotiation, key exchange, or
other purposes, as determined by the value of <spanx style="verb">cs</spanx>.
</t>
<t>Every suboption but the last in an ENO option MUST be a one-byte
suboption (with <spanx style="verb">v</spanx> = 0).  The last suboption MAY be a variable-length
suboption.  Its length is determined by the total length of the TCP
option.  In <xref target="fig:eno"/>, <spanx style="verb">Opt_i</spanx> is the variable-length option; its
total size is N-(2+i) bytes--one byte for <spanx style="verb">Opt_i</spanx> itself and N-(3+i)
bytes for additional data.  Multiple suboptions with data may be
included in a single TCP SYN segment by repeating the ENO option.
</t>
<t><xref target="tab:subopt"/> summarizes the allocation of values of <spanx style="verb">cs</spanx>.  Values
under 0x10 are reserved for <spanx style="emph">general suboptions</spanx> whose meaning applies
across encryption specs, as discussed in <xref target="general-suboptions"/>.
Values greater than or equal to 0x20 are are reserved for <spanx style="emph">spec
identifiers</spanx>.  Values in the range 0x10-0x1f are reserved for possible
future general options.  Implementations MUST ignore all unknown
suboptions.
</t>
<texttable anchor="tab:subopt" title="Allocation of cs bits in TCP-ENO suboptions
">
<ttcol align="left">cs</ttcol>
<ttcol align="left">Meaning</ttcol>

<c>0x00-0x0f</c><c>General options (see <xref target="general-suboptions"/>)</c>
<c>0x10-0x1f</c><c>Reserved for possible use by future general options</c>
<c>0x20-0x7f</c><c>Used to designate encryption specs</c>
</texttable>

<section anchor="tcpeno-roles" title="TCP-ENO roles">
<t>TCP-ENO uses abstract roles to distinguish the two ends of a TCP
connection:  One host plays the &quot;A&quot; role, while the other host plays
the &quot;B&quot; role.  Following a normal three-way handshake, the active
opener plays the A role and the passive opener plays the B role.  An
active opener is a host that sends a SYN segment without the ACK flag
set (after a <spanx style="verb">connect</spanx> system call on socket-based systems).  A
passive opener sends a SYN segment with the ACK flag set (after a
<spanx style="verb">listen</spanx> call on socket-based systems).
</t>
<t>Roles are abstracted from the active/passive opener distinction to
deal with simultaneous open, in which both hosts are active openers.
For simultaneous open, the general suboptions discussed in
<xref target="general-suboptions"/> define a tie-breaker bit <spanx style="verb">b</spanx>, where the host
with <spanx style="verb">b = 1</spanx> plays the B role, and the host with <spanx style="verb">b = 0</spanx> plays the A
role.  If two active openers have the same <spanx style="verb">b</spanx> bit, TCP-ENO fails and
reverts to unencrypted TCP.
</t>
<t>More precisely, the above role assignment can be reduced to comparing
a two-bit role <spanx style="emph">priority</spanx> for each host, shown in <xref target="fig:priority"/>.
The most significant bit, <spanx style="verb">p</spanx>, is 1 for a passive opener and 0 for an
active opener.  The least-significant bit <spanx style="verb">b</spanx> is the tie-breaker bit.
The host with the lower priority assumes the A role; the host with the
higher priority assumes the B role.  In the event of a tie, TCP-ENO
fails and MUST continue with unencrypted TCP as if the ENO options had
not been present in SYN segments.
</t>

<figure anchor="fig:priority" align="center" title="Role priority of an endpoint
"><artwork align="center">
bit   1   0
    +---+---+
    | p   b |
    +---+---+

    p - 0 for active opener, 1 for passive opener
    b - b bit from general suboptions sent by host
</artwork></figure>
<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 role A and B respectively in a connection.
</t>
</section>

<section anchor="tcpeno-handshake" title="TCP-ENO handshake">
<t>The TCP-ENO option is intended for use during TCP connection
establishment.  To enable incremental deployment, a host needs to
ensure both that the other host supports TCP-ENO and that no middlebox
has stripped the ENO option from its own TCP segments.  In the event
that either of these conditions does not hold, implementations MUST
immediately cease sending TCP-ENO options and MUST continue with
unencrypted TCP as if the ENO option had not been present.
</t>
<t>More precisely, for negotiation to succeed, the TCP-ENO option MUST be
present in the SYN segment sent by each host, so as to indicate
support for TCP-ENO.  Additionally, the ENO option MUST be present in
the first ACK segment sent by each host, so as to indicate that no
middlebox stripped the ENO option from the ACKed SYN.  Depending on
whether a host is an active or a passive opener, the first ACK segment
may or may not be the same as the SYN segment.  Specifically:
</t>
<t>
<list style="symbols">
<t>An active opener begins with a SYN-only segment, and hence must send
two segments containing ENO options.  The initial SYN-only segment
MUST contain an ENO option with at least one suboption, as pictured in
<xref target="fig:eno"/>.  If ENO succeeds, the active opener's first ACK segment
MUST subsequently contain an ACK-only ENO option, as pictured in
<xref target="fig:minimal"/>.</t>
<t>A passive opener's first transmitted segment has both the SYN and
ACK flags set.  Therefore, a passive opener MUST restrict ENO options
to the single SYN-ACK segment it sends and include an ENO option of
the type shown in <xref target="fig:eno"/>.</t>
</list>
</t>
<t>A spec identifier in one host's SYN segment is <spanx style="emph">valid</spanx> if it is
compatible with a suboption in the other host's SYN segment.  Two
suboptions are <spanx style="emph">compatible</spanx> when they have the same <spanx style="verb">cs</spanx> value (&gt;=
0x20) and when the particular combination of <spanx style="verb">v</spanx> bits and suboption
data in suboptions of the two SYN segments is well-defined by the
corresponding encryption spec.  Specs MAY allow or disallow any
combination of values of <spanx style="verb">v</spanx> in the two SYN segments.
</t>
<t>Once the two sides have exchanged SYN segments, the <spanx style="emph">negotiated spec</spanx>
is the first valid spec identifier in the SYN segment of host B (that
is, the passive opener in the absence of simultaneous open).  In other
words, the order of suboptions in host B's SYN segment determines spec
priority, while the order of suboptions in host A's SYN segment has no
effect.  Hosts must disable TCP-ENO if there is no valid spec in host
B's SYN segment.
</t>
<t>When possible, host B SHOULD send only one spec identifier (suboption
in the range 0x20-0xff), and SHOULD ensure this option is valid.
However, sending a single valid spec identifier is not required, as
doing so could be impractical in some cases, such as simultaneous open
or library-level implementations that can only provide a static
TCP-ENO option to the kernel.
</t>
<t>A host MUST disable ENO if any of the following conditions holds:
</t>
<t>
<list style="numbers">
<t>The host receives a SYN segment without an ENO option,</t>
<t>The host receives a SYN segment that contains no valid encryption
specs when paired with the SYN segment that the host has already sent
or would otherwise have sent,</t>
<t>The host receives a SYN segment containing general suboptions that
are incompatible with the SYN segment that it has already sent or
would otherwise have sent, or</t>
<t>The first ACK segment received by a host does not contain an ENO
option.</t>
</list>
</t>
<t>After disabling ENO, a host MUST NOT transmit any further ENO options
and MUST fall back to unencrypted TCP.
</t>
<t>Conversely, if a host receives an ACK segment containing an ENO
option, then encryption MUST be enabled.  From this point the host
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 anchor="handshake-examples" title="Handshake examples">

<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;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 thee 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, 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;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 the required ACK-only ENO option
in its first ACK 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;X,Y&gt;
(2) B -&gt; A:  SYN  ENO&lt;0x01,Z,Y,X&gt;
(3) A -&gt; B:  ACK  ENO&lt;&gt;
(4) B -&gt; A:  ACK  ENO&lt;&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 an ENO
option (the first SYN and first ACK from each host).  Note the use of
the tie-breaker bit in general suboption 0x01 assigns B its role, as
discussed in <xref target="general-suboptions"/>.
</t>
</section>
</section>

<section anchor="general-suboptions" title="General suboptions">
<t>Suboptions 0x00-0x0f are used for general conditions that apply
regardless of the negotiated encryption spec.  A TCP segment MUST
include at most one suboption whose high nibble is 0.  The value of
the low nibble 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   0   z    aa     b |
    +---+---+---+---+---+-------+---+

    z  - Zero bit (reserved for future use)
    aa - Application-aware bits
    b  - Tie-breaker bit for simultaneous open
</artwork></figure>
<t>The fields of the bitmask are interpreted as follows:
</t>
<t>
<list style="hanging">
<t hangText="z">
The <spanx style="verb">z</spanx> bit is reserved for future revisions of TCP-ENO.  Its value
MUST be set to zero in sent segments and ignored in received segments.</t>
<t hangText="aa">
The two application-aware bits indicate 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.  There are four possible
values, as shown in <xref target="tab:aa"/>.  The default, when applications have
not been modified to take advantage of TCP-ENO, MUST be 00.  However,
implementations SHOULD provide an API through which applications can
set the bits to other values and query for the other host's
application-aware bits.  The values 01 and 10 (binary) indicate that
the application is aware of TCP-ENO.  The distinction between 01 and
10 is left to the application.
<vspace/>

<vspace/>
Value 11 (binary) indicates that an application is aware of TCP-ENO
and requires application awareness from the other side.  If one host
sends value 00 and the other host sends 11, then TCP-ENO MUST be
disabled and fall back to unencrypted TCP.  A possible use of value 11
is for applications that perform legacy encryption and wish to disable
TCP-ENO unless higher-layer encryption can be disabled.</t>
</list>
</t>
<texttable anchor="tab:aa" title="Meaning of the two application-aware bits
">
<ttcol align="right">Value</ttcol>
<ttcol align="left">Meaning</ttcol>

<c>00</c><c>Application is not aware of TCP-ENO</c>
<c>01</c><c>Application is aware of TCP-ENO</c>
<c>10</c><c>Application is aware of TCP-ENO</c>
<c>11</c><c>Application awareness is mandatory for use of TCP-ENO</c>
</texttable>
<t>
<list style="hanging">
<t hangText="b">
This is the tie-breaker bit in role priority, discussed in
<xref target="tcpeno-roles"/>.</t>
</list>
</t>
<t>A SYN segment without an explicit general suboption has an implicit
general suboption of 0x00.
</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 a series of TCP-ENO options (each including the ENO and
length bytes, as they appeared in the TCP header).  Specifically, the
transcript is constructed from the following, in order:
</t>
<t>
<list style="numbers">
<t>Every TCP-ENO option in host A's SYN segment, in the order they
appeared in that SYN segment.</t>
<t>A minimal two-byte ENO option, as shown on the left in
<xref target="fig:minimal"/>.</t>
<t>Every TCP-ENO option in host B's SYN segment, in the order they
appeared in that SYN segment.</t>
<t>A minimal two-byte ENO option, as shown on the left in
<xref target="fig:minimal"/>.</t>
</list>
</t>
<t>Note that 2 and 4 merely serve as delimiters to separate the two
hosts' options from each other and from any data that follows the
transcript.  Note further that any ignored data in ACK-only ENO
options does not appear in the transcript.  Because parts 2 and 4 are
always exactly two bytes and SYN segments MUST NOT contain two-byte
ENO options, this encoding is unambiguous.
</t>
<t>For the transcript to be well defined, hosts MUST NOT alter ENO
options in retransmitted segments, except that an active opener MAY
remove the ENO option altogether from a retransmitted SYN segment and
disable TCP-ENO.  Such removal could be useful if middleboxes are
dropping segments with the ENO option.
</t>
</section>
</section>

<section anchor="requirements-for-encryption-specs" title="Requirements for encryption specs">
<t>TCP-ENO was designed to afford encryption spec authors a large amount
of design flexibility.  Nonetheless, to fit all encryption specs into
a coherent framework and abstract most of the differences away from
application writers, all encryption specs claiming ENO <spanx style="verb">cs</spanx> numbers
MUST satisfy the following properties.
</t>
<t>
<list style="symbols">
<t>Specs MUST always cryptographically protect both the integrity and
confidentiality of TCP data streams.</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 weaker 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 allow the negotiation of encryption modes that do not
provide forward secrecy.</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 with errors.</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 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 first
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.
</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 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>The session ID MUST NOT contain any confidential data (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 anchor="option-kind-sharing" title="Option kind sharing">
<t>This draft specifically prohibits ENO options from appearing in any
segments other than the initial SYN and ACK segments of a connection.
This means any use of the ENO option kind in subsequent segments will
not conflict with TCP-ENO.  Therefore, encryption specs that require
TCP option space MAY re-purpose the ENO option kind for use in
segments after the initial TCP handshake.  As previously stated, specs
MAY also place data in ACK-only ENO options, as shown on the right
side of <xref target="fig:minimal"/>.
</t>
</section>
</section>

<section anchor="api-extensions" title="API extensions">
<t>Implementations SHOULD provide API extensions through which
applications can query and configure the behavior of TCP-ENO,
including retrieving session IDs, setting and reading
application-aware bits, and specifying which specs to negotiate.  The
specifics of such an API are outside the scope of this document.
</t>
</section>

<section anchor="experiments" title="Experiments">
<t>This document has experimental status.  One of the primary open
questions is 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.  However,
if applications do not check and verify the session ID, they will be
open to man-in-the-middle attacks as well as simple downgrade attacks
in which an attacker strips off the TCP-ENO option.  Hence, where
possible, applications SHOULD be modified to fold the session ID into
authentication mechanisms, and SHOULD employ the application-aware
bits as needed to enable such negotiation in a backward-compatible
way.
</t>
<t>Because TCP-ENO enables multiple different encryption specs to
coexist, security could potentially be only as strong as the weakest
available encryption spec.  For this reason, it is crucial for session
IDs to depend on the TCP-ENO transcript in a strong way.  Hence,
encryption specs SHOULD compute session IDs using only well-studied
and conservative hash functions.  Thus, even if an encryption spec is
broken, and even if people deprecate it instead of disabling it, and
even if an attacker tampers with ENO options to force negotiation of
the broken spec, it should still be intractable for the attacker to
induce identical session IDs at both hosts.
</t>
<t>Implementations MUST not send ENO options unless encryption specs have
access to a strong source of randomness or pseudo-randomness.  Without
secret unpredictable data at both ends of a connection, it is
impossible for encryption specs to meet the confidentiality and
forward secrecy requirements required of them.
</t>
</section>

<section anchor="iana-considerations" title="IANA Considerations">
<t>A new TCP option kind number needs to be assigned to ENO by IANA.
</t>
<t>In addition, 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>This work was funded by DARPA CRASH under contract #N66001-10-2-4088.
</t>
</section>

</middle>
<back>
<references title="Normative References">
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.0793.xml"?>
</references>
<references title="Informative References">
<?rfc include="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-tls-tls13-07.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.7413.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.3493.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6394.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-tcpm-tcp-edo-03.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-briscoe-tcpm-inspace-mode-tcpbis-00.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-touch-tcpm-tcp-syn-ext-opt-02.xml"?>
</references>

</back>
</rfc>
