draft-ietf-tcpinc-tcpcrypt-10.txt   draft-ietf-tcpinc-tcpcrypt-11.txt 
Network Working Group A. Bittau Network Working Group A. Bittau
Internet-Draft Google Internet-Draft Google
Intended status: Experimental D. Giffin Intended status: Experimental D. Giffin
Expires: May 21, 2018 Stanford University Expires: June 3, 2018 Stanford University
M. Handley M. Handley
University College London University College London
D. Mazieres D. Mazieres
Stanford University Stanford University
Q. Slack Q. Slack
Sourcegraph Sourcegraph
E. Smith E. Smith
Kestrel Institute Kestrel Institute
November 17, 2017 November 30, 2017
Cryptographic protection of TCP Streams (tcpcrypt) Cryptographic protection of TCP Streams (tcpcrypt)
draft-ietf-tcpinc-tcpcrypt-10 draft-ietf-tcpinc-tcpcrypt-11
Abstract Abstract
This document specifies tcpcrypt, a TCP encryption protocol designed This document specifies tcpcrypt, a TCP encryption protocol designed
for use in conjunction with the TCP Encryption Negotiation Option for use in conjunction with the TCP Encryption Negotiation Option
(TCP-ENO). Tcpcrypt coexists with middleboxes by tolerating (TCP-ENO). Tcpcrypt coexists with middleboxes by tolerating
resegmentation, NATs, and other manipulations of the TCP header. The resegmentation, NATs, and other manipulations of the TCP header. The
protocol is self-contained and specifically tailored to TCP protocol is self-contained and specifically tailored to TCP
implementations, which often reside in kernels or other environments implementations, which often reside in kernels or other environments
in which large external software dependencies can be undesirable. in which large external software dependencies can be undesirable.
skipping to change at page 2, line 4 skipping to change at page 2, line 4
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on May 21, 2018. This Internet-Draft will expire on June 3, 2018.
Copyright Notice Copyright Notice
Copyright (c) 2017 IETF Trust and the persons identified as the Copyright (c) 2017 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 2, line 33 skipping to change at page 2, line 33
1. Requirements Language . . . . . . . . . . . . . . . . . . . . 3 1. Requirements Language . . . . . . . . . . . . . . . . . . . . 3
2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
3. Encryption Protocol . . . . . . . . . . . . . . . . . . . . . 3 3. Encryption Protocol . . . . . . . . . . . . . . . . . . . . . 3
3.1. Cryptographic Algorithms . . . . . . . . . . . . . . . . 3 3.1. Cryptographic Algorithms . . . . . . . . . . . . . . . . 3
3.2. Protocol Negotiation . . . . . . . . . . . . . . . . . . 5 3.2. Protocol Negotiation . . . . . . . . . . . . . . . . . . 5
3.3. Key Exchange . . . . . . . . . . . . . . . . . . . . . . 6 3.3. Key Exchange . . . . . . . . . . . . . . . . . . . . . . 6
3.4. Session ID . . . . . . . . . . . . . . . . . . . . . . . 9 3.4. Session ID . . . . . . . . . . . . . . . . . . . . . . . 9
3.5. Session Resumption . . . . . . . . . . . . . . . . . . . 9 3.5. Session Resumption . . . . . . . . . . . . . . . . . . . 9
3.6. Data Encryption and Authentication . . . . . . . . . . . 12 3.6. Data Encryption and Authentication . . . . . . . . . . . 12
3.7. TCP Header Protection . . . . . . . . . . . . . . . . . . 14 3.7. TCP Header Protection . . . . . . . . . . . . . . . . . . 14
3.8. Re-Keying . . . . . . . . . . . . . . . . . . . . . . . . 14 3.8. Re-Keying . . . . . . . . . . . . . . . . . . . . . . . . 15
3.9. Keep-Alive . . . . . . . . . . . . . . . . . . . . . . . 15 3.9. Keep-Alive . . . . . . . . . . . . . . . . . . . . . . . 16
4. Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4. Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1. Key-Exchange Messages . . . . . . . . . . . . . . . . . . 16 4.1. Key-Exchange Messages . . . . . . . . . . . . . . . . . . 16
4.2. Encryption Frames . . . . . . . . . . . . . . . . . . . . 18 4.2. Encryption Frames . . . . . . . . . . . . . . . . . . . . 18
4.2.1. Plaintext . . . . . . . . . . . . . . . . . . . . . . 18 4.2.1. Plaintext . . . . . . . . . . . . . . . . . . . . . . 19
4.2.2. Associated Data . . . . . . . . . . . . . . . . . . . 19 4.2.2. Associated Data . . . . . . . . . . . . . . . . . . . 20
4.2.3. Frame ID . . . . . . . . . . . . . . . . . . . . . . 19 4.2.3. Frame ID . . . . . . . . . . . . . . . . . . . . . . 20
4.3. Constant Values . . . . . . . . . . . . . . . . . . . . . 20 4.3. Constant Values . . . . . . . . . . . . . . . . . . . . . 20
5. Key-Agreement Schemes . . . . . . . . . . . . . . . . . . . . 20 5. Key-Agreement Schemes . . . . . . . . . . . . . . . . . . . . 21
6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . . . 21 6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . . . 22
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 22 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23
8. Security Considerations . . . . . . . . . . . . . . . . . . . 23 8. Security Considerations . . . . . . . . . . . . . . . . . . . 24
8.1. Asymmetric Roles . . . . . . . . . . . . . . . . . . . . 24 8.1. Asymmetric Roles . . . . . . . . . . . . . . . . . . . . 25
8.2. Verified Liveness . . . . . . . . . . . . . . . . . . . . 25 8.2. Verified Liveness . . . . . . . . . . . . . . . . . . . . 26
8.3. Mandatory Key-Agreement Schemes . . . . . . . . . . . . . 25 8.3. Mandatory Key-Agreement Schemes . . . . . . . . . . . . . 26
9. Experiments . . . . . . . . . . . . . . . . . . . . . . . . . 26 9. Experiments . . . . . . . . . . . . . . . . . . . . . . . . . 27
10. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 27 10. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 28
11. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 27 11. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 28
12. References . . . . . . . . . . . . . . . . . . . . . . . . . 27 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 28
12.1. Normative References . . . . . . . . . . . . . . . . . . 27 12.1. Normative References . . . . . . . . . . . . . . . . . . 28
12.2. Informative References . . . . . . . . . . . . . . . . . 28 12.2. Informative References . . . . . . . . . . . . . . . . . 29
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 29 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 30
1. Requirements Language 1. Requirements Language
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP "OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
2. Introduction 2. Introduction
skipping to change at page 4, line 26 skipping to change at page 4, line 26
typically the output of the extract function. The CPRF produces typically the output of the extract function. The CPRF produces
an arbitrary amount of Output Keying Material (OKM), and we use an arbitrary amount of Output Keying Material (OKM), and we use
the notation CPRF(K, CONST, L) to designate the first L bytes of the notation CPRF(K, CONST, L) to designate the first L bytes of
the OKM produced by the CPRF when parameterized by key K and the the OKM produced by the CPRF when parameterized by key K and the
constant CONST. constant CONST.
The Extract and CPRF functions used by the tcpcrypt variants defined The Extract and CPRF functions used by the tcpcrypt variants defined
in this document are the Extract and Expand functions of HKDF in this document are the Extract and Expand functions of HKDF
[RFC5869], which is built on HMAC [RFC2104]. These are defined as [RFC5869], which is built on HMAC [RFC2104]. These are defined as
follows in terms of the function "HMAC-Hash(key, value)" for a follows in terms of the function "HMAC-Hash(key, value)" for a
negotiated "Hash" function such as SHA-256; the symbol | denotes negotiated "Hash" function such as SHA-256; the symbol "|" denotes
concatenation, and the counter concatenated to the right of CONST concatenation, and the counter concatenated to the right of CONST
occupies a single octet. occupies a single octet.
HKDF-Extract(salt, IKM) -> PRK HKDF-Extract(salt, IKM) -> PRK
PRK = HMAC-Hash(salt, IKM) PRK = HMAC-Hash(salt, IKM)
HKDF-Expand(PRK, CONST, L) -> OKM HKDF-Expand(PRK, CONST, L) -> OKM
T(0) = empty string (zero length) T(0) = empty string (zero length)
T(1) = HMAC-Hash(PRK, T(0) | CONST | 0x01) T(1) = HMAC-Hash(PRK, T(0) | CONST | 0x01)
T(2) = HMAC-Hash(PRK, T(1) | CONST | 0x02) T(2) = HMAC-Hash(PRK, T(1) | CONST | 0x02)
skipping to change at page 5, line 27 skipping to change at page 5, line 27
An active opener that wishes to negotiate the use of tcpcrypt An active opener that wishes to negotiate the use of tcpcrypt
includes an ENO option in its SYN segment. That option includes includes an ENO option in its SYN segment. That option includes
suboptions with tcpcrypt TEP identifiers indicating the key-agreement suboptions with tcpcrypt TEP identifiers indicating the key-agreement
schemes it is willing to enable. The active opener MAY additionally schemes it is willing to enable. The active opener MAY additionally
include suboptions indicating support for encryption protocols other include suboptions indicating support for encryption protocols other
than tcpcrypt, as well as global suboptions as specified by TCP-ENO. than tcpcrypt, as well as global suboptions as specified by TCP-ENO.
If a passive opener receives an ENO option including tcpcrypt TEPs it If a passive opener receives an ENO option including tcpcrypt TEPs it
supports, it MAY then attach an ENO option to its SYN-ACK segment, supports, it MAY then attach an ENO option to its SYN-ACK segment,
including _solely_ the TEP it wishes to enable. including solely the TEP it wishes to enable.
To establish distinct roles for the two hosts in each connection, To establish distinct roles for the two hosts in each connection,
tcpcrypt depends on the role-negotiation mechanism of TCP-ENO. As tcpcrypt depends on the role-negotiation mechanism of TCP-ENO. As
one result of the negotiation process, TCP-ENO assigns hosts unique one result of the negotiation process, TCP-ENO assigns hosts unique
roles abstractly called "A" at one end of the connection and "B" at roles abstractly called "A" at one end of the connection and "B" at
the other. Generally, an active opener plays the "A" role and a the other. Generally, an active opener plays the "A" role and a
passive opener plays the "B" role; but in the case of simultaneous passive opener plays the "B" role; but in the case of simultaneous
open, an additional mechanism breaks the symmetry and assigns a open, an additional mechanism breaks the symmetry and assigns a
distinct role to each host. TCP-ENO uses the terms "host A" and distinct role to each host. TCP-ENO uses the terms "host A" and
"host B" to identify each end of a connection uniquely, and this "host B" to identify each end of a connection uniquely, and this
skipping to change at page 6, line 42 skipping to change at page 6, line 42
when resumption was negotiated (described below in Section 3.5), the when resumption was negotiated (described below in Section 3.5), the
two hosts perform key exchange through two messages, "Init1" and two hosts perform key exchange through two messages, "Init1" and
"Init2", at the start of the data streams of host A and host B, "Init2", at the start of the data streams of host A and host B,
respectively. These messages may span multiple TCP segments and need respectively. These messages may span multiple TCP segments and need
not end at a segment boundary. However, the segment containing the not end at a segment boundary. However, the segment containing the
last byte of an "Init1" or "Init2" message MUST have TCP's push flag last byte of an "Init1" or "Init2" message MUST have TCP's push flag
(PSH) set. (PSH) set.
The key exchange protocol, in abstract, proceeds as follows: The key exchange protocol, in abstract, proceeds as follows:
A -> B: Init1 = { INIT1_MAGIC, sym_cipher_list, N_A, PK_A } A -> B: Init1 = { INIT1_MAGIC, sym_cipher_list, N_A, Pub_A }
B -> A: Init2 = { INIT2_MAGIC, sym_cipher, N_B, PK_B } B -> A: Init2 = { INIT2_MAGIC, sym_cipher, N_B, Pub_B }
The concrete format of these messages is specified in Section 4.1. The concrete format of these messages is specified in Section 4.1.
The parameters are defined as follows: The parameters are defined as follows:
o "INIT1_MAGIC", "INIT2_MAGIC": constants defined in Section 4.3. o "INIT1_MAGIC", "INIT2_MAGIC": constants defined in Section 4.3.
o "sym_cipher_list": a list of symmetric ciphers (AEAD algorithms) o "sym_cipher_list": a list of identifiers of symmetric ciphers
acceptable to host A. These are specified in Table 5 in (AEAD algorithms) acceptable to host A. These are specified in
Section 7. Table 5 in Section 7.
o "sym_cipher": the symmetric cipher selected by host B from the o "sym_cipher": the symmetric cipher selected by host B from the
"sym_cipher_list" sent by host A. "sym_cipher_list" sent by host A.
o "N_A", "N_B": nonces chosen at random by hosts A and B, o "N_A", "N_B": nonces chosen at random by hosts A and B,
respectively. respectively.
o "PK_A", "PK_B": ephemeral public keys for hosts A and B, o "Pub_A", "Pub_B": ephemeral public keys for hosts A and B,
respectively. These, as well as their corresponding private keys, respectively. These, as well as their corresponding private keys,
are short-lived values that MUST be refreshed as frequently as are short-lived values that MUST be refreshed as frequently as
practically possible. The private keys SHOULD NOT ever be written practically possible. The private keys SHOULD NOT ever be written
to persistent storage. The security risks associated with the to persistent storage. The security risks associated with the
storage of these keys are discussed in Section 8. storage of these keys are discussed in Section 8.
If a host receives an ephemeral public key from its peer and a If a host receives an ephemeral public key from its peer and a
required key-validation step fails (see Section 5), it MUST abort the required key-validation step fails (see Section 5), it MUST abort the
connection and raise an error condition distinct from the end-of-file connection and raise an error condition distinct from the end-of-file
condition. condition.
The ephemeral secret ("ES") is the result of the key-agreement The ephemeral secret "ES" is the result of the key-agreement
algorithm (see Section 5) indicated by the negotiated TEP. The algorithm (see Section 5) indicated by the negotiated TEP. The
inputs to the algorithm are the local host's ephemeral private key inputs to the algorithm are the local host's ephemeral private key
and the remote host's ephemeral public key. For example, host A and the remote host's ephemeral public key. For example, host A
would compute "ES" using its own private key (not transmitted) and would compute "ES" using its own private key (not transmitted) and
host B's public key, "PK_B". host B's public key, "Pub_B".
The two sides then compute a pseudo-random key ("PRK"), from which The two sides then compute a pseudo-random key "PRK", from which all
all session keys are derived, as follows: session secrets are derived, as follows:
PRK = Extract(N_A, eno-transcript | Init1 | Init2 | ES) PRK = Extract(N_A, eno-transcript | Init1 | Init2 | ES)
Above, "|" denotes concatenation; "eno-transcript" is the protocol- Above, "|" denotes concatenation; "eno-transcript" is the protocol-
negotiation transcript defined in Section 4.8 of negotiation transcript defined in Section 4.8 of
[I-D.ietf-tcpinc-tcpeno]; and "Init1" and "Init2" are the transmitted [I-D.ietf-tcpinc-tcpeno]; and "Init1" and "Init2" are the transmitted
encodings of the messages described in Section 4.1. encodings of the messages described in Section 4.1.
A series of "session secrets" are then computed from "PRK" as A series of "session secrets" are then computed from "PRK" as
follows: follows:
skipping to change at page 8, line 21 skipping to change at page 8, line 21
mk[0] = CPRF(ss[i], CONST_REKEY, K_LEN) mk[0] = CPRF(ss[i], CONST_REKEY, K_LEN)
mk[j] = CPRF(mk[j-1], CONST_REKEY, K_LEN) mk[j] = CPRF(mk[j-1], CONST_REKEY, K_LEN)
The process of advancing through the series of master keys is The process of advancing through the series of master keys is
described in Section 3.8. described in Section 3.8.
Finally, each master key "mk[j]" is used to generate traffic keys for Finally, each master key "mk[j]" is used to generate traffic keys for
protecting application data using authenticated encryption: protecting application data using authenticated encryption:
k_ab[j] = CPRF(mk[j], CONST_KEY_A, ae_keylen + 12) k_ab[j] = CPRF(mk[j], CONST_KEY_A, ae_key_len + ae_nonce_len)
k_ba[j] = CPRF(mk[j], CONST_KEY_B, ae_keylen + 12) k_ba[j] = CPRF(mk[j], CONST_KEY_B, ae_key_len + ae_nonce_len)
In the first session derived from fresh key-agreement, traffic keys In the first session derived from fresh key-agreement, traffic keys
"k_ab[j]" are used by host A to encrypt and host B to decrypt, while "k_ab[j]" are used by host A to encrypt and host B to decrypt, while
keys "k_ba[j]" are used by host B to encrypt and host A to decrypt. keys "k_ba[j]" are used by host B to encrypt and host A to decrypt.
In a resumed session, as described more thoroughly below in In a resumed session, as described more thoroughly below in
Section 3.5, each host uses the keys in the same way as it did in the Section 3.5, each host uses the keys in the same way as it did in the
original session, regardless of its role in the current session: for original session, regardless of its role in the current session: for
example, if a host played role "A" in the first session, it will use example, if a host played role "A" in the first session, it will use
keys "k_ab[j]" to encrypt in each derived session. keys "k_ab[j]" to encrypt in each derived session.
The value "ae_keylen" depends on the authenticated-encryption The values "ae_key_len" and "ae_nonce_len" depend on the
algorithm selected, and is given under "Key Length" in Table 5 in authenticated-encryption algorithm selected, and are given in Table 3
Section 7. The algorithm uses the first "ae_keylen" bytes of each in Section 6. The algorithm uses the first "ae_key_len" bytes of
traffic key as an authenticated-encryption key, and the following 12 each traffic key as an authenticated-encryption key, and the
bytes as a "nonce randomizer". following "ae_nonce_len" bytes as a "nonce randomizer".
Implementations SHOULD provide an interface allowing the user to
specify, for a particular connection, the set of AEAD algorithms to
advertize in "sym_cipher_list" (when playing role "A") and also the
order of preference to use when selecting an algorithm from those
offered (when playing role "B"). A companion document
[I-D.ietf-tcpinc-api] describes recommended interfaces for this
purpose.
After host B sends "Init2" or host A receives it, that host may After host B sends "Init2" or host A receives it, that host may
immediately begin transmitting protected application data as immediately begin transmitting protected application data as
described in Section 3.6. described in Section 3.6.
If host A receives "Init2" with a "sym_cipher" value that was not If host A receives "Init2" with a "sym_cipher" value that was not
present in the "sym_cipher_list" it previously transmitted in present in the "sym_cipher_list" it previously transmitted in
"Init1", it MUST abort the connection and raise an error condition "Init1", it MUST abort the connection and raise an error condition
distinct from the end-of-file condition. distinct from the end-of-file condition.
skipping to change at page 9, line 42 skipping to change at page 10, line 5
The resumption identifier is calculated from a session secret "ss[i]" The resumption identifier is calculated from a session secret "ss[i]"
as follows: as follows:
resume[i] = CPRF(ss[i], CONST_RESUME, 18) resume[i] = CPRF(ss[i], CONST_RESUME, 18)
To name a session for resumption, a host sends either the first or To name a session for resumption, a host sends either the first or
second half of the resumption identifier, according to the role it second half of the resumption identifier, according to the role it
played in the original session with secret "ss[0]". played in the original session with secret "ss[0]".
A host that originally played role A and wishes to resume from a A host that originally played role "A" and wishes to resume from a
cached session sends a suboption with the first half of the cached session sends a suboption with the first half of the
resumption identifier: resumption identifier:
byte 0 1 9 (10 bytes total) byte 0 1 9 (10 bytes total)
+--------+--------+---...---+--------+ +--------+--------+---...---+--------+
| TEP- | resume[i]{0..8} | | TEP- | resume[i]{0..8} |
| byte | | | byte | |
+--------+--------+---...---+--------+ +--------+--------+---...---+--------+
Figure 2: Resumption suboption sent when original role was A. The Figure 2: Resumption suboption sent when original role was "A". The
TEP-byte contains a tcpcrypt TEP identifier and v = 1. TEP-byte contains a tcpcrypt TEP identifier and v = 1.
Similarly, a host that originally played role B sends a suboption Similarly, a host that originally played role "B" sends a suboption
with the second half of the resumption identifier: with the second half of the resumption identifier:
byte 0 1 9 (10 bytes total) byte 0 1 9 (10 bytes total)
+--------+--------+---...---+--------+ +--------+--------+---...---+--------+
| TEP- | resume[i]{9..17} | | TEP- | resume[i]{9..17} |
| byte | | | byte | |
+--------+--------+---...---+--------+ +--------+--------+---...---+--------+
Figure 3: Resumption suboption sent when original role was B. The Figure 3: Resumption suboption sent when original role was "B". The
TEP-byte contains a tcpcrypt TEP identifier and v = 1. TEP-byte contains a tcpcrypt TEP identifier and v = 1.
If a passive opener receives a resumption suboption containing an If a passive opener receives a resumption suboption containing an
identifier-half that names a session secret that it has cached and identifier-half that names a session secret that it has cached and
the subobtion's TEP matches the TEP used in the previous session, it the subobtion's TEP matches the TEP used in the previous session, it
SHOULD (with exceptions specified below) agree to resume from the SHOULD (with exceptions specified below) agree to resume from the
cached session by sending its own resumption suboption, which will cached session by sending its own resumption suboption, which will
contain the other half of the identifier. Otherwise, it MUST NOT contain the other half of the identifier. Otherwise, it MUST NOT
agree to resumption. agree to resumption.
If the passive opener does not agree to resumption with a particular If a passive opener does not agree to resumption with a particular
TEP, it may either request fresh key exchange by responding with a TEP, it may either request fresh key exchange by responding with a
non-resumption suboption using the same TEP, or else respond to any non-resumption suboption using the same TEP, or else respond to any
other received suboption. other received suboption.
If a passive opener receives an ENO suboption with a TEP identifier
and "v = 1", but the suboption data does not have length 9 bytes, it
MUST behave as if the same TEP had been sent with "v = 0". That is,
the suboption MUST be interpreted as an offer to negotiate fresh key
exchange with that TEP.
If an active opener sends a resumption suboption with a particular If an active opener sends a resumption suboption with a particular
TEP and the appropriate half of a resumption identifier and then, in TEP and the appropriate half of a resumption identifier and then, in
the same TCP handshake, receives a resumption suboption with the same the same TCP handshake, receives a resumption suboption with the same
TEP and an identifier-half that does _not_ match that resumption TEP and an identifier-half that does not match that resumption
identifier, it MUST ignore that suboption. In the typical case that identifier, it MUST ignore that suboption. In the typical case that
this was the only ENO suboption received, this means the host MUST this was the only ENO suboption received, this means the host MUST
disable TCP-ENO and tcpcrypt: that is, it MUST NOT send any more ENO disable TCP-ENO and tcpcrypt: that is, it MUST NOT send any more ENO
options and MUST NOT encrypt the connection. options and MUST NOT encrypt the connection.
When a host concludes that TCP-ENO negotiation has succeeded for some When a host concludes that TCP-ENO negotiation has succeeded for some
TEP that was received in a resumption suboption, it MUST then enable TEP that was received in a resumption suboption, it MUST then enable
encryption with that TEP, using the cached session secret, as encryption with that TEP, using the cached session secret, as
described in Section 3.6. described in Section 3.6.
skipping to change at page 11, line 23 skipping to change at page 11, line 32
session. session.
In a particular SYN segment, a host SHOULD NOT send more than one In a particular SYN segment, a host SHOULD NOT send more than one
resumption suboption (because this consumes TCP option space and is resumption suboption (because this consumes TCP option space and is
unlikely to be a useful practice), and MUST NOT send more than one unlikely to be a useful practice), and MUST NOT send more than one
resumption suboption with the same TEP identifier. But in addition resumption suboption with the same TEP identifier. But in addition
to any resumption suboptions, an active opener MAY include non- to any resumption suboptions, an active opener MAY include non-
resumption suboptions describing other TEPs it supports (in addition resumption suboptions describing other TEPs it supports (in addition
to the TEP in the resumption suboption). to the TEP in the resumption suboption).
After using "ss[i]" to compute "mk[0]", implementations SHOULD After using the session secret "ss[i]" to compute "mk[0]",
compute and cache "ss[i+1]" for possible use by a later session, then implementations SHOULD compute and cache "ss[i+1]" for possible use
erase "ss[i]" from memory. Hosts SHOULD retain "ss[i+1]" until it is by a later session, then erase "ss[i]" from memory. Hosts SHOULD
used or the memory needs to be reclaimed. Hosts SHOULD NOT write a retain "ss[i+1]" until it is used or the memory needs to be
cached "ss[i+1]" value to non-volatile storage. reclaimed. Hosts SHOULD NOT write any session secrets to non-
volatile storage.
When proposing resumption, the active opener MUST use the lowest When proposing resumption, the active opener MUST use the lowest
value of "i" that has not already been used (successfully or not) to value of "i" that has not already been used (successfully or not) to
negotiate resumption with the same host and for the same pre-session negotiate resumption with the same host and for the same original
key "ss[0]". session secret "ss[0]".
A session secret may not be used to secure more than one TCP A session secret may not be used to secure more than one TCP
connection. To prevent this, a host MUST NOT resume with a session connection. To prevent this, a host MUST NOT resume with a session
secret if it has ever enabled encryption in the past with the same secret if it has ever enabled encryption in the past with the same
secret, in either role. In the event that two hosts simultaneously secret, in either role. In the event that two hosts simultaneously
send SYN segments to each other that propose resumption with the same send SYN segments to each other that propose resumption with the same
session secret but the two segments are not part of a simultaneous session secret but the two segments are not part of a simultaneous
open, both connections will have to revert to fresh key-exchange. To open, both connections will have to revert to fresh key-exchange. To
avoid this limitation, implementations MAY choose to implement avoid this limitation, implementations MAY choose to implement
session resumption such that a given pre-session key "ss[0]" is only session resumption such that all session secrets derived from a given
used for either passive or active opens at the same host, not both. "ss[0]" are used for either passive or active opens at the same host,
not both.
If two hosts have previously negotiated a tcpcrypt session, either If two hosts have previously negotiated a tcpcrypt session, either
host may later initiate session resumption regardless of which host host may later initiate session resumption regardless of which host
was the active opener or played the "A" role in the previous session. was the active opener or played the "A" role in the previous session.
However, a given host must either encrypt with keys "k_ab[j]" for all However, a given host must either encrypt with keys "k_ab[j]" for all
sessions derived from the same pre-session key "ss[0]", or with keys sessions derived from the same original session secret "ss[0]", or
"k_ba[j]". Thus, which keys a host uses to send segments is not with keys "k_ba[j]". Thus, which keys a host uses to send segments
affected by the role it plays in the current connection: it depends is not affected by the role it plays in the current connection: it
only on whether the host played the "A" or "B" role in the initial depends only on whether the host played the "A" or "B" role in the
session. initial session.
Implementations that cache session secrets MUST provide a means for Implementations that cache session secrets MUST provide a means for
applications to control that caching. In particular, when an applications to control that caching. In particular, when an
application requests a new TCP connection, it must be able to specify application requests a new TCP connection, it must be able to specify
that during the connection no session secrets will be cached and all two policies for the duration of the connection: 1) that resumption
resumption requests will be ignored in favor of fresh key exchange. requests will be ignored, and thus fresh key exchange will be
And for an established connection, an application must be able to required; and 2) that no session secrets will be cached. (These
cause any cache state that was used in or resulted from establishing policies may be specified independently or as a unit.) And for an
the connection to be flushed. A companion document established connection, an application must be able to cause any
[I-D.ietf-tcpinc-api] describes recommended interfaces for this cache state that was used in or resulted from establishing the
purpose. connection to be flushed. A companion document [I-D.ietf-tcpinc-api]
describes recommended interfaces for this purpose.
3.6. Data Encryption and Authentication 3.6. Data Encryption and Authentication
Following key exchange (or its omission via session resumption), all Following key exchange (or its omission via session resumption), all
further communication in a tcpcrypt-enabled connection is carried out further communication in a tcpcrypt-enabled connection is carried out
within delimited _encryption frames_ that are encrypted and within delimited _encryption frames_ that are encrypted and
authenticated using the agreed keys. authenticated using the agreed keys.
This protection is provided via algorithms for Authenticated This protection is provided via algorithms for Authenticated
Encryption with Associated Data (AEAD). The particular algorithms Encryption with Associated Data (AEAD). The particular algorithms
that may be used are listed in Table 5 in Section 7, and additional that may be used are listed in Table 5 in Section 7. Additional
algorithms may be specified according to the policy in that section. algorithms may be specified according to the policy in that section.
One algorithm is selected during the negotiation described in One algorithm is selected during the negotiation described in
Section 3.3. Section 3.3. The lengths "ae_key_len" and "ae_nonce_len" associated
with each algorithm are found in Table 3 in Section 6, together with
requirements for which algorithms must be implemented.
The format of an encryption frame is specified in Section 4.2. A The format of an encryption frame is specified in Section 4.2. A
sending host breaks its stream of application data into a series of sending host breaks its stream of application data into a series of
chunks. Each chunk is placed in the "data" portion of a "plaintext" chunks. Each chunk is placed in the "data" portion of a "plaintext"
value, which is then encrypted to yield a frame's "ciphertext" field. value, which is then encrypted to yield a frame's "ciphertext" field.
Chunks must be small enough that the ciphertext (whose length depends Chunks must be small enough that the ciphertext (whose length depends
on the AEAD cipher used, and is generally slightly longer than the on the AEAD cipher used, and is generally slightly longer than the
plaintext) has length less than 2^16 bytes. plaintext) has length less than 2^16 bytes.
An "associated data" value (see Section 4.2.2) is constructed for the An "associated data" value (see Section 4.2.2) is constructed for the
frame. It contains the frame's "control" field and the length of the frame. It contains the frame's "control" field and the length of the
ciphertext. ciphertext.
A "frame ID" value (see Section 4.2.3) is also constructed for the A "frame ID" value (see Section 4.2.3) is also constructed for the
frame but not explicitly transmitted. It contains an "offset" field frame, but not explicitly transmitted. It contains a 64-bit "offset"
whose integer value is the zero-indexed byte offset of the beginning field whose integer value is the zero-indexed byte offset of the
of the current encryption frame in the underlying TCP datastream. beginning of the current encryption frame in the underlying TCP
(That is, the offset in the framing stream, not the plaintext datastream. (That is, the offset in the framing stream, not the
application stream.) Because it is strictly necessary for the plaintext application stream.) The offset is then left-padded with
security of the AEAD algorithms specified in this document, an zero-valued bytes to form a value of length "ae_nonce_len". Because
implementation MUST NOT ever transmit distinct frames with the same it is strictly necessary for the security of the AEAD algorithms
frame ID value under the same encryption key. In particular, a specified in this document, an implementation MUST NOT ever transmit
retransmitted TCP segment MUST contain the same payload bytes for the distinct frames with the same frame ID value under the same
same TCP sequence numbers, and a host MUST NOT transmit more than encryption key. In particular, a retransmitted TCP segment MUST
2^64 bytes in the underlying TCP datastream (which would cause the contain the same payload bytes for the same TCP sequence numbers, and
"offset" field to wrap) before re-keying. a host MUST NOT transmit more than 2^64 bytes in the underlying TCP
datastream (which would cause the "offset" field to wrap) before re-
keying as decribed in Section 3.8.
With reference to the "AEAD Interface" described in Section 2 of With reference to the "AEAD Interface" described in Section 2 of
[RFC5116], tcpcrypt invokes the AEAD algorithm with values taken from [RFC5116], tcpcrypt invokes the AEAD algorithm with values taken from
the traffic key "k_ab[j]" or "k_ba[j]" for some "j", according to the the traffic key "k_ab[j]" or "k_ba[j]" for some "j", according to the
host's role as described in Section 3.3. host's role as described in Section 3.3.
First, the traffic key is divided into two parts: First, the traffic key is divided into two parts:
byte 0 ae_keylen ae_keylen + 11 ae_key_len + ae_nonce_len - 1
| | | |
v v v byte 0 ae_key_len |
+----+----+--...--+----+----+----+--...--+----+ | | |
| K | NR | v v v
+----+----+--...--+----+----+----+--...--+----+ +----+----+--...--+----+----+----+--...--+----+
| K | NR |
+----+----+--...--+----+----+----+--...--+----+
\_____________________________________________/ \_____________________________________________/
traffic key traffic key
The first "ae_keylen" bytes of the traffic key provide the AEAD key The first "ae_key_len" bytes of the traffic key provide the AEAD key
"K", while the remaining 12 bytes provide a "nonce randomizer" value "K", while the remaining "ae_nonce_len" bytes provide a "nonce
"NR". The frame ID is then combined via bitwise exclusive-or with randomizer" value "NR". The frame ID is then combined via bitwise
the nonce randomizer to yield "N", the AEAD nonce for the frame: exclusive-or with the nonce randomizer to yield "N", the AEAD nonce
for the frame:
N = frame_ID xor NR N = frame_ID xor NR
The plaintext value serves as "P", and the associated data as "A". The plaintext value serves as "P", and the associated data as "A".
The output of the encryption operation, "C", is transmitted in the The output of the encryption operation, "C", is transmitted in the
frame's "ciphertext" field. frame's "ciphertext" field.
When a frame is received, tcpcrypt reconstructs the associated data When a frame is received, tcpcrypt reconstructs the associated data
and frame ID values (the former contains only data sent in the clear, and frame ID values (the former contains only data sent in the clear,
and the latter is implicit in the TCP stream), computes the nonce N and the latter is implicit in the TCP stream), computes the nonce "N"
as above, and provides these and the ciphertext value to the the AEAD as above, and provides these and the ciphertext value to the AEAD
decryption operation. The output of this operation is either a decryption operation. The output of this operation is either a
plaintext value "P" or the special symbol FAIL. In the latter case, plaintext value "P" or the special symbol FAIL. In the latter case,
the implementation SHOULD abort the connection and raise an error the implementation SHOULD abort the connection and raise an error
condition distinct from the end-of-file condition. But if none of condition distinct from the end-of-file condition. But if none of
the TCP segment(s) containing the frame have been acknowledged and the TCP segment(s) containing the frame have been acknowledged and
retransmission could potentially result in a valid frame, an retransmission could potentially result in a valid frame, an
implementation MAY instead drop these segments. implementation MAY instead drop these segments (and "renege" if they
have been SACKed, according to [RFC2018] Section 8).
3.7. TCP Header Protection 3.7. TCP Header Protection
The "ciphertext" field of the encryption frame contains protected The "ciphertext" field of the encryption frame contains protected
versions of certain TCP header values. versions of certain TCP header values.
When the "URGp" bit is set, the "urgent" value indicates an offset When the "URGp" bit is set, the "urgent" value indicates an offset
from the current frame's beginning offset; the sum of these offsets from the current frame's beginning offset; the sum of these offsets
gives the index of the last byte of urgent data in the application gives the index of the last byte of urgent data in the application
datastream. datastream.
skipping to change at page 14, line 30 skipping to change at page 14, line 49
tcpcrypt means setting FIN on the segment containing the last byte of tcpcrypt means setting FIN on the segment containing the last byte of
the last frame. However, a receiver MUST report the end-of-file the last frame. However, a receiver MUST report the end-of-file
condition to the connection's local user when and only when it condition to the connection's local user when and only when it
receives a frame with the "FINp" bit set. If a host receives a receives a frame with the "FINp" bit set. If a host receives a
segment with the TCP FIN flag set but the received datastream segment with the TCP FIN flag set but the received datastream
including this segment does not contain a frame with "FINp" set, the including this segment does not contain a frame with "FINp" set, the
host SHOULD abort the connection and raise an error condition host SHOULD abort the connection and raise an error condition
distinct from the end-of-file condition. But if there are distinct from the end-of-file condition. But if there are
unacknowledged segments whose retransmission could potentially result unacknowledged segments whose retransmission could potentially result
in a valid frame, the host MAY instead drop the segment with the TCP in a valid frame, the host MAY instead drop the segment with the TCP
FIN flag set. FIN flag set (and "renege" if it has been SACKed, according to
[RFC2018] Section 8).
3.8. Re-Keying 3.8. Re-Keying
Re-keying allows hosts to wipe from memory keys that could decrypt Re-keying allows hosts to wipe from memory keys that could decrypt
previously transmitted segments. It also allows the use of AEAD previously transmitted segments. It also allows the use of AEAD
ciphers that can securely encrypt only a bounded number of messages ciphers that can securely encrypt only a bounded number of messages
under a given key. under a given key.
As described above in Section 3.3, a master key "mk[j]" is used to As described above in Section 3.3, a master key "mk[j]" is used to
generate two encryption keys "k_ab[j]" and "k_ba[j]". We refer to generate two encryption keys "k_ab[j]" and "k_ba[j]". We refer to
skipping to change at page 16, line 36 skipping to change at page 17, line 27
8 8
+--------+-----+----+-----+----+---...---+-----+-----+ +--------+-----+----+-----+----+---...---+-----+-----+
|nciphers|sym_ |sym_ | |sym_ | |nciphers|sym_ |sym_ | |sym_ |
| = K |cipher[0] |cipher[1] | |cipher[K-1]| | = K |cipher[0] |cipher[1] | |cipher[K-1]|
+--------+-----+----+-----+----+---...---+-----+-----+ +--------+-----+----+-----+----+---...---+-----+-----+
2*K + 9 2*K + 9 + N_A_LEN 2*K + 9 2*K + 9 + N_A_LEN
| | | |
v v v v
+-------+---...---+-------+-------+---...---+-------+ +-------+---...---+-------+-------+---...---+-------+
| N_A | PK_A | | N_A | Pub_A |
| | | | | |
+-------+---...---+-------+-------+---...---+-------+ +-------+---...---+-------+-------+---...---+-------+
M - 1 M - 1
+-------+---...---+-------+ +-------+---...---+-------+
| ignored | | ignored |
| | | |
+-------+---...---+-------+ +-------+---...---+-------+
The constant "INIT1_MAGIC" is defined in Section 4.3. The four-byte The constant "INIT1_MAGIC" is defined in Section 4.3. The four-byte
field "message_len" gives the length of the entire "Init1" message, field "message_len" gives the length of the entire "Init1" message,
encoded as a big-endian integer. The "nciphers" field contains an encoded as a big-endian integer. The "nciphers" field contains an
integer value that specifies the number of two-byte symmetric-cipher integer value that specifies the number of two-byte symmetric-cipher
identifiers that follow. The "sym_cipher[i]" identifiers indicate identifiers that follow. The "sym_cipher[i]" identifiers indicate
cryptographic algorithms in Table 5 in Section 7. The length cryptographic algorithms in Table 5 in Section 7. The length
"N_A_LEN" and the length of "PK_A" are both determined by the "N_A_LEN" and the length of "Pub_A" are both determined by the
negotiated TEP, as described in Section 5. negotiated TEP, as described in Section 5.
Implementations of this protocol MUST construct "Init1" such that the Implementations of this protocol MUST construct "Init1" such that the
field "ignored" has zero length; that is, they must construct the field "ignored" has zero length; that is, they must construct the
message such that its end, as determined by "message_len", coincides message such that its end, as determined by "message_len", coincides
with the end of the field "PK_A". When receiving "Init1", however, with the end of the field "Pub_A". When receiving "Init1", however,
implementations MUST permit and ignore any bytes following "PK_A". implementations MUST permit and ignore any bytes following "Pub_A".
The "Init2" message has the following encoding: The "Init2" message has the following encoding:
byte 0 1 2 3 byte 0 1 2 3
+-------+-------+-------+-------+ +-------+-------+-------+-------+
| INIT2_MAGIC | | INIT2_MAGIC |
| | | |
+-------+-------+-------+-------+ +-------+-------+-------+-------+
4 5 6 7 8 9 4 5 6 7 8 9
+-------+-------+-------+-------+-------+-------+ +-------+-------+-------+-------+-------+-------+
| message_len | sym_cipher | | message_len | sym_cipher |
| = M | | | = M | |
+-------+-------+-------+-------+-------+-------+ +-------+-------+-------+-------+-------+-------+
10 10 + N_B_LEN 10 10 + N_B_LEN
| | | |
v v v v
+-------+---...---+-------+-------+---...---+-------+ +-------+---...---+-------+-------+---...---+-------+
| N_B | PK_B | | N_B | Pub_B |
| | | | | |
+-------+---...---+-------+-------+---...---+-------+ +-------+---...---+-------+-------+---...---+-------+
M - 1 M - 1
+-------+---...---+-------+ +-------+---...---+-------+
| ignored | | ignored |
| | | |
+-------+---...---+-------+ +-------+---...---+-------+
The constant "INIT2_MAGIC" is defined in Section 4.3. The four-byte The constant "INIT2_MAGIC" is defined in Section 4.3. The four-byte
field "message_len" gives the length of the entire "Init2" message, field "message_len" gives the length of the entire "Init2" message,
encoded as a big-endian integer. The "sym_cipher" value is a encoded as a big-endian integer. The "sym_cipher" value is a
selection from the symmetric-cipher identifiers in the previously- selection from the symmetric-cipher identifiers in the previously-
received "Init1" message. The length "N_B_LEN" and the length of received "Init1" message. The length "N_B_LEN" and the length of
"PK_B" are both determined by the negotiated TEP, as described in "Pub_B" are both determined by the negotiated TEP, as described in
Section 5. Section 5.
Implementations of this protocol MUST construct "Init2" such that the Implementations of this protocol MUST construct "Init2" such that the
field "ignored" has zero length; that is, they must construct the field "ignored" has zero length; that is, they must construct the
message such that its end, as determined by "message_len", coincides message such that its end, as determined by "message_len", coincides
with the end of the "PK_B" field. When receiving "Init2", however, with the end of the "Pub_B" field. When receiving "Init2", however,
implementations MUST permit and ignore any bytes following "PK_B". implementations MUST permit and ignore any bytes following "Pub_B".
4.2. Encryption Frames 4.2. Encryption Frames
An _encryption frame_ comprises a control byte and a length-prefixed An _encryption frame_ comprises a control byte and a length-prefixed
ciphertext value: ciphertext value:
byte 0 1 2 3 clen+2 byte 0 1 2 3 clen+2
+-------+-------+-------+-------+---...---+-------+ +-------+-------+-------+-------+---...---+-------+
|control| clen | ciphertext | |control| clen | ciphertext |
+-------+-------+-------+-------+---...---+-------+ +-------+-------+-------+-------+---...---+-------+
skipping to change at page 18, line 44 skipping to change at page 19, line 36
The "ciphertext" field is the result of applying the negotiated The "ciphertext" field is the result of applying the negotiated
authenticated-encryption algorithm to a "plaintext" value, which has authenticated-encryption algorithm to a "plaintext" value, which has
one of these two formats: one of these two formats:
byte 0 1 plen-1 byte 0 1 plen-1
+-------+-------+---...---+-------+ +-------+-------+---...---+-------+
| flags | data | | flags | data |
+-------+-------+---...---+-------+ +-------+-------+---...---+-------+
byte 0 1 2 3 plen-1 byte 0 1 2 3 plen-1
+-------+-------+-------+-------+---...---+-------+ +-------+-------+-------+-------+---...---+-------+
| flags | urgent | data | | flags | urgent | data |
+-------+-------+-------+-------+---...---+-------+ +-------+-------+-------+-------+---...---+-------+
(Note that "clen" in the previous section will generally be greater (Note that "clen" in the previous section will generally be greater
than "plen", as the ciphertext produced by the authenticated- than "plen", as the ciphertext produced by the authenticated-
encryption scheme must both encrypt the application data and provide encryption scheme must both encrypt the application data and provide
a way to verify its integrity.) a way to verify its integrity.)
The "flags" byte has this structure: The "flags" byte has this structure:
skipping to change at page 19, line 43 skipping to change at page 20, line 34
+-------+-------+-------+ +-------+-------+-------+
It contains the same values as the frame's "control" and "clen" It contains the same values as the frame's "control" and "clen"
fields. fields.
4.2.3. Frame ID 4.2.3. Frame ID
Lastly, a "frame ID" (used to construct the nonce for the AEAD Lastly, a "frame ID" (used to construct the nonce for the AEAD
algorithm) has this format: algorithm) has this format:
byte byte 0 ae_nonce_len - 8 ae_nonce_len - 1
+------+------+------+------+ | | |
0 | FRAME_ID_MAGIC | v v v
+------+------+------+------+ +-----+--...--+-----+-----+--...--+-----+
4 | | | 0 | | 0 | offset |
+ offset + +-----+--...--+-----+-----+--...--+-----+
8 | |
+------+------+------+------+
The 4-byte magic constant is defined in Section 4.3. The 8-byte The 8-byte "offset" field contains an integer in big-endian format.
"offset" field contains an integer in big-endian format. Its value Its value is specified in Section 3.6. Zero-valued bytes are
is specified in Section 3.6. prepended to the "offset" field to form a structure of length
"ae_nonce_len".
4.3. Constant Values 4.3. Constant Values
The table below defines values for the constants used in the The table below defines values for the constants used in the
protocol. protocol.
+------------+----------------+ +------------+--------------+
| Value | Name | | Value | Name |
+------------+----------------+ +------------+--------------+
| 0x01 | CONST_NEXTK | | 0x01 | CONST_NEXTK |
| 0x02 | CONST_SESSID | | 0x02 | CONST_SESSID |
| 0x03 | CONST_REKEY | | 0x03 | CONST_REKEY |
| 0x04 | CONST_KEY_A | | 0x04 | CONST_KEY_A |
| 0x05 | CONST_KEY_B | | 0x05 | CONST_KEY_B |
| 0x06 | CONST_RESUME | | 0x06 | CONST_RESUME |
| 0x15101a0e | INIT1_MAGIC | | 0x15101a0e | INIT1_MAGIC |
| 0x097105e0 | INIT2_MAGIC | | 0x097105e0 | INIT2_MAGIC |
| 0x44415441 | FRAME_ID_MAGIC | +------------+--------------+
+------------+----------------+
Table 1: Constant values used in the protocol Table 1: Constant values used in the protocol
5. Key-Agreement Schemes 5. Key-Agreement Schemes
The TEP negotiated via TCP-ENO indicates the use of one of the key- The TEP negotiated via TCP-ENO indicates the use of one of the key-
agreement schemes named in Table 4 in Section 7. For example, agreement schemes named in Table 4 in Section 7. For example,
"TCPCRYPT_ECDHE_P256" names the tcpcrypt protocol using ECDHE-P256 "TCPCRYPT_ECDHE_P256" names the tcpcrypt protocol using ECDHE-P256
together with the CPRF and length parameters specified below. together with the CPRF and length parameters specified below.
All the TEPs specified in this document require the use of HKDF- All the TEPs specified in this document require the use of HKDF-
Expand-SHA256 as the CPRF, and these lengths for nonces and session Expand-SHA256 as the CPRF, and these lengths for nonces and session
keys: secrets:
N_A_LEN: 32 bytes N_A_LEN: 32 bytes
N_B_LEN: 32 bytes N_B_LEN: 32 bytes
K_LEN: 32 bytes K_LEN: 32 bytes
If future documents assign additional TEPs for use with tcpcrypt, If future documents assign additional TEPs for use with tcpcrypt,
they may specify different values for the lengths above. Note that they may specify different values for the lengths above. Note that
the minimum session ID length required by TCP-ENO, together with the the minimum session ID length required by TCP-ENO, together with the
way tcpcrypt constructs session IDs, implies that "K_LEN" must have way tcpcrypt constructs session IDs, implies that "K_LEN" must have
length at least 32 bytes. length at least 32 bytes.
Key-agreement schemes ECDHE-P256 and ECDHE-P521 employ the ECSVDP-DH Key-agreement schemes ECDHE-P256 and ECDHE-P521 employ the ECSVDP-DH
secret value derivation primitive defined in [ieee1363]. The named secret value derivation primitive defined in [IEEE-1363]. The named
curves are defined in [nist-dss]. When the public-key values "PK_A" curves are defined in [NIST-DSS]. When the public-key values "Pub_A"
and "PK_B" are transmitted as described in Section 4.1, they are and "Pub_B" are transmitted as described in Section 4.1, they are
encoded with the "Elliptic Curve Point to Octet String Conversion encoded with the "Elliptic Curve Point to Octet String Conversion
Primitive" described in Section E.2.3 of [ieee1363], and are prefixed Primitive" described in Section E.2.3 of [IEEE-1363], and are
by a two-byte length in big-endian format: prefixed by a two-byte length in big-endian format:
byte 0 1 2 L - 1 byte 0 1 2 L - 1
+-------+-------+-------+---...---+-------+ +-------+-------+-------+---...---+-------+
| pubkey_len | pubkey | | pubkey_len | pubkey |
| = L | | | = L | |
+-------+-------+-------+---...---+-------+ +-------+-------+-------+---...---+-------+
Implementations MUST encode these "pubkey" values in "compressed Implementations MUST encode these "pubkey" values in "compressed
format". Implementations MUST validate these "pubkey" values format". Implementations MUST validate these "pubkey" values
according to the algorithm in [ieee1363] Section A.16.10. according to the algorithm in [IEEE-1363] Section A.16.10.
Key-agreement schemes ECDHE-Curve25519 and ECDHE-Curve448 use the Key-agreement schemes ECDHE-Curve25519 and ECDHE-Curve448 use the
functions X25519 and X448, respectively, to perform the Diffie-Helman functions X25519 and X448, respectively, to perform the Diffie-Helman
protocol as described in [RFC7748]. When using these ciphers, protocol as described in [RFC7748]. When using these ciphers,
public-key values "PK_A" and "PK_B" are transmitted directly with no public-key values "Pub_A" and "Pub_B" are transmitted directly with
length prefix: 32 bytes for Curve25519, and 56 bytes for Curve448. no length prefix: 32 bytes for Curve25519, and 56 bytes for Curve448.
Implementations are required to implement certain TEPs, according to Implementations are required to implement certain TEPs, according to
Table 2 below. Note that system administrators may configure which Table 2 below. Note that system administrators may configure which
TEPs a host will negotiate, independent of these requirements. TEPs a host will negotiate, independent of these requirements.
+-------------+---------------------------+ +-------------+---------------------------+
| Requirement | TEP | | Requirement | TEP |
+-------------+---------------------------+ +-------------+---------------------------+
| MUST | TCPCRYPT_ECDHE_Curve25519 | | MUST | TCPCRYPT_ECDHE_Curve25519 |
| SHOULD | TCPCRYPT_ECDHE_Curve448 | | SHOULD | TCPCRYPT_ECDHE_Curve448 |
| MAY | TCPCRYPT_ECDHE_P256 | | MAY | TCPCRYPT_ECDHE_P256 |
| MAY | TCPCRYPT_ECDHE_P521 | | MAY | TCPCRYPT_ECDHE_P521 |
+-------------+---------------------------+ +-------------+---------------------------+
Table 2: Requirements for implementation of TEPs Table 2: Requirements for implementation of TEPs
6. AEAD Algorithms 6. AEAD Algorithms
Specifiers and key-lengths for AEAD algorithms are given in Table 5 This document uses "sym-cipher" identifiers in the messages "Init1"
in Section 7. The algorithms "AEAD_AES_128_GCM" and and "Init2" (see Section 3.3) to negotiate the use of AEAD
"AEAD_AES_256_GCM" are specified in [RFC5116]. The algorithm algorithms; the values of these identifiers are given in Table 5 in
"AEAD_CHACHA20_POLY1305" is specified in [RFC7539]. Section 7. The algorithms "AEAD_AES_128_GCM" and "AEAD_AES_256_GCM"
are specified in [RFC5116]. The algorithm "AEAD_CHACHA20_POLY1305"
is specified in [RFC7539].
Implementations are required to support certain algorithms according Implementations are required to support certain AEAD algorithms
to Table 3 below. Note that system administrators may configure according to Table 3 below. Note that system administrators may
which algorithms a host will negotiate, independent of these configure which algorithms a host will negotiate, independent of
requirements. these requirements.
+-------------+------------------------+ Lastly, this document uses the lengths "ae_key_len" and
| Requirement | AEAD Algorithm | "ae_nonce_len" to specify aspects of encryption and data formats.
+-------------+------------------------+
| MUST | AEAD_AES_128_GCM |
| SHOULD | AEAD_AES_256_GCM |
| SHOULD | AEAD_CHACHA20_POLY1305 |
+-------------+------------------------+
Table 3: Requirements for implementation of AEAD algorithms These values depend on the negotiated AEAD algorithm, also according
to the table below.
+------------------------+-------------+------------+--------------+
| AEAD Algorithm | Requirement | ae_key_len | ae_nonce_len |
+------------------------+-------------+------------+--------------+
| AEAD_AES_128_GCM | MUST | 16 bytes | 12 bytes |
| AEAD_AES_256_GCM | SHOULD | 32 bytes | 12 bytes |
| AEAD_CHACHA20_POLY1305 | SHOULD | 32 bytes | 12 bytes |
+------------------------+-------------+------------+--------------+
Table 3: Requirement and lengths for each AEAD algorithm
7. IANA Considerations 7. IANA Considerations
For use with TCP-ENO's negotiation mechanism, tcpcrypt's TEP For use with TCP-ENO's negotiation mechanism, tcpcrypt's TEP
identifiers will need to be incorporated in IANA's "TCP encryption identifiers will need to be incorporated in IANA's "TCP encryption
protocol identifiers" registry under the "Transmission Control protocol identifiers" registry under the "Transmission Control
Protocol (TCP) Parameters" registry, as in Table 4 below. The Protocol (TCP) Parameters" registry, as in Table 4 below. The
various key-agreement schemes used by these tcpcrypt variants are various key-agreement schemes used by these tcpcrypt variants are
defined in Section 5. defined in Section 5.
skipping to change at page 22, line 35 skipping to change at page 23, line 38
| Value | Meaning | Reference | | Value | Meaning | Reference |
+-------+---------------------------+-----------+ +-------+---------------------------+-----------+
| 0x21 | TCPCRYPT_ECDHE_P256 | [RFC-TBD] | | 0x21 | TCPCRYPT_ECDHE_P256 | [RFC-TBD] |
| 0x22 | TCPCRYPT_ECDHE_P521 | [RFC-TBD] | | 0x22 | TCPCRYPT_ECDHE_P521 | [RFC-TBD] |
| 0x23 | TCPCRYPT_ECDHE_Curve25519 | [RFC-TBD] | | 0x23 | TCPCRYPT_ECDHE_Curve25519 | [RFC-TBD] |
| 0x24 | TCPCRYPT_ECDHE_Curve448 | [RFC-TBD] | | 0x24 | TCPCRYPT_ECDHE_Curve448 | [RFC-TBD] |
+-------+---------------------------+-----------+ +-------+---------------------------+-----------+
Table 4: TEP identifiers for use with tcpcrypt Table 4: TEP identifiers for use with tcpcrypt
In Section 4.1, this document defines "sym_cipher" specifiers in the In Section 6, this document defines the use of several AEAD
algorithms for encrypting application data. To name these
algorithms, the tcpcrypt protocol uses two-byte identifiers in the
range 0x0001 to 0xFFFF inclusive, for which IANA is to maintain a new range 0x0001 to 0xFFFF inclusive, for which IANA is to maintain a new
"tcpcrypt AEAD Algorithm" registry under the "Transmission Control "tcpcrypt AEAD Algorithm" registry under the "Transmission Control
Protocol (TCP) Parameters" registry. The initial values for this Protocol (TCP) Parameters" registry. The initial values for this
registry are given in Table 5 below. The AEAD algorithms named there registry are given in Table 5 below. Future assignments are to be
are defined in Section 6. Future assignments are to be made upon made upon satisfying either of two policies defined in [RFC8126]:
satisfying either of two policies defined in [RFC8126]: "IETF Review" "IETF Review" or (for non-IETF stream specifications) "Expert Review
or (for non-IETF stream specifications) "Expert Review with RFC with RFC Required." IANA will furthermore provide early allocation
Required." IANA will furthermore provide early allocation [RFC7120] [RFC7120] to facilitate testing before RFCs are finalized.
to facilitate testing before RFCs are finalized.
+--------+------------------------+------------+-----------+ +--------+------------------------+---------------------+
| Value | AEAD Algorithm | Key Length | Reference | | Value | AEAD Algorithm | Reference |
+--------+------------------------+------------+-----------+ +--------+------------------------+---------------------+
| 0x0001 | AEAD_AES_128_GCM | 16 bytes | [RFC-TBD] | | 0x0001 | AEAD_AES_128_GCM | [RFC-TBD] Section 6 |
| 0x0002 | AEAD_AES_256_GCM | 32 bytes | [RFC-TBD] | | 0x0002 | AEAD_AES_256_GCM | [RFC-TBD] Section 6 |
| 0x0010 | AEAD_CHACHA20_POLY1305 | 32 bytes | [RFC-TBD] | | 0x0010 | AEAD_CHACHA20_POLY1305 | [RFC-TBD] Section 6 |
+--------+------------------------+------------+-----------+ +--------+------------------------+---------------------+
Table 5: Authenticated-encryption algorithms corresponding to Table 5: Authenticated-encryption algorithms for use with tcpcrypt
sym_cipher specifiers in Init1 and Init2 messages.
8. Security Considerations 8. Security Considerations
All of the security considerations of TCP-ENO apply to tcpcrypt. In All of the security considerations of TCP-ENO apply to tcpcrypt. In
particular, tcpcrypt does not protect against active eavesdroppers particular, tcpcrypt does not protect against active eavesdroppers
unless applications authenticate the session ID. If it can be unless applications authenticate the session ID. If it can be
established that the session IDs computed at each end of the established that the session IDs computed at each end of the
connection match, then tcpcrypt guarantees that no man-in-the-middle connection match, then tcpcrypt guarantees that no man-in-the-middle
attacks occurred unless the attacker has broken the underlying attacks occurred unless the attacker has broken the underlying
cryptographic primitives (e.g., ECDH). A proof of this property for cryptographic primitives (e.g., ECDH). A proof of this property for
an earlier version of the protocol has been published [tcpcrypt]. an earlier version of the protocol has been published [tcpcrypt].
To gain middlebox compatibility, tcpcrypt does not protect TCP To ensure middlebox compatibility, tcpcrypt does not protect TCP
headers. Hence, the protocol is vulnerable to denial-of-service from headers. Hence, the protocol is vulnerable to denial-of-service from
off-path attackers just as plain TCP is. Possible attacks include off-path attackers just as plain TCP is. Possible attacks include
desynchronizing the underlying TCP stream, injecting RST or FIN desynchronizing the underlying TCP stream, injecting RST or FIN
segments, and forging re-key bits. These attacks will cause a segments, and forging re-key bits. These attacks will cause a
tcpcrypt connection to hang or fail with an error, but not in any tcpcrypt connection to hang or fail with an error, but not in any
circumstance where plain TCP could continue uncorrupted. circumstance where plain TCP could continue uncorrupted.
Implementations MUST give higher-level software a way to distinguish Implementations MUST give higher-level software a way to distinguish
such errors from a clean end-of-stream (indicated by an authenticated such errors from a clean end-of-stream (indicated by an authenticated
"FINp" bit) so that applications can avoid semantic truncation "FINp" bit) so that applications can avoid semantic truncation
attacks. attacks.
skipping to change at page 23, line 51 skipping to change at page 24, line 50
a connection to an adversary. If key negotiation is compromised and a connection to an adversary. If key negotiation is compromised and
yields two different keys, all subsequent frames will be ignored due yields two different keys, all subsequent frames will be ignored due
to failed integrity checks, causing the application's connection to to failed integrity checks, causing the application's connection to
hang. This is not a new threat because in plain TCP, an active hang. This is not a new threat because in plain TCP, an active
attacker could have modified sequence and acknowledgement numbers to attacker could have modified sequence and acknowledgement numbers to
hang the connection anyway. hang the connection anyway.
Tcpcrypt uses short-lived public keys to provide forward secrecy. Tcpcrypt uses short-lived public keys to provide forward secrecy.
That is, once an implementation removes these keys from memory, a That is, once an implementation removes these keys from memory, a
compromise of the system will not provide any means to derive the compromise of the system will not provide any means to derive the
session keys for past connections. All currently-specified key session secrets for past connections. All currently-specified key
agreement schemes involve ECDHE-based key agreement, meaning a new agreement schemes involve ECDHE-based key agreement, meaning a new
key-pair can be efficiently computed for each connection. If key-pair can be efficiently computed for each connection. If
implementations reuse these parameters, they MUST limit the lifetime implementations reuse these parameters, they MUST limit the lifetime
of the private parameters as far as practical in order to minimize of the private parameters as far as practical in order to minimize
the number of past connections that are vulnerable. Of course, the number of past connections that are vulnerable. Of course,
placing private keys in persistent storage introduces severe risks placing private keys in persistent storage introduces severe risks
that they may not be destroyed reliably and in a timely fashion, and that they may not be destroyed reliably and in a timely fashion, and
SHOULD be avoided at all costs. SHOULD be avoided at all costs.
Attackers cannot force passive openers to move forward in their Attackers cannot force passive openers to move forward in their
skipping to change at page 24, line 43 skipping to change at page 25, line 42
However, until a pseudo-random generator has been seeded with However, until a pseudo-random generator has been seeded with
sufficient entropy, not only will tcpcrypt be insecure, it will sufficient entropy, not only will tcpcrypt be insecure, it will
reveal information that further weakens the security of the pseudo- reveal information that further weakens the security of the pseudo-
random generator, potentially harming other applications. As random generator, potentially harming other applications. As
required by TCP-ENO, implementations MUST NOT send ENO options unless required by TCP-ENO, implementations MUST NOT send ENO options unless
they have access to an adequate source of randomness. they have access to an adequate source of randomness.
8.1. Asymmetric Roles 8.1. Asymmetric Roles
Tcpcrypt transforms a shared pseudo-random key (PRK) into Tcpcrypt transforms a shared pseudo-random key (PRK) into
cryptographic session keys for each direction. Doing so requires an cryptographic traffic keys for each direction. Doing so requires an
asymmetry in the protocol, as the key derivation function must be asymmetry in the protocol, as the key derivation function must be
perturbed differently to generate different keys in each direction. perturbed differently to generate different keys in each direction.
Tcpcrypt includes other asymmetries in the roles of the two hosts, Tcpcrypt includes other asymmetries in the roles of the two hosts,
such as the process of negotiating algorithms (e.g., proposing vs. such as the process of negotiating algorithms (e.g., proposing vs.
selecting cipher suites). selecting cipher suites).
8.2. Verified Liveness 8.2. Verified Liveness
Many hosts implement TCP Keep-Alives [RFC1122] as an option for Many hosts implement TCP Keep-Alives [RFC1122] as an option for
applications to ensure that the other end of a TCP connection still applications to ensure that the other end of a TCP connection still
skipping to change at page 26, line 8 skipping to change at page 27, line 8
To meet that ideal, it might appear natural to also mandate ECDHE To meet that ideal, it might appear natural to also mandate ECDHE
using P-256, as this scheme is well-studied, widely implemented, and using P-256, as this scheme is well-studied, widely implemented, and
sufficiently different from the Curve25519-based scheme that it is sufficiently different from the Curve25519-based scheme that it is
unlikely they will both suffer from a single (non-quantum) unlikely they will both suffer from a single (non-quantum)
cryptanalytic advance. cryptanalytic advance.
However, implementing the Diffie-Hellman function using NIST elliptic However, implementing the Diffie-Hellman function using NIST elliptic
curves (including those specified for use with tcpcrypt, P-256 and curves (including those specified for use with tcpcrypt, P-256 and
P-521) appears to be very difficult to achieve without introducing P-521) appears to be very difficult to achieve without introducing
vulnerability to side-channel attacks [nist-ecc]. Although well- vulnerability to side-channel attacks [NIST-fail]. Although well-
trusted implementations are available as part of large cryptographic trusted implementations are available as part of large cryptographic
libraries, these may be difficult to extract for use in operating- libraries, these may be difficult to extract for use in operating-
system kernels where tcpcrypt is usually best implemented. In system kernels where tcpcrypt is usually best implemented. In
contrast, the characteristics of Curve25519 together with its recent contrast, the characteristics of Curve25519 together with its recent
popularity has led to many safe and efficient implementations, popularity has led to many safe and efficient implementations,
including some that fit naturally into the kernel environment. including some that fit naturally into the kernel environment.
[RFC7696] insists that, "The selected algorithms need to be resistant [RFC7696] insists that, "The selected algorithms need to be resistant
to side-channel attacks and also meet the performance, power, and to side-channel attacks and also meet the performance, power, and
code size requirements on a wide variety of platforms." On this code size requirements on a wide variety of platforms." On this
skipping to change at page 27, line 36 skipping to change at page 28, line 36
12. References 12. References
12.1. Normative References 12.1. Normative References
[I-D.ietf-tcpinc-tcpeno] [I-D.ietf-tcpinc-tcpeno]
Bittau, A., Giffin, D., Handley, M., Mazieres, D., and E. Bittau, A., Giffin, D., Handley, M., Mazieres, D., and E.
Smith, "TCP-ENO: Encryption Negotiation Option", draft- Smith, "TCP-ENO: Encryption Negotiation Option", draft-
ietf-tcpinc-tcpeno-13 (work in progress), November 2017. ietf-tcpinc-tcpeno-13 (work in progress), November 2017.
[ieee1363] [IEEE-1363]
IEEE, "IEEE Standard Specifications for Public-Key IEEE, "IEEE Standard Specifications for Public-Key
Cryptography (IEEE Std 1363-2000)", 2000. Cryptography (IEEE Std 1363-2000)", 2000.
[nist-dss] [NIST-DSS]
NIST, "FIPS PUB 186-4: Digital Signature Standard (DSS)", NIST, "FIPS PUB 186-4: Digital Signature Standard (DSS)",
2013. 2013.
[RFC0793] Postel, J., "Transmission Control Protocol", STD 7, [RFC0793] Postel, J., "Transmission Control Protocol", STD 7,
RFC 793, DOI 10.17487/RFC0793, September 1981, RFC 793, DOI 10.17487/RFC0793, September 1981,
<https://www.rfc-editor.org/info/rfc793>. <https://www.rfc-editor.org/info/rfc793>.
[RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP
Selective Acknowledgment Options", RFC 2018,
DOI 10.17487/RFC2018, October 1996, <https://www.rfc-
editor.org/info/rfc2018>.
[RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed-
Hashing for Message Authentication", RFC 2104, Hashing for Message Authentication", RFC 2104,
DOI 10.17487/RFC2104, February 1997, <https://www.rfc- DOI 10.17487/RFC2104, February 1997, <https://www.rfc-
editor.org/info/rfc2104>. editor.org/info/rfc2104>.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, <https://www.rfc- DOI 10.17487/RFC2119, March 1997, <https://www.rfc-
editor.org/info/rfc2119>. editor.org/info/rfc2119>.
skipping to change at page 28, line 48 skipping to change at page 30, line 5
May 2017, <https://www.rfc-editor.org/info/rfc8174>. May 2017, <https://www.rfc-editor.org/info/rfc8174>.
12.2. Informative References 12.2. Informative References
[I-D.ietf-tcpinc-api] [I-D.ietf-tcpinc-api]
Bittau, A., Boneh, D., Giffin, D., Handley, M., Mazieres, Bittau, A., Boneh, D., Giffin, D., Handley, M., Mazieres,
D., and E. Smith, "Interface Extensions for TCP-ENO and D., and E. Smith, "Interface Extensions for TCP-ENO and
tcpcrypt", draft-ietf-tcpinc-api-05 (work in progress), tcpcrypt", draft-ietf-tcpinc-api-05 (work in progress),
September 2017. September 2017.
[nist-ecc] [NIST-fail]
Bernstein, D. and T. Lange, "Failures in NIST's ECC Bernstein, D. and T. Lange, "Failures in NIST's ECC
standards", 2016, <https://cr.yp.to/newelliptic/nistecc- standards", 2016, <https://cr.yp.to/newelliptic/nistecc-
20160106.pdf>. 20160106.pdf>.
[RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts -
Communication Layers", STD 3, RFC 1122, Communication Layers", STD 3, RFC 1122,
DOI 10.17487/RFC1122, October 1989, <https://www.rfc- DOI 10.17487/RFC1122, October 1989, <https://www.rfc-
editor.org/info/rfc1122>. editor.org/info/rfc1122>.
[RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker,
 End of changes. 70 change blocks. 
181 lines changed or deleted 218 lines changed or added

This html diff was produced by rfcdiff 1.46. The latest version is available from http://tools.ietf.org/tools/rfcdiff/