idnits 2.17.1 draft-ietf-tcpinc-tcpcrypt-12.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (June 29, 2018) is 2126 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Experimental ---------------------------------------------------------------------------- -- Looks like a reference, but probably isn't: '0' on line 783 -- Looks like a reference, but probably isn't: '1' on line 783 == Missing Reference: 'K-1' is mentioned on line 783, but not defined == Missing Reference: 'RFC-TBD' is mentioned on line 1099, but not defined == Outdated reference: A later version (-19) exists of draft-ietf-tcpinc-tcpeno-18 ** Obsolete normative reference: RFC 793 (Obsoleted by RFC 9293) ** Obsolete normative reference: RFC 7539 (Obsoleted by RFC 8439) == Outdated reference: A later version (-06) exists of draft-ietf-tcpinc-api-05 Summary: 2 errors (**), 0 flaws (~~), 5 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group A. Bittau 3 Internet-Draft Google 4 Intended status: Experimental D. Giffin 5 Expires: December 31, 2018 Stanford University 6 M. Handley 7 University College London 8 D. Mazieres 9 Stanford University 10 Q. Slack 11 Sourcegraph 12 E. Smith 13 Kestrel Institute 14 June 29, 2018 16 Cryptographic protection of TCP Streams (tcpcrypt) 17 draft-ietf-tcpinc-tcpcrypt-12 19 Abstract 21 This document specifies tcpcrypt, a TCP encryption protocol designed 22 for use in conjunction with the TCP Encryption Negotiation Option 23 (TCP-ENO). Tcpcrypt coexists with middleboxes by tolerating 24 resegmentation, NATs, and other manipulations of the TCP header. The 25 protocol is self-contained and specifically tailored to TCP 26 implementations, which often reside in kernels or other environments 27 in which large external software dependencies can be undesirable. 28 Because the size of TCP options is limited, the protocol requires one 29 additional one-way message latency to perform key exchange before 30 application data can be transmitted. However, the extra latency can 31 be avoided between two hosts that have recently established a 32 previous tcpcrypt connection. 34 Status of This Memo 36 This Internet-Draft is submitted in full conformance with the 37 provisions of BCP 78 and BCP 79. 39 Internet-Drafts are working documents of the Internet Engineering 40 Task Force (IETF). Note that other groups may also distribute 41 working documents as Internet-Drafts. The list of current Internet- 42 Drafts is at https://datatracker.ietf.org/drafts/current/. 44 Internet-Drafts are draft documents valid for a maximum of six months 45 and may be updated, replaced, or obsoleted by other documents at any 46 time. It is inappropriate to use Internet-Drafts as reference 47 material or to cite them other than as "work in progress." 48 This Internet-Draft will expire on December 31, 2018. 50 Copyright Notice 52 Copyright (c) 2018 IETF Trust and the persons identified as the 53 document authors. All rights reserved. 55 This document is subject to BCP 78 and the IETF Trust's Legal 56 Provisions Relating to IETF Documents 57 (https://trustee.ietf.org/license-info) in effect on the date of 58 publication of this document. Please review these documents 59 carefully, as they describe your rights and restrictions with respect 60 to this document. Code Components extracted from this document must 61 include Simplified BSD License text as described in Section 4.e of 62 the Trust Legal Provisions and are provided without warranty as 63 described in the Simplified BSD License. 65 Table of Contents 67 1. Requirements Language . . . . . . . . . . . . . . . . . . . . 3 68 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 69 3. Encryption Protocol . . . . . . . . . . . . . . . . . . . . . 3 70 3.1. Cryptographic Algorithms . . . . . . . . . . . . . . . . 3 71 3.2. Protocol Negotiation . . . . . . . . . . . . . . . . . . 5 72 3.3. Key Exchange . . . . . . . . . . . . . . . . . . . . . . 6 73 3.4. Session ID . . . . . . . . . . . . . . . . . . . . . . . 9 74 3.5. Session Resumption . . . . . . . . . . . . . . . . . . . 9 75 3.6. Data Encryption and Authentication . . . . . . . . . . . 13 76 3.7. TCP Header Protection . . . . . . . . . . . . . . . . . . 14 77 3.8. Re-Keying . . . . . . . . . . . . . . . . . . . . . . . . 15 78 3.9. Keep-Alive . . . . . . . . . . . . . . . . . . . . . . . 16 79 4. Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . 16 80 4.1. Key-Exchange Messages . . . . . . . . . . . . . . . . . . 16 81 4.2. Encryption Frames . . . . . . . . . . . . . . . . . . . . 18 82 4.2.1. Plaintext . . . . . . . . . . . . . . . . . . . . . . 19 83 4.2.2. Associated Data . . . . . . . . . . . . . . . . . . . 20 84 4.2.3. Frame ID . . . . . . . . . . . . . . . . . . . . . . 20 85 4.3. Constant Values . . . . . . . . . . . . . . . . . . . . . 20 86 5. Key-Agreement Schemes . . . . . . . . . . . . . . . . . . . . 21 87 6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . . . 22 88 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23 89 8. Security Considerations . . . . . . . . . . . . . . . . . . . 24 90 8.1. Asymmetric Roles . . . . . . . . . . . . . . . . . . . . 25 91 8.2. Verified Liveness . . . . . . . . . . . . . . . . . . . . 26 92 8.3. Mandatory Key-Agreement Schemes . . . . . . . . . . . . . 26 93 9. Experiments . . . . . . . . . . . . . . . . . . . . . . . . . 27 94 10. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 28 95 11. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 28 96 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 28 97 12.1. Normative References . . . . . . . . . . . . . . . . . . 28 98 12.2. Informative References . . . . . . . . . . . . . . . . . 29 99 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 30 101 1. Requirements Language 103 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 104 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 105 "OPTIONAL" in this document are to be interpreted as described in BCP 106 14 [RFC2119] [RFC8174] when, and only when, they appear in all 107 capitals, as shown here. 109 2. Introduction 111 This document describes tcpcrypt, an extension to TCP for 112 cryptographic protection of session data. Tcpcrypt was designed to 113 meet the following goals: 115 o Meet the requirements of the TCP Encryption Negotiation Option 116 (TCP-ENO) [I-D.ietf-tcpinc-tcpeno] for protecting connection data. 118 o Be amenable to small, self-contained implementations inside TCP 119 stacks. 121 o Minimize additional latency at connection startup. 123 o As much as possible, prevent connection failure in the presence of 124 NATs and other middleboxes that might normalize traffic or 125 otherwise manipulate TCP segments. 127 o Operate independently of IP addresses, making it possible to 128 authenticate resumed sessions efficiently even when either end 129 changes IP address. 131 A companion document [I-D.ietf-tcpinc-api] describes recommended 132 interfaces for configuring certain parameters of this protocol. 134 3. Encryption Protocol 136 This section describes the operation of the tcpcrypt protocol. The 137 wire format of all messages is specified in Section 4. 139 3.1. Cryptographic Algorithms 141 Setting up a tcpcrypt connection employs three types of cryptographic 142 algorithms: 144 o A _key agreement scheme_ is used with a short-lived public key to 145 agree upon a shared secret. 147 o An _extract function_ is used to generate a pseudo-random key 148 (PRK) from some initial keying material produced by the key 149 agreement scheme. The notation Extract(S, IKM) denotes the output 150 of the extract function with salt S and initial keying material 151 IKM. 153 o A _collision-resistant pseudo-random function (CPRF)_ is used to 154 generate multiple cryptographic keys from a pseudo-random key, 155 typically the output of the extract function. The CPRF produces 156 an arbitrary amount of Output Keying Material (OKM), and we use 157 the notation CPRF(K, CONST, L) to designate the first L bytes of 158 the OKM produced by the CPRF when parameterized by key K and the 159 constant CONST. 161 The Extract and CPRF functions used by the tcpcrypt variants defined 162 in this document are the Extract and Expand functions of HKDF 163 [RFC5869], which is built on HMAC [RFC2104]. These are defined as 164 follows in terms of the function "HMAC-Hash(key, value)" for a 165 negotiated "Hash" function such as SHA-256; the symbol "|" denotes 166 concatenation, and the counter concatenated to the right of CONST 167 occupies a single octet. 169 HKDF-Extract(salt, IKM) -> PRK 170 PRK = HMAC-Hash(salt, IKM) 172 HKDF-Expand(PRK, CONST, L) -> OKM 173 T(0) = empty string (zero length) 174 T(1) = HMAC-Hash(PRK, T(0) | CONST | 0x01) 175 T(2) = HMAC-Hash(PRK, T(1) | CONST | 0x02) 176 T(3) = HMAC-Hash(PRK, T(2) | CONST | 0x03) 177 ... 179 OKM = first L octets of T(1) | T(2) | T(3) | ... 180 where L <= 255*OutputLength(Hash) 182 Figure 1: HKDF functions used for key derivation 184 Lastly, once tcpcrypt has been successfully set up and encryption 185 keys have been derived, an algorithm for Authenticated Encryption 186 with Associated Data (AEAD) is used to protect the confidentiality 187 and integrity of all transmitted application data. AEAD algorithms 188 use a single key to encrypt their input data and also to generate a 189 cryptographic tag to accompany the resulting ciphertext; when 190 decryption is performed, the tag allows authentication of the 191 encrypted data and of optional, associated plaintext data. 193 3.2. Protocol Negotiation 195 Tcpcrypt depends on TCP-ENO [I-D.ietf-tcpinc-tcpeno] to negotiate 196 whether encryption will be enabled for a connection, and also which 197 key-agreement scheme to use. TCP-ENO negotiates the use of a 198 particular TCP encryption protocol or _TEP_ by including protocol 199 identifiers in ENO suboptions. This document associates four TEP 200 identifiers with the tcpcrypt protocol, as listed in Table 4 in 201 Section 7. Each identifier indicates the use of a particular key- 202 agreement scheme, with an associated CPRF and length parameter. 203 Future standards can associate additional TEP identifiers with 204 tcpcrypt, following the assignment policy specified by TCP-ENO. 206 An active opener that wishes to negotiate the use of tcpcrypt 207 includes an ENO option in its SYN segment. That option includes 208 suboptions with tcpcrypt TEP identifiers indicating the key-agreement 209 schemes it is willing to enable. The active opener MAY additionally 210 include suboptions indicating support for encryption protocols other 211 than tcpcrypt, as well as global suboptions as specified by TCP-ENO. 213 If a passive opener receives an ENO option including tcpcrypt TEPs it 214 supports, it MAY then attach an ENO option to its SYN-ACK segment, 215 including solely the TEP it wishes to enable. 217 To establish distinct roles for the two hosts in each connection, 218 tcpcrypt depends on the role-negotiation mechanism of TCP-ENO. As 219 one result of the negotiation process, TCP-ENO assigns hosts unique 220 roles abstractly called "A" at one end of the connection and "B" at 221 the other. Generally, an active opener plays the "A" role and a 222 passive opener plays the "B" role, but in the case of simultaneous 223 open, an additional mechanism breaks the symmetry and assigns a 224 distinct role to each host. TCP-ENO uses the terms "host A" and 225 "host B" to identify each end of a connection uniquely, and this 226 document employs those terms in the same way. 228 An ENO suboption includes a flag "v" which indicates the presence of 229 associated, variable-length data. In order to propose fresh key 230 agreement with a particular tcpcrypt TEP, a host sends a one-byte 231 suboption containing the TEP identifier and "v = 0". In order to 232 propose session resumption (described further below) with a 233 particular TEP, a host sends a variable-length suboption containing 234 the TEP identifier, the flag "v = 1", an identifier derived from a 235 session secret previously negotiated with the same host and the same 236 TEP, and a nonce. 238 Once two hosts have exchanged SYN segments, TCP-ENO defines the 239 _negotiated TEP_ to be the last valid TEP identifier in the SYN 240 segment of host B (that is, the passive opener in the absence of 241 simultaneous open) that also occurs in that of host A. If there is 242 no such TEP, hosts MUST disable TCP-ENO and tcpcrypt. 244 If the negotiated TEP was sent by host B with "v = 0", it means that 245 fresh key agreement will be performed as described below in 246 Section 3.3. If, on the other hand, host B sent the TEP with "v = 1" 247 and both hosts sent appropriate resumption identifiers in their 248 suboption data, then the key-exchange messages will be omitted in 249 favor of determining keys via session resumption as described in 250 Section 3.5. With session resumption, protected application data MAY 251 be sent immediately as detailed in Section 3.6. 253 Note that the negotiated TEP is determined without reference to the 254 "v" bits in ENO suboptions, so if host A offers resumption with a 255 particular TEP and host B replies with a non-resumption suboption 256 with the same TEP, that could become the negotiated TEP and fresh key 257 agreement will be performed. That is, sending a resumption suboption 258 also implies willingness to perform fresh key agreement with the 259 indicated TEP. 261 As REQUIRED by TCP-ENO, once a host has both sent and received an ACK 262 segment containing a valid ENO option, encryption MUST be enabled and 263 plaintext application data MUST NOT ever be exchanged on the 264 connection. If the negotiated TEP is among those listed in Table 4, 265 a host MUST follow the protocol described in this document. 267 3.3. Key Exchange 269 Following successful negotiation of a tcpcrypt TEP, all further 270 signaling is performed in the Data portion of TCP segments. Except 271 when resumption was negotiated (described below in Section 3.5), the 272 two hosts perform key exchange through two messages, "Init1" and 273 "Init2", at the start of the data streams of host A and host B, 274 respectively. These messages MAY span multiple TCP segments and need 275 not end at a segment boundary. However, the segment containing the 276 last byte of an "Init1" or "Init2" message MUST have TCP's push flag 277 (PSH) set. 279 The key exchange protocol, in abstract, proceeds as follows: 281 A -> B: Init1 = { INIT1_MAGIC, sym_cipher_list, N_A, Pub_A } 282 B -> A: Init2 = { INIT2_MAGIC, sym_cipher, N_B, Pub_B } 284 The concrete format of these messages is specified in Section 4.1. 286 The parameters are defined as follows: 288 o "INIT1_MAGIC", "INIT2_MAGIC": constants defined in Section 4.3. 290 o "sym_cipher_list": a list of identifiers of symmetric ciphers 291 (AEAD algorithms) acceptable to host A. These are specified in 292 Table 5 in Section 7. 294 o "sym_cipher": the symmetric cipher selected by host B from the 295 "sym_cipher_list" sent by host A. 297 o "N_A", "N_B": nonces chosen at random by hosts A and B, 298 respectively. 300 o "Pub_A", "Pub_B": ephemeral public keys for hosts A and B, 301 respectively. These, as well as their corresponding private keys, 302 are short-lived values that MUST be refreshed frequently. The 303 private keys SHOULD NOT ever be written to persistent storage. 304 The security risks associated with the storage of these keys are 305 discussed in Section 8. 307 If a host receives an ephemeral public key from its peer and a key- 308 validation step fails (see Section 5), it MUST abort the connection 309 and raise an error condition distinct from the end-of-file condition. 311 The ephemeral secret "ES" is the result of the key-agreement 312 algorithm (see Section 5) indicated by the negotiated TEP. The 313 inputs to the algorithm are the local host's ephemeral private key 314 and the remote host's ephemeral public key. For example, host A 315 would compute "ES" using its own private key (not transmitted) and 316 host B's public key, "Pub_B". 318 The two sides then compute a pseudo-random key "PRK", from which all 319 session secrets are derived, as follows: 321 PRK = Extract(N_A, eno-transcript | Init1 | Init2 | ES) 323 Above, "|" denotes concatenation; "eno-transcript" is the protocol- 324 negotiation transcript defined in Section 4.8 of 325 [I-D.ietf-tcpinc-tcpeno]; and "Init1" and "Init2" are the transmitted 326 encodings of the messages described in Section 4.1. 328 A series of "session secrets" are computed from "PRK" as follows: 330 ss[0] = PRK 331 ss[i] = CPRF(ss[i-1], CONST_NEXTK, K_LEN) 333 The value "ss[0]" is used to generate all key material for the 334 current connection. The values "ss[i]" for "i > 0" are used by 335 session resumption to avoid public key cryptography when establishing 336 subsequent connections between the same two hosts, as described later 337 in Section 3.5. The "CONST_*" values are constants defined in 338 Section 4.3. The length "K_LEN" depends on the tcpcrypt TEP in use, 339 and is specified in Section 5. 341 Given a session secret "ss[i]", the two sides compute a series of 342 master keys as follows: 344 mk[0] = CPRF(ss[i], CONST_REKEY | sn[i], K_LEN) 345 mk[j] = CPRF(mk[j-1], CONST_REKEY, K_LEN) 347 The process of advancing through the series of master keys is 348 described in Section 3.8. The values "sn[i]" are "session nonces." 349 For the initial session with "i = 0", the session nonce is zero bytes 350 long. The values for subsequent sessions are derived from fresh 351 connection data as described in Section 3.5. 353 Finally, each master key "mk[j]" is used to generate traffic keys for 354 protecting application data using authenticated encryption: 356 k_ab[j] = CPRF(mk[j], CONST_KEY_A, ae_key_len + ae_nonce_len) 357 k_ba[j] = CPRF(mk[j], CONST_KEY_B, ae_key_len + ae_nonce_len) 359 In the first session derived from fresh key-agreement, traffic keys 360 "k_ab[j]" are used by host A to encrypt and host B to decrypt, while 361 keys "k_ba[j]" are used by host B to encrypt and host A to decrypt. 362 In a resumed session, as described more thoroughly below in 363 Section 3.5, each host uses the keys in the same way as it did in the 364 original session, regardless of its role in the current session: for 365 example, if a host played role "A" in the first session, it will use 366 keys "k_ab[j]" to encrypt in each derived session. 368 The values "ae_key_len" and "ae_nonce_len" depend on the 369 authenticated-encryption algorithm selected, and are given in Table 3 370 in Section 6. The algorithm uses the first "ae_key_len" bytes of 371 each traffic key as an authenticated-encryption key, and the 372 following "ae_nonce_len" bytes as a "nonce randomizer". 374 Implementations SHOULD provide an interface allowing the user to 375 specify, for a particular connection, the set of AEAD algorithms to 376 advertize in "sym_cipher_list" (when playing role "A") and also the 377 order of preference to use when selecting an algorithm from those 378 offered (when playing role "B"). A companion document 379 [I-D.ietf-tcpinc-api] describes recommended interfaces for this 380 purpose. 382 After host B sends "Init2" or host A receives it, that host MAY 383 immediately begin transmitting protected application data as 384 described in Section 3.6. 386 If host A receives "Init2" with a "sym_cipher" value that was not 387 present in the "sym_cipher_list" it previously transmitted in 388 "Init1", it MUST abort the connection and raise an error condition 389 distinct from the end-of-file condition. 391 Throughout this document, to "abort the connection" means to issue 392 the "Abort" command as described in [RFC0793], Section 3.8. That is, 393 the TCP connection is destroyed, RESET is transmitted, and the local 394 user is alerted to the abort event. 396 3.4. Session ID 398 TCP-ENO requires each TEP to define a _session ID_ value that 399 uniquely identifies each encrypted connection. 401 A tcpcrypt session ID begins with the byte transmitted by host B that 402 contains the negotiated TEP identifier along with the "v" bit. The 403 remainder of the ID is derived from the session secret and session 404 nonce, as follows: 406 session_id[i] = TEP-byte | CPRF(ss[i], CONST_SESSID | sn[i], K_LEN) 408 Again, the length "K_LEN" depends on the TEP, and is specified in 409 Section 5. 411 3.5. Session Resumption 413 If two hosts have previously negotiated a session with secret 414 "ss[i-1]", they can establish a new connection without public-key 415 operations using "ss[i]", the next session secret in the sequence 416 derived from the original PRK. 418 A host signals willingness to resume with a particular session secret 419 by sending a SYN segment with a resumption suboption: that is, an ENO 420 suboption containing the negotiated TEP identifier of the previous 421 session, half of the "resumption identifier" for the new session, and 422 a "resumption nonce". 424 The resumption nonce MUST have a minimum length of zero bytes and 425 maximum length of eight bytes. An implementation MUST either send 426 four or more bytes of nonce for all resumption attempts, or else 427 default to a minimum of four bytes and provide an interface for 428 system administrators to configure other minimum lengths. In the 429 latter case, documentation accompanying the configuration interface 430 MUST explain that using nonce values shorter than four bytes is only 431 safe if there is no risk of the system participating in multiple 432 resumptions from the same session secret, as could happen with live 433 virtual-machine cloning. The resumption nonce MUST be chosen 434 randomly or using a mechanism that guarantees uniqueness even in the 435 face of virtual machine cloning or other re-execution of the same 436 session. 438 The resumption identifier is calculated from a session secret "ss[i]" 439 as follows: 441 resume[i] = CPRF(ss[i], CONST_RESUME, 18) 443 To name a session for resumption, a host sends either the first or 444 second half of the resumption identifier, according to the role it 445 played in the original session with secret "ss[0]". 447 A host that originally played role "A" and wishes to resume from a 448 cached session sends a suboption with the first half of the 449 resumption identifier: 451 byte 0 1 9 10 452 +------+------+--...--+------+------+--...--+------+ 453 | TEP- | resume[i]{0..8} | nonce_a | 454 | byte | | | 455 +------+------+--...--+------+------+--...--+------+ 457 Figure 2: Resumption suboption sent when original role was "A". The 458 TEP-byte contains a tcpcrypt TEP identifier and v = 1. The nonce 459 value MUST have length between 0 and 8 bytes. 461 Similarly, a host that originally played role "B" sends a suboption 462 with the second half of the resumption identifier: 464 byte 0 1 9 10 465 +------+------+--...--+------+------+--...--+------+ 466 | TEP- | resume[i]{9..17} | nonce_b | 467 | byte | | | 468 +------+------+--...--+------+------+--...--+------+ 470 Figure 3: Resumption suboption sent when original role was "B". The 471 TEP-byte contains a tcpcrypt TEP identifier and v = 1. The nonce 472 value MUST have length between 0 and 8 bytes. 474 If a passive opener receives a resumption suboption containing an 475 identifier-half that names a session secret that it has cached and 476 the subobtion's TEP matches the TEP used in the previous session, it 477 SHOULD (with exceptions specified below) agree to resume from the 478 cached session by sending its own resumption suboption, which will 479 contain the other half of the identifier. Otherwise, it MUST NOT 480 agree to resumption. 482 If a passive opener does not agree to resumption with a particular 483 TEP, it MAY either request fresh key exchange by responding with a 484 non-resumption suboption using the same TEP, or else respond to any 485 other received TEP suboption. 487 If a passive opener receives an ENO suboption with a TEP identifier 488 and "v = 1", but the suboption data is less than 9 bytes in length, 489 it MUST behave as if the same TEP had been sent with "v = 0". That 490 is, the suboption MUST be interpreted as an offer to negotiate fresh 491 key exchange with that TEP. 493 If an active opener sends a resumption suboption with a particular 494 TEP and the appropriate half of a resumption identifier and then, in 495 the same TCP handshake, receives a resumption suboption with the same 496 TEP and an identifier-half that does not match that resumption 497 identifier, it MUST ignore that suboption. In the typical case that 498 this was the only ENO suboption received, this means the host MUST 499 disable TCP-ENO and tcpcrypt: that is, it MUST NOT send any more ENO 500 options and MUST NOT encrypt the connection. 502 When a host concludes that TCP-ENO negotiation has succeeded for some 503 TEP that was received in a resumption suboption, it MUST then enable 504 encryption with that TEP using the cached session secret. To do 505 this, it first constructs "sn[i]" as follows: 507 sn[i] = nonce_a | nonce_b 509 Master keys are then computed from "s[i]" and "sn[i]" as described in 510 Section 3.3, and application data encrypted as described in 511 Section 3.6. 513 The session ID (Section 3.4) is constructed in the same way for 514 resumed sessions as it is for fresh ones. In this case the first 515 byte will always have "v = 1". The remainder of the ID is derived 516 from the cached session secret and the session nonce that was 517 generated during resumption. 519 In the case of simultaneous open where TCP-ENO is able to establish 520 asymmetric roles, two hosts that simultaneously send SYN segments 521 with compatible resumption suboptions MAY resume the associated 522 session. 524 In a particular SYN segment, a host SHOULD NOT send more than one 525 resumption suboption (because this consumes TCP option space and is 526 unlikely to be a useful practice), and MUST NOT send more than one 527 resumption suboption with the same TEP identifier. But in addition 528 to any resumption suboptions, an active opener MAY include non- 529 resumption suboptions describing other TEPs it supports (in addition 530 to the TEP in the resumption suboption). 532 After using the session secret "ss[i]" to compute "mk[0]", 533 implementations SHOULD compute and cache "ss[i+1]" for possible use 534 by a later session, then erase "ss[i]" from memory. Hosts MAY retain 535 "ss[i+1]" until it is used or the memory needs to be reclaimed. 536 Hosts SHOULD NOT write any session secrets to non-volatile storage. 538 When proposing resumption, the active opener MUST use the lowest 539 value of "i" that has not already been used (successfully or not) to 540 negotiate resumption with the same host and for the same original 541 session secret "ss[0]". 543 A given session secret "ss[i]" MUST NOT be used to secure more than 544 one TCP connection. To prevent this, a host MUST NOT resume with a 545 session secret if it has ever enabled encryption in the past with the 546 same secret, in either role. In the event that two hosts 547 simultaneously send SYN segments to each other that propose 548 resumption with the same session secret but the two segments are not 549 part of a simultaneous open, both connections would need to revert to 550 fresh key-exchange. To avoid this limitation, implementations MAY 551 choose to implement session resumption such that all session secrets 552 derived from a given "ss[0]" are used for either passive or active 553 opens at the same host, not both. 555 If two hosts have previously negotiated a tcpcrypt session, either 556 host MAY later initiate session resumption regardless of which host 557 was the active opener or played the "A" role in the previous session. 559 However, a given host MUST either encrypt with keys "k_ab[j]" for all 560 sessions derived from the same original session secret "ss[0]", or 561 with keys "k_ba[j]". Thus, which keys a host uses to send segments 562 is not affected by the role it plays in the current connection: it 563 depends only on whether the host played the "A" or "B" role in the 564 initial session. 566 Implementations that cache session secrets MUST provide a means for 567 applications to control that caching. In particular, when an 568 application requests a new TCP connection, it MUST have a way to 569 specify two policies for the duration of the connection: 1) that 570 resumption requests will be ignored, and thus fresh key exchange will 571 be necessary; and 2) that no session secrets will be cached. (These 572 policies can be specified independently or as a unit.) And for an 573 established connection, an application MUST have a means to cause any 574 cache state that was used in or resulted from establishing the 575 connection to be flushed. A companion document [I-D.ietf-tcpinc-api] 576 describes recommended interfaces for this purpose. 578 3.6. Data Encryption and Authentication 580 Following key exchange (or its omission via session resumption), all 581 further communication in a tcpcrypt-enabled connection is carried out 582 within delimited _encryption frames_ that are encrypted and 583 authenticated using the agreed upon keys. 585 This protection is provided via algorithms for Authenticated 586 Encryption with Associated Data (AEAD). The permitted algorithms are 587 listed in Table 5 in Section 7. Additional algorithms can be 588 specified in the future according to the policy in that section. One 589 algorithm is selected during the negotiation described in 590 Section 3.3. The lengths "ae_key_len" and "ae_nonce_len" associated 591 with each algorithm are found in Table 3 in Section 6, together with 592 requirements for which algorithms MUST be implemented. 594 The format of an encryption frame is specified in Section 4.2. A 595 sending host breaks its stream of application data into a series of 596 chunks. Each chunk is placed in the "data" portion of a "plaintext" 597 value, which is then encrypted to yield a frame's "ciphertext" field. 598 Chunks MUST be small enough that the ciphertext (whose length depends 599 on the AEAD cipher used, and is generally slightly longer than the 600 plaintext) has length less than 2^16 bytes. 602 An "associated data" value (see Section 4.2.2) is constructed for the 603 frame. It contains the frame's "control" field and the length of the 604 ciphertext. 606 A "frame ID" value (see Section 4.2.3) is also constructed for the 607 frame, but not explicitly transmitted. It contains a 64-bit "offset" 608 field whose integer value is the zero-indexed byte offset of the 609 beginning of the current encryption frame in the underlying TCP 610 datastream. (That is, the offset in the framing stream, not the 611 plaintext application stream.) The offset is then left-padded with 612 zero-valued bytes to form a value of length "ae_nonce_len". Because 613 it is strictly necessary for the security of the AEAD algorithms 614 specified in this document, an implementation MUST NOT ever transmit 615 distinct frames with the same frame ID value under the same 616 encryption key. In particular, a retransmitted TCP segment MUST 617 contain the same payload bytes for the same TCP sequence numbers, and 618 a host MUST NOT transmit more than 2^64 bytes in the underlying TCP 619 datastream (which would cause the "offset" field to wrap) before re- 620 keying as decribed in Section 3.8. 622 With reference to the "AEAD Interface" described in Section 2 of 623 [RFC5116], tcpcrypt invokes the AEAD algorithm with values taken from 624 the traffic key "k_ab[j]" or "k_ba[j]" for some "j", according to the 625 host's role as described in Section 3.3. 627 First, the traffic key is divided into two parts: 629 ae_key_len + ae_nonce_len - 1 630 | 631 byte 0 ae_key_len | 632 | | | 633 v v v 634 +----+----+--...--+----+----+----+--...--+----+ 635 | K | NR | 636 +----+----+--...--+----+----+----+--...--+----+ 638 \_____________________________________________/ 639 traffic key 641 The first "ae_key_len" bytes of the traffic key provide the AEAD key 642 "K", while the remaining "ae_nonce_len" bytes provide a "nonce 643 randomizer" value "NR". The frame ID is then combined via bitwise 644 exclusive-or with the nonce randomizer to yield "N", the AEAD nonce 645 for the frame: 647 N = frame_ID XOR NR 649 The plaintext value serves as "P", and the associated data as "A". 650 The output of the encryption operation, "C", is transmitted in the 651 frame's "ciphertext" field. 653 When a frame is received, tcpcrypt reconstructs the associated data 654 and frame ID values (the former contains only data sent in the clear, 655 and the latter is implicit in the TCP stream), computes the nonce "N" 656 as above, and provides these and the ciphertext value to the AEAD 657 decryption operation. The output of this operation is either a 658 plaintext value "P" or the special symbol FAIL. In the latter case, 659 the implementation SHOULD abort the connection and raise an error 660 condition distinct from the end-of-file condition. But if none of 661 the TCP segment(s) containing the frame have been acknowledged and 662 retransmission could potentially result in a valid frame, an 663 implementation MAY instead drop these segments (and "renege" if they 664 have been SACKed, according to [RFC2018] Section 8). 666 3.7. TCP Header Protection 668 The "ciphertext" field of the encryption frame contains protected 669 versions of certain TCP header values. 671 When the "URGp" bit is set, the "urgent" value indicates an offset 672 from the current frame's beginning offset; the sum of these offsets 673 gives the index of the last byte of urgent data in the application 674 datastream. 676 A sender MUST set the "FINp" bit on the last frame it sends in the 677 connection (unless it aborts the connection), and MUST NOT set "FINp" 678 on any other frame. 680 TCP sets the FIN flag when a sender has no more data, which with 681 tcpcrypt means setting FIN on the segment containing the last byte of 682 the last frame. However, a receiver MUST report the end-of-file 683 condition to the connection's local user when and only when it 684 receives a frame with the "FINp" bit set. If a host receives a 685 segment with the TCP FIN flag set but the received datastream 686 including this segment does not contain a frame with "FINp" set, the 687 host SHOULD abort the connection and raise an error condition 688 distinct from the end-of-file condition. But if there are 689 unacknowledged segments whose retransmission could potentially result 690 in a valid frame, the host MAY instead drop the segment with the TCP 691 FIN flag set (and "renege" if it has been SACKed, according to 692 [RFC2018] Section 8). 694 3.8. Re-Keying 696 Re-keying allows hosts to wipe from memory keys that could decrypt 697 previously transmitted segments. It also allows the use of AEAD 698 ciphers that can securely encrypt only a bounded number of messages 699 under a given key. 701 As described above in Section 3.3, a master key "mk[j]" is used to 702 generate two encryption keys "k_ab[j]" and "k_ba[j]". We refer to 703 these as a _key-set_ with _generation number_ "j". Each host 704 maintains a _local generation number_ that determines which key-set 705 it uses to encrypt outgoing frames, and a _remote generation number_ 706 equal to the highest generation used in frames received from its 707 peer. Initially, these two generation numbers are set to zero. 709 A host MAY increment its local generation number beyond the remote 710 generation number it has recorded. We call this action _initiating 711 re-keying_. 713 When a host has incremented its local generation number and uses the 714 new key-set for the first time to encrypt an outgoing frame, it MUST 715 set "rekey = 1" for that frame. It MUST set "rekey = 0" in all other 716 cases. 718 When a host receives a frame with "rekey = 1", it increments its 719 record of the remote generation number. If the remote generation 720 number is now greater than the local generation number, the receiver 721 MUST immediately increment its local generation number to match. 722 Moreover, if the receiver has not yet transmitted a segment with the 723 FIN flag set, it MUST immediately send a frame (with empty 724 application data if necessary) with "rekey = 1". 726 A host MUST NOT initiate more than one concurrent re-key operation if 727 it has no data to send; that is, it MUST NOT initiate re-keying with 728 an empty encryption frame more than once while its record of the 729 remote generation number is less than its own. 731 Note that when parts of the datastream are retransmitted, TCP 732 requires that implementations always send the same data bytes for the 733 same TCP sequence numbers. Thus, frame data in retransmitted 734 segments MUST be encrypted with the same key as when it was first 735 transmitted, regardless of the current local generation number. 737 Implementations SHOULD delete older-generation keys from memory once 738 they have received all frames they will need to decrypt with the old 739 keys and have encrypted all outgoing frames under the old keys. 741 3.9. Keep-Alive 743 Instead of using TCP Keep-Alives to verify that the remote endpoint 744 is still responsive, tcpcrypt implementations SHOULD employ the re- 745 keying mechanism for this purpose, as follows. When necessary, a 746 host SHOULD probe the liveness of its peer by initiating re-keying 747 and transmitting a new frame immediately (with empty application data 748 if necessary). 750 As described in Section 3.8, a host receiving a frame encrypted under 751 a generation number greater than its own MUST increment its own 752 generation number and (if it has not already transmitted a segment 753 with FIN set) immediately transmit a new frame (with zero-length 754 application data if necessary). 756 Implementations MAY use TCP Keep-Alives for purposes that do not 757 require endpoint authentication, as discussed in Section 8.2. 759 4. Encodings 761 This section provides byte-level encodings for values transmitted or 762 computed by the protocol. 764 4.1. Key-Exchange Messages 766 The "Init1" message has the following encoding: 768 byte 0 1 2 3 769 +-------+-------+-------+-------+ 770 | INIT1_MAGIC | 771 | | 772 +-------+-------+-------+-------+ 774 4 5 6 7 775 +-------+-------+-------+-------+ 776 | message_len | 777 | = M | 778 +-------+-------+-------+-------+ 780 8 781 +--------+-----+----+-----+----+---...---+-----+-----+ 782 |nciphers|sym_ |sym_ | |sym_ | 783 | = K |cipher[0] |cipher[1] | |cipher[K-1]| 784 +--------+-----+----+-----+----+---...---+-----+-----+ 786 2*K + 9 2*K + 9 + N_A_LEN 787 | | 788 v v 789 +-------+---...---+-------+-------+---...---+-------+ 790 | N_A | Pub_A | 791 | | | 792 +-------+---...---+-------+-------+---...---+-------+ 794 M - 1 795 +-------+---...---+-------+ 796 | ignored | 797 | | 798 +-------+---...---+-------+ 800 The constant "INIT1_MAGIC" is defined in Section 4.3. The four-byte 801 field "message_len" gives the length of the entire "Init1" message, 802 encoded as a big-endian integer. The "nciphers" field contains an 803 integer value that specifies the number of two-byte symmetric-cipher 804 identifiers that follow. The "sym_cipher[i]" identifiers indicate 805 cryptographic algorithms in Table 5 in Section 7. The length 806 "N_A_LEN" and the length of "Pub_A" are both determined by the 807 negotiated TEP, as described in Section 5. 809 Implementations of this protocol MUST construct "Init1" such that the 810 field "ignored" has zero length; that is, they MUST construct the 811 message such that its end, as determined by "message_len", coincides 812 with the end of the field "Pub_A". When receiving "Init1", however, 813 implementations MUST permit and ignore any bytes following "Pub_A". 815 The "Init2" message has the following encoding: 817 byte 0 1 2 3 818 +-------+-------+-------+-------+ 819 | INIT2_MAGIC | 820 | | 821 +-------+-------+-------+-------+ 823 4 5 6 7 8 9 824 +-------+-------+-------+-------+-------+-------+ 825 | message_len | sym_cipher | 826 | = M | | 827 +-------+-------+-------+-------+-------+-------+ 829 10 10 + N_B_LEN 830 | | 831 v v 832 +-------+---...---+-------+-------+---...---+-------+ 833 | N_B | Pub_B | 834 | | | 835 +-------+---...---+-------+-------+---...---+-------+ 837 M - 1 838 +-------+---...---+-------+ 839 | ignored | 840 | | 841 +-------+---...---+-------+ 843 The constant "INIT2_MAGIC" is defined in Section 4.3. The four-byte 844 field "message_len" gives the length of the entire "Init2" message, 845 encoded as a big-endian integer. The "sym_cipher" value is a 846 selection from the symmetric-cipher identifiers in the previously- 847 received "Init1" message. The length "N_B_LEN" and the length of 848 "Pub_B" are both determined by the negotiated TEP, as described in 849 Section 5. 851 Implementations of this protocol MUST construct "Init2" such that the 852 field "ignored" has zero length; that is, they MUST construct the 853 message such that its end, as determined by "message_len", coincides 854 with the end of the "Pub_B" field. When receiving "Init2", however, 855 implementations MUST permit and ignore any bytes following "Pub_B". 857 4.2. Encryption Frames 859 An _encryption frame_ comprises a control byte and a length-prefixed 860 ciphertext value: 862 byte 0 1 2 3 clen+2 863 +-------+-------+-------+-------+---...---+-------+ 864 |control| clen | ciphertext | 865 +-------+-------+-------+-------+---...---+-------+ 867 The field "clen" is an integer in big-endian format and gives the 868 length of the "ciphertext" field. 870 The byte "control" has this structure: 872 bit 7 1 0 873 +-------+---...---+-------+-------+ 874 | cres | rekey | 875 +-------+---...---+-------+-------+ 877 The seven-bit field "cres" is reserved; implementations MUST set 878 these bits to zero when sending, and MUST ignore them when receiving. 880 The use of the "rekey" field is described in Section 3.8. 882 4.2.1. Plaintext 884 The "ciphertext" field is the result of applying the negotiated 885 authenticated-encryption algorithm to a "plaintext" value, which has 886 one of these two formats: 888 byte 0 1 plen-1 889 +-------+-------+---...---+-------+ 890 | flags | data | 891 +-------+-------+---...---+-------+ 893 byte 0 1 2 3 plen-1 894 +-------+-------+-------+-------+---...---+-------+ 895 | flags | urgent | data | 896 +-------+-------+-------+-------+---...---+-------+ 898 (Note that "clen" in the previous section will generally be greater 899 than "plen", as the ciphertext produced by the authenticated- 900 encryption scheme both encrypts the application data and provides 901 redundancy with which to verify its integrity.) 903 The "flags" byte has this structure: 905 bit 7 6 5 4 3 2 1 0 906 +----+----+----+----+----+----+----+----+ 907 | fres |URGp|FINp| 908 +----+----+----+----+----+----+----+----+ 910 The six-bit value "fres" is reserved; implementations MUST set these 911 six bits to zero when sending, and MUST ignore them when receiving. 913 When the "URGp" bit is set, it indicates that the "urgent" field is 914 present, and thus that the plaintext value has the second structure 915 variant above; otherwise the first variant is used. 917 The meaning of "urgent" and of the flag bits is described in 918 Section 3.7. 920 4.2.2. Associated Data 922 An encryption frame's "associated data" (which is supplied to the 923 AEAD algorithm when decrypting the ciphertext and verifying the 924 frame's integrity) has this format: 926 byte 0 1 2 927 +-------+-------+-------+ 928 |control| clen | 929 +-------+-------+-------+ 931 It contains the same values as the frame's "control" and "clen" 932 fields. 934 4.2.3. Frame ID 936 Lastly, a "frame ID" (used to construct the nonce for the AEAD 937 algorithm) has this format: 939 byte 0 ae_nonce_len - 8 ae_nonce_len - 1 940 | | | 941 v v v 942 +-----+--...--+-----+-----+--...--+-----+ 943 | 0 | | 0 | offset | 944 +-----+--...--+-----+-----+--...--+-----+ 946 The 8-byte "offset" field contains an integer in big-endian format. 947 Its value is specified in Section 3.6. Zero-valued bytes are 948 prepended to the "offset" field to form a structure of length 949 "ae_nonce_len". 951 4.3. Constant Values 953 The table below defines values for the constants used in the 954 protocol. 956 +------------+--------------+ 957 | Value | Name | 958 +------------+--------------+ 959 | 0x01 | CONST_NEXTK | 960 | 0x02 | CONST_SESSID | 961 | 0x03 | CONST_REKEY | 962 | 0x04 | CONST_KEY_A | 963 | 0x05 | CONST_KEY_B | 964 | 0x06 | CONST_RESUME | 965 | 0x15101a0e | INIT1_MAGIC | 966 | 0x097105e0 | INIT2_MAGIC | 967 +------------+--------------+ 969 Table 1: Constant values used in the protocol 971 5. Key-Agreement Schemes 973 The TEP negotiated via TCP-ENO indicates the use of one of the key- 974 agreement schemes named in Table 4 in Section 7. For example, 975 "TCPCRYPT_ECDHE_P256" names the tcpcrypt protocol using ECDHE-P256 976 together with the CPRF and length parameters specified below. 978 All the TEPs specified in this document require the use of HKDF- 979 Expand-SHA256 as the CPRF, and these lengths for nonces and session 980 secrets: 982 N_A_LEN: 32 bytes 983 N_B_LEN: 32 bytes 984 K_LEN: 32 bytes 986 Future documents assigning additional TEPs for use with tcpcrypt 987 mmight specify different values for the lengths above. Note that the 988 minimum session ID length specified by TCP-ENO, together with the way 989 tcpcrypt constructs session IDs, implies that "K_LEN" MUST have 990 length at least 32 bytes. 992 Key-agreement schemes ECDHE-P256 and ECDHE-P521 employ the ECSVDP-DH 993 secret value derivation primitive defined in [IEEE-1363]. The named 994 curves are defined in [NIST-DSS]. When the public-key values "Pub_A" 995 and "Pub_B" are transmitted as described in Section 4.1, they are 996 encoded with the "Elliptic Curve Point to Octet String Conversion 997 Primitive" described in Section E.2.3 of [IEEE-1363], and are 998 prefixed by a two-byte length in big-endian format: 1000 byte 0 1 2 L - 1 1001 +-------+-------+-------+---...---+-------+ 1002 | pubkey_len | pubkey | 1003 | = L | | 1004 +-------+-------+-------+---...---+-------+ 1006 Implementations MUST encode these "pubkey" values in "compressed 1007 format". Implementations MUST validate these "pubkey" values 1008 according to the algorithm in [IEEE-1363] Section A.16.10. 1010 Key-agreement schemes ECDHE-Curve25519 and ECDHE-Curve448 use the 1011 functions X25519 and X448, respectively, to perform the Diffie-Helman 1012 protocol as described in [RFC7748]. When using these ciphers, 1013 public-key values "Pub_A" and "Pub_B" are transmitted directly with 1014 no length prefix: 32 bytes for Curve25519, and 56 bytes for Curve448. 1016 Table 2 below specifies the requirement levels of the four TEPs 1017 specified in this document. In particular, all implementations of 1018 tcpcrypt MUST support TCPCRYPT_ECDHE_Curve25519. However, system 1019 administrators MAY configure which TEPs a host will negotiate 1020 independent of these implementation requirements. 1022 +-------------+---------------------------+ 1023 | Requirement | TEP | 1024 +-------------+---------------------------+ 1025 | REQUIRED | TCPCRYPT_ECDHE_Curve25519 | 1026 | RECOMMENDED | TCPCRYPT_ECDHE_Curve448 | 1027 | OPTIONAL | TCPCRYPT_ECDHE_P256 | 1028 | OPTIONAL | TCPCRYPT_ECDHE_P521 | 1029 +-------------+---------------------------+ 1031 Table 2: Requirements for implementation of TEPs 1033 6. AEAD Algorithms 1035 This document uses "sym-cipher" identifiers in the messages "Init1" 1036 and "Init2" (see Section 3.3) to negotiate the use of AEAD 1037 algorithms; the values of these identifiers are given in Table 5 in 1038 Section 7. The algorithms "AEAD_AES_128_GCM" and "AEAD_AES_256_GCM" 1039 are specified in [RFC5116]. The algorithm "AEAD_CHACHA20_POLY1305" 1040 is specified in [RFC7539]. 1042 Implementations MUST support certain AEAD algorithms according to 1043 Table 3 below. Note that system administrators MAY configure which 1044 algorithms a host will negotiate independent of these requirements. 1046 Lastly, this document uses the lengths "ae_key_len" and 1047 "ae_nonce_len" to specify aspects of encryption and data formats. 1049 These values depend on the negotiated AEAD algorithm, also according 1050 to the table below. 1052 +------------------------+-------------+------------+--------------+ 1053 | AEAD Algorithm | Requirement | ae_key_len | ae_nonce_len | 1054 +------------------------+-------------+------------+--------------+ 1055 | AEAD_AES_128_GCM | REQUIRED | 16 bytes | 12 bytes | 1056 | AEAD_AES_256_GCM | RECOMMENDED | 32 bytes | 12 bytes | 1057 | AEAD_CHACHA20_POLY1305 | RECOMMENDED | 32 bytes | 12 bytes | 1058 +------------------------+-------------+------------+--------------+ 1060 Table 3: Requirement and lengths for each AEAD algorithm 1062 7. IANA Considerations 1064 For use with TCP-ENO's negotiation mechanism, tcpcrypt's TEP 1065 identifiers will need to be incorporated in IANA's "TCP encryption 1066 protocol identifiers" registry under the "Transmission Control 1067 Protocol (TCP) Parameters" registry, as in Table 4 below. The 1068 various key-agreement schemes used by these tcpcrypt variants are 1069 defined in Section 5. 1071 +-------+---------------------------+-----------+ 1072 | Value | Meaning | Reference | 1073 +-------+---------------------------+-----------+ 1074 | 0x21 | TCPCRYPT_ECDHE_P256 | [RFC-TBD] | 1075 | 0x22 | TCPCRYPT_ECDHE_P521 | [RFC-TBD] | 1076 | 0x23 | TCPCRYPT_ECDHE_Curve25519 | [RFC-TBD] | 1077 | 0x24 | TCPCRYPT_ECDHE_Curve448 | [RFC-TBD] | 1078 +-------+---------------------------+-----------+ 1080 Table 4: TEP identifiers for use with tcpcrypt 1082 In Section 6, this document defines the use of several AEAD 1083 algorithms for encrypting application data. To name these 1084 algorithms, the tcpcrypt protocol uses two-byte identifiers in the 1085 range 0x0001 to 0xFFFF inclusive, for which IANA is to maintain a new 1086 "tcpcrypt AEAD Algorithm" registry under the "Transmission Control 1087 Protocol (TCP) Parameters" registry. The initial values for this 1088 registry are given in Table 5 below. Future assignments are to be 1089 made upon satisfying either of two policies defined in [RFC8126]: 1090 "IETF Review" or (for non-IETF stream specifications) "Expert Review 1091 with RFC Required." IANA will furthermore provide early allocation 1092 [RFC7120] to facilitate testing before RFCs are finalized. 1094 +--------+------------------------+---------------------+ 1095 | Value | AEAD Algorithm | Reference | 1096 +--------+------------------------+---------------------+ 1097 | 0x0001 | AEAD_AES_128_GCM | [RFC-TBD] Section 6 | 1098 | 0x0002 | AEAD_AES_256_GCM | [RFC-TBD] Section 6 | 1099 | 0x0010 | AEAD_CHACHA20_POLY1305 | [RFC-TBD] Section 6 | 1100 +--------+------------------------+---------------------+ 1102 Table 5: Authenticated-encryption algorithms for use with tcpcrypt 1104 8. Security Considerations 1106 All of the security considerations of TCP-ENO apply to tcpcrypt. In 1107 particular, tcpcrypt does not protect against active network 1108 attackers unless applications authenticate the session ID. If it can 1109 be established that the session IDs computed at each end of the 1110 connection match, then tcpcrypt guarantees that no man-in-the-middle 1111 attacks occurred unless the attacker has broken the underlying 1112 cryptographic primitives (e.g., ECDH). A proof of this property for 1113 an earlier version of the protocol has been published [tcpcrypt]. 1115 To ensure middlebox compatibility, tcpcrypt does not protect TCP 1116 headers. Hence, the protocol is vulnerable to denial-of-service from 1117 off-path attackers just as plain TCP is. Possible attacks include 1118 desynchronizing the underlying TCP stream, injecting RST or FIN 1119 segments, and forging re-key bits. These attacks will cause a 1120 tcpcrypt connection to hang or fail with an error, but not in any 1121 circumstance where plain TCP could continue uncorrupted. 1122 Implementations MUST give higher-level software a way to distinguish 1123 such errors from a clean end-of-stream (indicated by an authenticated 1124 "FINp" bit) so that applications can avoid semantic truncation 1125 attacks. 1127 There is no "key confirmation" step in tcpcrypt. This is not needed 1128 because tcpcrypt's threat model includes the possibility of a 1129 connection to an adversary. If key negotiation is compromised and 1130 yields two different keys, failed integrity checks on every 1131 subsequent frame will cause the connection either to hang or to 1132 abort. This is not a new threat as an active attacker can achieve 1133 the same results against a plain TCP connection by injecting RST 1134 segments or modifying sequence and acknowledgement numbers. 1136 Tcpcrypt uses short-lived public keys to provide forward secrecy. 1137 That is, once an implementation removes these keys from memory, a 1138 compromise of the system will not provide any means to derive the 1139 session secrets for past connections. All currently-specified key 1140 agreement schemes involve ECDHE-based key agreement, meaning a new 1141 key-pair can be efficiently computed for each connection. If 1142 implementations reuse these parameters, they MUST limit the lifetime 1143 of the private parameters as far as practical in order to minimize 1144 the number of past connections that are vulnerable. Of course, 1145 placing private keys in persistent storage introduces severe risks 1146 that they will not be destroyed reliably and in a timely fashion, and 1147 SHOULD be avoided at all costs. 1149 Attackers cannot force passive openers to move forward in their 1150 session resumption chain without guessing the content of the 1151 resumption identifier, which will be difficult without key knowledge. 1153 The cipher-suites specified in this document all use HMAC-SHA256 to 1154 implement the collision-resistant pseudo-random function denoted by 1155 "CPRF". A collision-resistant function is one for which, for 1156 sufficiently large L, an attacker cannot find two distinct inputs 1157 (K_1, CONST_1) and (K_2, CONST_2) such that CPRF(K_1, CONST_1, L) = 1158 CPRF(K_2, CONST_2, L). Collision resistance is important to assure 1159 the uniqueness of session IDs, which are generated using the CPRF. 1161 Lastly, many of tcpcrypt's cryptographic functions require random 1162 input, and thus any host implementing tcpcrypt MUST have access to a 1163 cryptographically-secure source of randomness or pseudo-randomness. 1164 [RFC4086] provides recommendations on how to achieve this. 1166 Most implementations will rely on a device's pseudo-random generator, 1167 seeded from hardware events and a seed carried over from the previous 1168 boot. Once a pseudo-random generator has been properly seeded, it 1169 can generate effectively arbitrary amounts of pseudo-random data. 1170 However, until a pseudo-random generator has been seeded with 1171 sufficient entropy, not only will tcpcrypt be insecure, it will 1172 reveal information that further weakens the security of the pseudo- 1173 random generator, potentially harming other applications. As 1174 REQUIRED by TCP-ENO, implementations MUST NOT send ENO options unless 1175 they have access to an adequate source of randomness. 1177 8.1. Asymmetric Roles 1179 Tcpcrypt transforms a shared pseudo-random key (PRK) into 1180 cryptographic traffic keys for each direction. Doing so requires an 1181 asymmetry in the protocol, as the key derivation function must be 1182 perturbed differently to generate different keys in each direction. 1183 Tcpcrypt includes other asymmetries in the roles of the two hosts, 1184 such as the process of negotiating algorithms (e.g., proposing vs. 1185 selecting cipher suites). 1187 8.2. Verified Liveness 1189 Many hosts implement TCP Keep-Alives [RFC1122] as an option for 1190 applications to ensure that the other end of a TCP connection still 1191 exists even when there is no data to be sent. A TCP Keep-Alive 1192 segment carries a sequence number one prior to the beginning of the 1193 send window, and may carry one byte of "garbage" data. Such a 1194 segment causes the remote side to send an acknowledgment. 1196 Unfortunately, tcpcrypt cannot cryptographically verify Keep-Alive 1197 acknowledgments. Hence, an attacker could prolong the existence of a 1198 session at one host after the other end of the connection no longer 1199 exists. (Such an attack might prevent a process with sensitive data 1200 from exiting, giving an attacker more time to compromise a host and 1201 extract the sensitive data.) 1203 To counter this threat, tcpcrypt specifies a way to stimulate the 1204 remote host to send verifiably fresh and authentic data, described in 1205 Section 3.9. 1207 The TCP keep-alive mechanism has also been used for its effects on 1208 intermediate nodes in the network, such as preventing flow state from 1209 expiring at NAT boxes or firewalls. As these purposes do not require 1210 the authentication of endpoints, implementations MAY safely 1211 accomplish them using either the existing TCP keep-alive mechanism or 1212 tcpcrypt's verified keep-alive mechanism. 1214 8.3. Mandatory Key-Agreement Schemes 1216 This document mandates that tcpcrypt implementations provide support 1217 for at least one key-agreement scheme: ECDHE using Curve25519. This 1218 choice of a single mandatory algorithm is the result of a difficult 1219 tradeoff between cryptographic diversity and the ease and security of 1220 actual deployment. 1222 The IETF's appraisal of best current practice on this matter 1223 [RFC7696] says, "Ideally, two independent sets of mandatory-to- 1224 implement algorithms will be specified, allowing for a primary suite 1225 and a secondary suite. This approach ensures that the secondary 1226 suite is widely deployed if a flaw is found in the primary one." 1228 To meet that ideal, it might appear natural to also mandate ECDHE 1229 using P-256, as this scheme is well-studied, widely implemented, and 1230 sufficiently different from the Curve25519-based scheme that it is 1231 unlikely they will both suffer from a single (non-quantum) 1232 cryptanalytic advance. 1234 However, implementing the Diffie-Hellman function using NIST elliptic 1235 curves (including those specified for use with tcpcrypt, P-256 and 1236 P-521) appears to be very difficult to achieve without introducing 1237 vulnerability to side-channel attacks [NIST-fail]. Although well- 1238 trusted implementations are available as part of large cryptographic 1239 libraries, these can be difficult to extract for use in operating- 1240 system kernels where tcpcrypt is usually best implemented. In 1241 contrast, the characteristics of Curve25519 together with its recent 1242 popularity has led to many safe and efficient implementations, 1243 including some that fit naturally into the kernel environment. 1245 [RFC7696] insists that, "The selected algorithms need to be resistant 1246 to side-channel attacks and also meet the performance, power, and 1247 code size requirements on a wide variety of platforms." On this 1248 principle, tcpcrypt excludes the NIST curves from the set of 1249 mandatory-to-implement key-agreement algorithms. 1251 Lastly, this document encourages support for key-agreement with 1252 Curve448, categorizing it as RECOMMENDED. Curve448 appears likely to 1253 admit safe and efficient implementations. However, support is not 1254 REQUIRED because existing implementations might not yet be 1255 sufficiently well-proven. 1257 9. Experiments 1259 Some experience will be required to determine whether the tcpcrypt 1260 protocol can be deployed safely and successfully across the diverse 1261 environments of the global internet. 1263 Safety means that TCP implementations that support tcpcrypt are able 1264 to communicate reliably in all the same settings as they would 1265 without tcpcrypt. As described in [I-D.ietf-tcpinc-tcpeno] 1266 Section 9, this property can be subverted if middleboxes strip ENO 1267 options from non-SYN segments after allowing them in SYN segments; or 1268 if the particular communication patterns of tcpcrypt offend the 1269 policies of middleboxes doing deep-packet inspection. 1271 Success, in addition to safety, means hosts that implement tcpcrypt 1272 actually enable encryption when connecting to one another. This 1273 property depends on the network's treatment of the TCP-ENO handshake, 1274 and can be subverted if middleboxes merely strip unknown TCP options 1275 or if they terminate TCP connections and relay data back and forth 1276 unencrypted. 1278 Ease of implementation will be a further challenge to deployment. 1279 Because tcpcrypt requires encryption operations on frames that may 1280 span TCP segments, kernel implementations are forced to buffer 1281 segments in different ways than are necessary for plain TCP. More 1282 implementation experience will show how much additional code 1283 complexity is required in various operating systems, and what kind of 1284 performance effects can be expected. 1286 10. Acknowledgments 1288 We are grateful for contributions, help, discussions, and feedback 1289 from the TCPINC working group and from other IETF reviewers, 1290 including Marcelo Bagnulo, David Black, Bob Briscoe, Jana Iyengar, 1291 Stephen Kent, Tero Kivinen, Mirja Kuhlewind, Yoav Nir, Christoph 1292 Paasch, Eric Rescorla, Kyle Rose, and Dale Worley. 1294 This work was funded by gifts from Intel (to Brad Karp) and from 1295 Google; by NSF award CNS-0716806 (A Clean-Slate Infrastructure for 1296 Information Flow Control); by DARPA CRASH under contract 1297 #N66001-10-2-4088; and by the Stanford Secure Internet of Things 1298 Project. 1300 11. Contributors 1302 Dan Boneh and Michael Hamburg were co-authors of the draft that 1303 became this document. 1305 12. References 1307 12.1. Normative References 1309 [I-D.ietf-tcpinc-tcpeno] 1310 Bittau, A., Giffin, D., Handley, M., Mazieres, D., and E. 1311 Smith, "TCP-ENO: Encryption Negotiation Option", draft- 1312 ietf-tcpinc-tcpeno-18 (work in progress), November 2017. 1314 [IEEE-1363] 1315 IEEE, "IEEE Standard Specifications for Public-Key 1316 Cryptography (IEEE Std 1363-2000)", 2000. 1318 [NIST-DSS] 1319 NIST, "FIPS PUB 186-4: Digital Signature Standard (DSS)", 1320 2013. 1322 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 1323 RFC 793, DOI 10.17487/RFC0793, September 1981, 1324 . 1326 [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 1327 Selective Acknowledgment Options", RFC 2018, 1328 DOI 10.17487/RFC2018, October 1996, 1329 . 1331 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1332 Hashing for Message Authentication", RFC 2104, 1333 DOI 10.17487/RFC2104, February 1997, 1334 . 1336 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1337 Requirement Levels", BCP 14, RFC 2119, 1338 DOI 10.17487/RFC2119, March 1997, 1339 . 1341 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 1342 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1343 . 1345 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1346 Key Derivation Function (HKDF)", RFC 5869, 1347 DOI 10.17487/RFC5869, May 2010, 1348 . 1350 [RFC7120] Cotton, M., "Early IANA Allocation of Standards Track Code 1351 Points", BCP 100, RFC 7120, DOI 10.17487/RFC7120, January 1352 2014, . 1354 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1355 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 1356 . 1358 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 1359 for Security", RFC 7748, DOI 10.17487/RFC7748, January 1360 2016, . 1362 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 1363 Writing an IANA Considerations Section in RFCs", BCP 26, 1364 RFC 8126, DOI 10.17487/RFC8126, June 2017, 1365 . 1367 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1368 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1369 May 2017, . 1371 12.2. Informative References 1373 [I-D.ietf-tcpinc-api] 1374 Bittau, A., Boneh, D., Giffin, D., Handley, M., Mazieres, 1375 D., and E. Smith, "Interface Extensions for TCP-ENO and 1376 tcpcrypt", draft-ietf-tcpinc-api-05 (work in progress), 1377 September 2017. 1379 [NIST-fail] 1380 Bernstein, D. and T. Lange, "Failures in NIST's ECC 1381 standards", 2016, 1382 . 1384 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 1385 Communication Layers", STD 3, RFC 1122, 1386 DOI 10.17487/RFC1122, October 1989, 1387 . 1389 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 1390 "Randomness Requirements for Security", BCP 106, RFC 4086, 1391 DOI 10.17487/RFC4086, June 2005, 1392 . 1394 [RFC7696] Housley, R., "Guidelines for Cryptographic Algorithm 1395 Agility and Selecting Mandatory-to-Implement Algorithms", 1396 BCP 201, RFC 7696, DOI 10.17487/RFC7696, November 2015, 1397 . 1399 [tcpcrypt] 1400 Bittau, A., Hamburg, M., Handley, M., Mazieres, D., and D. 1401 Boneh, "The case for ubiquitous transport-level 1402 encryption", USENIX Security , 2010. 1404 Authors' Addresses 1406 Andrea Bittau 1407 Google 1408 345 Spear Street 1409 San Francisco, CA 94105 1410 US 1412 Email: bittau@google.com 1414 Daniel B. Giffin 1415 Stanford University 1416 353 Serra Mall, Room 288 1417 Stanford, CA 94305 1418 US 1420 Email: dbg@scs.stanford.edu 1421 Mark Handley 1422 University College London 1423 Gower St. 1424 London WC1E 6BT 1425 UK 1427 Email: M.Handley@cs.ucl.ac.uk 1429 David Mazieres 1430 Stanford University 1431 353 Serra Mall, Room 290 1432 Stanford, CA 94305 1433 US 1435 Email: dm@uun.org 1437 Quinn Slack 1438 Sourcegraph 1439 121 2nd St Ste 200 1440 San Francisco, CA 94105 1441 US 1443 Email: sqs@sourcegraph.com 1445 Eric W. Smith 1446 Kestrel Institute 1447 3260 Hillview Avenue 1448 Palo Alto, CA 94304 1449 US 1451 Email: eric.smith@kestrel.edu