idnits 2.17.1 draft-ietf-tcpinc-tcpcrypt-14.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 (November 4, 2018) is 1999 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 781 -- Looks like a reference, but probably isn't: '1' on line 781 == Missing Reference: 'K-1' is mentioned on line 781, but not defined == Missing Reference: 'RFC-TBD' is mentioned on line 1099, but not defined ** Obsolete normative reference: RFC 793 (Obsoleted by RFC 9293) ** Obsolete normative reference: RFC 7539 (Obsoleted by RFC 8439) Summary: 2 errors (**), 0 flaws (~~), 3 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: May 8, 2019 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 November 4, 2018 16 Cryptographic protection of TCP Streams (tcpcrypt) 17 draft-ietf-tcpinc-tcpcrypt-14 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 May 8, 2019. 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. The value MUST be chosen randomly or 426 using a mechanism that guarantees uniqueness even in the face of 427 virtual machine cloning or other re-execution of the same session. 428 An attacker who can force either side of a connection to reuse a 429 session secret with the same nonce will completely break the security 430 of tcpcrypt. Reuse of session secrets is possible in the event of 431 virtual machine cloning or reuse of system-level hibernation state. 432 Implementations SHOULD provide an API through which to set the 433 resumption nonce length, and MUST default to eight bytes if they 434 cannot prohibit the reuse of session secrets. 436 The resumption identifier is calculated from a session secret "ss[i]" 437 as follows: 439 resume[i] = CPRF(ss[i], CONST_RESUME, 18) 441 To name a session for resumption, a host sends either the first or 442 second half of the resumption identifier, according to the role it 443 played in the original session with secret "ss[0]". 445 A host that originally played role "A" and wishes to resume from a 446 cached session sends a suboption with the first half of the 447 resumption identifier: 449 byte 0 1 9 10 450 +------+------+--...--+------+------+--...--+------+ 451 | TEP- | resume[i]{0..8} | nonce_a | 452 | byte | | | 453 +------+------+--...--+------+------+--...--+------+ 455 Figure 2: Resumption suboption sent when original role was "A". The 456 TEP-byte contains a tcpcrypt TEP identifier and v = 1. The nonce 457 value MUST have length between 0 and 8 bytes. 459 Similarly, a host that originally played role "B" sends a suboption 460 with the second half of the resumption identifier: 462 byte 0 1 9 10 463 +------+------+--...--+------+------+--...--+------+ 464 | TEP- | resume[i]{9..17} | nonce_b | 465 | byte | | | 466 +------+------+--...--+------+------+--...--+------+ 468 Figure 3: Resumption suboption sent when original role was "B". The 469 TEP-byte contains a tcpcrypt TEP identifier and v = 1. The nonce 470 value MUST have length between 0 and 8 bytes. 472 If a passive opener receives a resumption suboption containing an 473 identifier-half that names a session secret that it has cached and 474 the subobtion's TEP matches the TEP used in the previous session, it 475 SHOULD (with exceptions specified below) agree to resume from the 476 cached session by sending its own resumption suboption, which will 477 contain the other half of the identifier. Otherwise, it MUST NOT 478 agree to resumption. 480 If a passive opener does not agree to resumption with a particular 481 TEP, it MAY either request fresh key exchange by responding with a 482 non-resumption suboption using the same TEP, or else respond to any 483 other received TEP suboption. 485 If a passive opener receives an ENO suboption with a TEP identifier 486 and "v = 1", but the suboption data is less than 9 bytes in length, 487 it MUST behave as if the same TEP had been sent with "v = 0". That 488 is, the suboption MUST be interpreted as an offer to negotiate fresh 489 key exchange with that TEP. 491 If an active opener sends a resumption suboption with a particular 492 TEP and the appropriate half of a resumption identifier and then, in 493 the same TCP handshake, receives a resumption suboption with the same 494 TEP and an identifier-half that does not match that resumption 495 identifier, it MUST ignore that suboption. In the typical case that 496 this was the only ENO suboption received, this means the host MUST 497 disable TCP-ENO and tcpcrypt: that is, it MUST NOT send any more ENO 498 options and MUST NOT encrypt the connection. 500 When a host concludes that TCP-ENO negotiation has succeeded for some 501 TEP that was received in a resumption suboption, it MUST then enable 502 encryption with that TEP using the cached session secret. To do 503 this, it first constructs "sn[i]" as follows: 505 sn[i] = nonce_a | nonce_b 507 Master keys are then computed from "s[i]" and "sn[i]" as described in 508 Section 3.3, and application data encrypted as described in 509 Section 3.6. 511 The session ID (Section 3.4) is constructed in the same way for 512 resumed sessions as it is for fresh ones. In this case the first 513 byte will always have "v = 1". The remainder of the ID is derived 514 from the cached session secret and the session nonce that was 515 generated during resumption. 517 In the case of simultaneous open where TCP-ENO is able to establish 518 asymmetric roles, two hosts that simultaneously send SYN segments 519 with compatible resumption suboptions MAY resume the associated 520 session. 522 In a particular SYN segment, a host SHOULD NOT send more than one 523 resumption suboption (because this consumes TCP option space and is 524 unlikely to be a useful practice), and MUST NOT send more than one 525 resumption suboption with the same TEP identifier. But in addition 526 to any resumption suboptions, an active opener MAY include non- 527 resumption suboptions describing other TEPs it supports (in addition 528 to the TEP in the resumption suboption). 530 After using the session secret "ss[i]" to compute "mk[0]", 531 implementations SHOULD compute and cache "ss[i+1]" for possible use 532 by a later session, then erase "ss[i]" from memory. Hosts MAY retain 533 "ss[i+1]" until it is used or the memory needs to be reclaimed. 534 Hosts SHOULD NOT write any session secrets to non-volatile storage. 536 When proposing resumption, the active opener MUST use the lowest 537 value of "i" that has not already been used (successfully or not) to 538 negotiate resumption with the same host and for the same original 539 session secret "ss[0]". 541 A given session secret "ss[i]" MUST NOT be used to secure more than 542 one TCP connection. To prevent this, a host MUST NOT resume with a 543 session secret if it has ever enabled encryption in the past with the 544 same secret, in either role. In the event that two hosts 545 simultaneously send SYN segments to each other that propose 546 resumption with the same session secret but the two segments are not 547 part of a simultaneous open, both connections would need to revert to 548 fresh key-exchange. To avoid this limitation, implementations MAY 549 choose to implement session resumption such that all session secrets 550 derived from a given "ss[0]" are used for either passive or active 551 opens at the same host, not both. 553 If two hosts have previously negotiated a tcpcrypt session, either 554 host MAY later initiate session resumption regardless of which host 555 was the active opener or played the "A" role in the previous session. 557 However, a given host MUST either encrypt with keys "k_ab[j]" for all 558 sessions derived from the same original session secret "ss[0]", or 559 with keys "k_ba[j]". Thus, which keys a host uses to send segments 560 is not affected by the role it plays in the current connection: it 561 depends only on whether the host played the "A" or "B" role in the 562 initial session. 564 Implementations that cache session secrets MUST provide a means for 565 applications to control that caching. In particular, when an 566 application requests a new TCP connection, it MUST have a way to 567 specify two policies for the duration of the connection: 1) that 568 resumption requests will be ignored, and thus fresh key exchange will 569 be necessary; and 2) that no session secrets will be cached. (These 570 policies can be specified independently or as a unit.) And for an 571 established connection, an application MUST have a means to cause any 572 cache state that was used in or resulted from establishing the 573 connection to be flushed. A companion document [I-D.ietf-tcpinc-api] 574 describes recommended interfaces for this purpose. 576 3.6. Data Encryption and Authentication 578 Following key exchange (or its omission via session resumption), all 579 further communication in a tcpcrypt-enabled connection is carried out 580 within delimited _encryption frames_ that are encrypted and 581 authenticated using the agreed upon keys. 583 This protection is provided via algorithms for Authenticated 584 Encryption with Associated Data (AEAD). The permitted algorithms are 585 listed in Table 5 in Section 7. Additional algorithms can be 586 specified in the future according to the policy in that section. One 587 algorithm is selected during the negotiation described in 588 Section 3.3. The lengths "ae_key_len" and "ae_nonce_len" associated 589 with each algorithm are found in Table 3 in Section 6, together with 590 requirements for which algorithms MUST be implemented. 592 The format of an encryption frame is specified in Section 4.2. A 593 sending host breaks its stream of application data into a series of 594 chunks. Each chunk is placed in the "data" portion of a "plaintext" 595 value, which is then encrypted to yield a frame's "ciphertext" field. 596 Chunks MUST be small enough that the ciphertext (whose length depends 597 on the AEAD cipher used, and is generally slightly longer than the 598 plaintext) has length less than 2^16 bytes. 600 An "associated data" value (see Section 4.2.2) is constructed for the 601 frame. It contains the frame's "control" field and the length of the 602 ciphertext. 604 A "frame ID" value (see Section 4.2.3) is also constructed for the 605 frame, but not explicitly transmitted. It contains a 64-bit "offset" 606 field whose integer value is the zero-indexed byte offset of the 607 beginning of the current encryption frame in the underlying TCP 608 datastream. (That is, the offset in the framing stream, not the 609 plaintext application stream.) The offset is then left-padded with 610 zero-valued bytes to form a value of length "ae_nonce_len". Because 611 it is strictly necessary for the security of the AEAD algorithms 612 specified in this document, an implementation MUST NOT ever transmit 613 distinct frames with the same frame ID value under the same 614 encryption key. In particular, a retransmitted TCP segment MUST 615 contain the same payload bytes for the same TCP sequence numbers, and 616 a host MUST NOT transmit more than 2^64 bytes in the underlying TCP 617 datastream (which would cause the "offset" field to wrap) before re- 618 keying as decribed in Section 3.8. 620 With reference to the "AEAD Interface" described in Section 2 of 621 [RFC5116], tcpcrypt invokes the AEAD algorithm with values taken from 622 the traffic key "k_ab[j]" or "k_ba[j]" for some "j", according to the 623 host's role as described in Section 3.3. 625 First, the traffic key is divided into two parts: 627 ae_key_len + ae_nonce_len - 1 628 | 629 byte 0 ae_key_len | 630 | | | 631 v v v 632 +----+----+--...--+----+----+----+--...--+----+ 633 | K | NR | 634 +----+----+--...--+----+----+----+--...--+----+ 636 \_____________________________________________/ 637 traffic key 639 The first "ae_key_len" bytes of the traffic key provide the AEAD key 640 "K", while the remaining "ae_nonce_len" bytes provide a "nonce 641 randomizer" value "NR". The frame ID is then combined via bitwise 642 exclusive-or with the nonce randomizer to yield "N", the AEAD nonce 643 for the frame: 645 N = frame_ID XOR NR 647 The plaintext value serves as "P", and the associated data as "A". 648 The output of the encryption operation, "C", is transmitted in the 649 frame's "ciphertext" field. 651 When a frame is received, tcpcrypt reconstructs the associated data 652 and frame ID values (the former contains only data sent in the clear, 653 and the latter is implicit in the TCP stream), computes the nonce "N" 654 as above, and provides these and the ciphertext value to the AEAD 655 decryption operation. The output of this operation is either a 656 plaintext value "P" or the special symbol FAIL. In the latter case, 657 the implementation SHOULD abort the connection and raise an error 658 condition distinct from the end-of-file condition. But if none of 659 the TCP segment(s) containing the frame have been acknowledged and 660 retransmission could potentially result in a valid frame, an 661 implementation MAY instead drop these segments (and "renege" if they 662 have been SACKed, according to [RFC2018] Section 8). 664 3.7. TCP Header Protection 666 The "ciphertext" field of the encryption frame contains protected 667 versions of certain TCP header values. 669 When the "URGp" bit is set, the "urgent" value indicates an offset 670 from the current frame's beginning offset; the sum of these offsets 671 gives the index of the last byte of urgent data in the application 672 datastream. 674 A sender MUST set the "FINp" bit on the last frame it sends in the 675 connection (unless it aborts the connection), and MUST NOT set "FINp" 676 on any other frame. 678 TCP sets the FIN flag when a sender has no more data, which with 679 tcpcrypt means setting FIN on the segment containing the last byte of 680 the last frame. However, a receiver MUST report the end-of-file 681 condition to the connection's local user when and only when it 682 receives a frame with the "FINp" bit set. If a host receives a 683 segment with the TCP FIN flag set but the received datastream 684 including this segment does not contain a frame with "FINp" set, the 685 host SHOULD abort the connection and raise an error condition 686 distinct from the end-of-file condition. But if there are 687 unacknowledged segments whose retransmission could potentially result 688 in a valid frame, the host MAY instead drop the segment with the TCP 689 FIN flag set (and "renege" if it has been SACKed, according to 690 [RFC2018] Section 8). 692 3.8. Re-Keying 694 Re-keying allows hosts to wipe from memory keys that could decrypt 695 previously transmitted segments. It also allows the use of AEAD 696 ciphers that can securely encrypt only a bounded number of messages 697 under a given key. 699 As described above in Section 3.3, a master key "mk[j]" is used to 700 generate two encryption keys "k_ab[j]" and "k_ba[j]". We refer to 701 these as a _key-set_ with _generation number_ "j". Each host 702 maintains a _local generation number_ that determines which key-set 703 it uses to encrypt outgoing frames, and a _remote generation number_ 704 equal to the highest generation used in frames received from its 705 peer. Initially, these two generation numbers are set to zero. 707 A host MAY increment its local generation number beyond the remote 708 generation number it has recorded. We call this action _initiating 709 re-keying_. 711 When a host has incremented its local generation number and uses the 712 new key-set for the first time to encrypt an outgoing frame, it MUST 713 set "rekey = 1" for that frame. It MUST set "rekey = 0" in all other 714 cases. 716 When a host receives a frame with "rekey = 1", it increments its 717 record of the remote generation number. If the remote generation 718 number is now greater than the local generation number, the receiver 719 MUST immediately increment its local generation number to match. 720 Moreover, if the receiver has not yet transmitted a segment with the 721 FIN flag set, it MUST immediately send a frame (with empty 722 application data if necessary) with "rekey = 1". 724 A host MUST NOT initiate more than one concurrent re-key operation if 725 it has no data to send; that is, it MUST NOT initiate re-keying with 726 an empty encryption frame more than once while its record of the 727 remote generation number is less than its own. 729 Note that when parts of the datastream are retransmitted, TCP 730 requires that implementations always send the same data bytes for the 731 same TCP sequence numbers. Thus, frame data in retransmitted 732 segments MUST be encrypted with the same key as when it was first 733 transmitted, regardless of the current local generation number. 735 Implementations SHOULD delete older-generation keys from memory once 736 they have received all frames they will need to decrypt with the old 737 keys and have encrypted all outgoing frames under the old keys. 739 3.9. Keep-Alive 741 Instead of using TCP Keep-Alives to verify that the remote endpoint 742 is still responsive, tcpcrypt implementations SHOULD employ the re- 743 keying mechanism for this purpose, as follows. When necessary, a 744 host SHOULD probe the liveness of its peer by initiating re-keying 745 and transmitting a new frame immediately (with empty application data 746 if necessary). 748 As described in Section 3.8, a host receiving a frame encrypted under 749 a generation number greater than its own MUST increment its own 750 generation number and (if it has not already transmitted a segment 751 with FIN set) immediately transmit a new frame (with zero-length 752 application data if necessary). 754 Implementations MAY use TCP Keep-Alives for purposes that do not 755 require endpoint authentication, as discussed in Section 8.2. 757 4. Encodings 759 This section provides byte-level encodings for values transmitted or 760 computed by the protocol. 762 4.1. Key-Exchange Messages 764 The "Init1" message has the following encoding: 766 byte 0 1 2 3 767 +-------+-------+-------+-------+ 768 | INIT1_MAGIC | 769 | | 770 +-------+-------+-------+-------+ 772 4 5 6 7 773 +-------+-------+-------+-------+ 774 | message_len | 775 | = M | 776 +-------+-------+-------+-------+ 778 8 779 +--------+-----+----+-----+----+---...---+-----+-----+ 780 |nciphers|sym_ |sym_ | |sym_ | 781 | = K |cipher[0] |cipher[1] | |cipher[K-1]| 782 +--------+-----+----+-----+----+---...---+-----+-----+ 784 2*K + 9 2*K + 9 + N_A_LEN 785 | | 786 v v 787 +-------+---...---+-------+-------+---...---+-------+ 788 | N_A | Pub_A | 789 | | | 790 +-------+---...---+-------+-------+---...---+-------+ 792 M - 1 793 +-------+---...---+-------+ 794 | ignored | 795 | | 796 +-------+---...---+-------+ 798 The constant "INIT1_MAGIC" is defined in Section 4.3. The four-byte 799 field "message_len" gives the length of the entire "Init1" message, 800 encoded as a big-endian integer. The "nciphers" field contains an 801 integer value that specifies the number of two-byte symmetric-cipher 802 identifiers that follow. The "sym_cipher[i]" identifiers indicate 803 cryptographic algorithms in Table 5 in Section 7. The length 804 "N_A_LEN" and the length of "Pub_A" are both determined by the 805 negotiated TEP, as described in Section 5. 807 Implementations of this protocol MUST construct "Init1" such that the 808 field "ignored" has zero length; that is, they MUST construct the 809 message such that its end, as determined by "message_len", coincides 810 with the end of the field "Pub_A". When receiving "Init1", however, 811 implementations MUST permit and ignore any bytes following "Pub_A". 813 The "Init2" message has the following encoding: 815 byte 0 1 2 3 816 +-------+-------+-------+-------+ 817 | INIT2_MAGIC | 818 | | 819 +-------+-------+-------+-------+ 821 4 5 6 7 8 9 822 +-------+-------+-------+-------+-------+-------+ 823 | message_len | sym_cipher | 824 | = M | | 825 +-------+-------+-------+-------+-------+-------+ 827 10 10 + N_B_LEN 828 | | 829 v v 830 +-------+---...---+-------+-------+---...---+-------+ 831 | N_B | Pub_B | 832 | | | 833 +-------+---...---+-------+-------+---...---+-------+ 835 M - 1 836 +-------+---...---+-------+ 837 | ignored | 838 | | 839 +-------+---...---+-------+ 841 The constant "INIT2_MAGIC" is defined in Section 4.3. The four-byte 842 field "message_len" gives the length of the entire "Init2" message, 843 encoded as a big-endian integer. The "sym_cipher" value is a 844 selection from the symmetric-cipher identifiers in the previously- 845 received "Init1" message. The length "N_B_LEN" and the length of 846 "Pub_B" are both determined by the negotiated TEP, as described in 847 Section 5. 849 Implementations of this protocol MUST construct "Init2" such that the 850 field "ignored" has zero length; that is, they MUST construct the 851 message such that its end, as determined by "message_len", coincides 852 with the end of the "Pub_B" field. When receiving "Init2", however, 853 implementations MUST permit and ignore any bytes following "Pub_B". 855 4.2. Encryption Frames 857 An _encryption frame_ comprises a control byte and a length-prefixed 858 ciphertext value: 860 byte 0 1 2 3 clen+2 861 +-------+-------+-------+-------+---...---+-------+ 862 |control| clen | ciphertext | 863 +-------+-------+-------+-------+---...---+-------+ 865 The field "clen" is an integer in big-endian format and gives the 866 length of the "ciphertext" field. 868 The byte "control" has this structure: 870 bit 7 1 0 871 +-------+---...---+-------+-------+ 872 | cres | rekey | 873 +-------+---...---+-------+-------+ 875 The seven-bit field "cres" is reserved; implementations MUST set 876 these bits to zero when sending, and MUST ignore them when receiving. 878 The use of the "rekey" field is described in Section 3.8. 880 4.2.1. Plaintext 882 The "ciphertext" field is the result of applying the negotiated 883 authenticated-encryption algorithm to a "plaintext" value, which has 884 one of these two formats: 886 byte 0 1 plen-1 887 +-------+-------+---...---+-------+ 888 | flags | data | 889 +-------+-------+---...---+-------+ 891 byte 0 1 2 3 plen-1 892 +-------+-------+-------+-------+---...---+-------+ 893 | flags | urgent | data | 894 +-------+-------+-------+-------+---...---+-------+ 896 (Note that "clen" in the previous section will generally be greater 897 than "plen", as the ciphertext produced by the authenticated- 898 encryption scheme both encrypts the application data and provides 899 redundancy with which to verify its integrity.) 901 The "flags" byte has this structure: 903 bit 7 6 5 4 3 2 1 0 904 +----+----+----+----+----+----+----+----+ 905 | fres |URGp|FINp| 906 +----+----+----+----+----+----+----+----+ 908 The six-bit value "fres" is reserved; implementations MUST set these 909 six bits to zero when sending, and MUST ignore them when receiving. 911 When the "URGp" bit is set, it indicates that the "urgent" field is 912 present, and thus that the plaintext value has the second structure 913 variant above; otherwise the first variant is used. 915 The meaning of "urgent" and of the flag bits is described in 916 Section 3.7. 918 4.2.2. Associated Data 920 An encryption frame's "associated data" (which is supplied to the 921 AEAD algorithm when decrypting the ciphertext and verifying the 922 frame's integrity) has this format: 924 byte 0 1 2 925 +-------+-------+-------+ 926 |control| clen | 927 +-------+-------+-------+ 929 It contains the same values as the frame's "control" and "clen" 930 fields. 932 4.2.3. Frame ID 934 Lastly, a "frame ID" (used to construct the nonce for the AEAD 935 algorithm) has this format: 937 byte 0 ae_nonce_len - 8 ae_nonce_len - 1 938 | | | 939 v v v 940 +-----+--...--+-----+-----+--...--+-----+ 941 | 0 | | 0 | offset | 942 +-----+--...--+-----+-----+--...--+-----+ 944 The 8-byte "offset" field contains an integer in big-endian format. 945 Its value is specified in Section 3.6. Zero-valued bytes are 946 prepended to the "offset" field to form a structure of length 947 "ae_nonce_len". 949 4.3. Constant Values 951 The table below defines values for the constants used in the 952 protocol. 954 +------------+--------------+ 955 | Value | Name | 956 +------------+--------------+ 957 | 0x01 | CONST_NEXTK | 958 | 0x02 | CONST_SESSID | 959 | 0x03 | CONST_REKEY | 960 | 0x04 | CONST_KEY_A | 961 | 0x05 | CONST_KEY_B | 962 | 0x06 | CONST_RESUME | 963 | 0x15101a0e | INIT1_MAGIC | 964 | 0x097105e0 | INIT2_MAGIC | 965 +------------+--------------+ 967 Table 1: Constant values used in the protocol 969 5. Key-Agreement Schemes 971 The TEP negotiated via TCP-ENO indicates the use of one of the key- 972 agreement schemes named in Table 4 in Section 7. For example, 973 "TCPCRYPT_ECDHE_P256" names the tcpcrypt protocol using ECDHE-P256 974 together with the CPRF and length parameters specified below. 976 All the TEPs specified in this document require the use of HKDF- 977 Expand-SHA256 as the CPRF, and these lengths for nonces and session 978 secrets: 980 N_A_LEN: 32 bytes 981 N_B_LEN: 32 bytes 982 K_LEN: 32 bytes 984 Future documents assigning additional TEPs for use with tcpcrypt 985 mmight specify different values for the lengths above. Note that the 986 minimum session ID length specified by TCP-ENO, together with the way 987 tcpcrypt constructs session IDs, implies that "K_LEN" MUST have 988 length at least 32 bytes. 990 Key-agreement schemes ECDHE-P256 and ECDHE-P521 employ the ECSVDP-DH 991 secret value derivation primitive defined in [IEEE-1363]. The named 992 curves are defined in [NIST-DSS]. When the public-key values "Pub_A" 993 and "Pub_B" are transmitted as described in Section 4.1, they are 994 encoded with the "Elliptic Curve Point to Octet String Conversion 995 Primitive" described in Section E.2.3 of [IEEE-1363], and are 996 prefixed by a two-byte length in big-endian format: 998 byte 0 1 2 L - 1 999 +-------+-------+-------+---...---+-------+ 1000 | pubkey_len | pubkey | 1001 | = L | | 1002 +-------+-------+-------+---...---+-------+ 1004 Implementations MUST encode these "pubkey" values in "compressed 1005 format". Implementations MUST validate these "pubkey" values 1006 according to the algorithm in [IEEE-1363] Section A.16.10. 1008 Key-agreement schemes ECDHE-Curve25519 and ECDHE-Curve448 use the 1009 functions X25519 and X448, respectively, to perform the Diffie-Helman 1010 protocol as described in [RFC7748]. Implementations MUST check 1011 whether the computed Diffie-Hellman shared secret is the all-zero 1012 value and abort if so, as described in Section 6 of [RFC7748]. When 1013 using these ciphers, public-key values "Pub_A" and "Pub_B" are 1014 transmitted directly with no length prefix: 32 bytes for Curve25519, 1015 and 56 bytes for Curve448. 1017 Table 2 below specifies the requirement levels of the four TEPs 1018 specified in this document. In particular, all implementations of 1019 tcpcrypt MUST support TCPCRYPT_ECDHE_Curve25519. However, system 1020 administrators MAY configure which TEPs a host will negotiate 1021 independent of these implementation requirements. 1023 +-------------+---------------------------+ 1024 | Requirement | TEP | 1025 +-------------+---------------------------+ 1026 | REQUIRED | TCPCRYPT_ECDHE_Curve25519 | 1027 | RECOMMENDED | TCPCRYPT_ECDHE_Curve448 | 1028 | OPTIONAL | TCPCRYPT_ECDHE_P256 | 1029 | OPTIONAL | TCPCRYPT_ECDHE_P521 | 1030 +-------------+---------------------------+ 1032 Table 2: Requirements for implementation of TEPs 1034 6. AEAD Algorithms 1036 This document uses "sym-cipher" identifiers in the messages "Init1" 1037 and "Init2" (see Section 3.3) to negotiate the use of AEAD 1038 algorithms; the values of these identifiers are given in Table 5 in 1039 Section 7. The algorithms "AEAD_AES_128_GCM" and "AEAD_AES_256_GCM" 1040 are specified in [RFC5116]. The algorithm "AEAD_CHACHA20_POLY1305" 1041 is specified in [RFC7539]. 1043 Implementations MUST support certain AEAD algorithms according to 1044 Table 3 below. Note that system administrators MAY configure which 1045 algorithms a host will negotiate independent of these requirements. 1047 Lastly, this document uses the lengths "ae_key_len" and 1048 "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 whenever possible. 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. However, implementing the Diffie-Hellman function using 1230 NIST elliptic curves (including those specified for use with 1231 tcpcrypt, P-256 and P-521) appears to be very difficult to achieve 1232 without introducing vulnerability to side-channel attacks 1233 [NIST-fail]. Although well-trusted implementations are available as 1234 part of large cryptographic libraries, these can be difficult to 1235 extract for use in operating-system kernels where tcpcrypt is usually 1236 best implemented. In contrast, the characteristics of Curve25519 1237 together with its recent popularity has led to many safe and 1238 efficient implementations, including some that fit naturally into the 1239 kernel environment. 1241 [RFC7696] insists that, "The selected algorithms need to be resistant 1242 to side-channel attacks and also meet the performance, power, and 1243 code size requirements on a wide variety of platforms." On this 1244 principle, tcpcrypt excludes the NIST curves from the set of 1245 mandatory-to-implement key-agreement algorithms. 1247 Lastly, this document encourages support for key-agreement with 1248 Curve448, categorizing it as RECOMMENDED. Curve448 appears likely to 1249 admit safe and efficient implementations. However, support is not 1250 REQUIRED because existing implementations might not yet be 1251 sufficiently well-proven. 1253 9. Experiments 1255 Some experience will be required to determine whether the tcpcrypt 1256 protocol can be deployed safely and successfully across the diverse 1257 environments of the global internet. 1259 Safety means that TCP implementations that support tcpcrypt are able 1260 to communicate reliably in all the same settings as they would 1261 without tcpcrypt. As described in [I-D.ietf-tcpinc-tcpeno] 1262 Section 9, this property can be subverted if middleboxes strip ENO 1263 options from non-SYN segments after allowing them in SYN segments; or 1264 if the particular communication patterns of tcpcrypt offend the 1265 policies of middleboxes doing deep-packet inspection. 1267 Success, in addition to safety, means hosts that implement tcpcrypt 1268 actually enable encryption when connecting to one another. This 1269 property depends on the network's treatment of the TCP-ENO handshake, 1270 and can be subverted if middleboxes merely strip unknown TCP options 1271 or if they terminate TCP connections and relay data back and forth 1272 unencrypted. 1274 Ease of implementation will be a further challenge to deployment. 1275 Because tcpcrypt requires encryption operations on frames that may 1276 span TCP segments, kernel implementations are forced to buffer 1277 segments in different ways than are necessary for plain TCP. More 1278 implementation experience will show how much additional code 1279 complexity is required in various operating systems, and what kind of 1280 performance effects can be expected. 1282 10. Acknowledgments 1284 We are grateful for contributions, help, discussions, and feedback 1285 from the TCPINC working group and from other IETF reviewers, 1286 including Marcelo Bagnulo, David Black, Bob Briscoe, Jana Iyengar, 1287 Stephen Kent, Tero Kivinen, Mirja Kuhlewind, Yoav Nir, Christoph 1288 Paasch, Eric Rescorla, Kyle Rose, and Dale Worley. 1290 This work was funded by gifts from Intel (to Brad Karp) and from 1291 Google; by NSF award CNS-0716806 (A Clean-Slate Infrastructure for 1292 Information Flow Control); by DARPA CRASH under contract 1293 #N66001-10-2-4088; and by the Stanford Secure Internet of Things 1294 Project. 1296 11. Contributors 1298 Dan Boneh and Michael Hamburg were co-authors of the draft that 1299 became this document. 1301 12. References 1303 12.1. Normative References 1305 [I-D.ietf-tcpinc-tcpeno] 1306 Bittau, A., Giffin, D., Handley, M., Mazieres, D., and E. 1307 Smith, "TCP-ENO: Encryption Negotiation Option", draft- 1308 ietf-tcpinc-tcpeno-19 (work in progress), June 2018. 1310 [IEEE-1363] 1311 IEEE, "IEEE Standard Specifications for Public-Key 1312 Cryptography (IEEE Std 1363-2000)", 2000. 1314 [NIST-DSS] 1315 NIST, "FIPS PUB 186-4: Digital Signature Standard (DSS)", 1316 2013. 1318 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 1319 RFC 793, DOI 10.17487/RFC0793, September 1981, 1320 . 1322 [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 1323 Selective Acknowledgment Options", RFC 2018, 1324 DOI 10.17487/RFC2018, October 1996, 1325 . 1327 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1328 Hashing for Message Authentication", RFC 2104, 1329 DOI 10.17487/RFC2104, February 1997, 1330 . 1332 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1333 Requirement Levels", BCP 14, RFC 2119, 1334 DOI 10.17487/RFC2119, March 1997, 1335 . 1337 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 1338 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1339 . 1341 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1342 Key Derivation Function (HKDF)", RFC 5869, 1343 DOI 10.17487/RFC5869, May 2010, 1344 . 1346 [RFC7120] Cotton, M., "Early IANA Allocation of Standards Track Code 1347 Points", BCP 100, RFC 7120, DOI 10.17487/RFC7120, January 1348 2014, . 1350 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1351 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 1352 . 1354 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 1355 for Security", RFC 7748, DOI 10.17487/RFC7748, January 1356 2016, . 1358 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 1359 Writing an IANA Considerations Section in RFCs", BCP 26, 1360 RFC 8126, DOI 10.17487/RFC8126, June 2017, 1361 . 1363 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1364 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1365 May 2017, . 1367 12.2. Informative References 1369 [I-D.ietf-tcpinc-api] 1370 Bittau, A., Boneh, D., Giffin, D., Handley, M., Mazieres, 1371 D., and E. Smith, "Interface Extensions for TCP-ENO and 1372 tcpcrypt", draft-ietf-tcpinc-api-06 (work in progress), 1373 June 2018. 1375 [NIST-fail] 1376 Bernstein, D. and T. Lange, "Failures in NIST's ECC 1377 standards", 2016, 1378 . 1380 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 1381 Communication Layers", STD 3, RFC 1122, 1382 DOI 10.17487/RFC1122, October 1989, 1383 . 1385 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 1386 "Randomness Requirements for Security", BCP 106, RFC 4086, 1387 DOI 10.17487/RFC4086, June 2005, 1388 . 1390 [RFC7696] Housley, R., "Guidelines for Cryptographic Algorithm 1391 Agility and Selecting Mandatory-to-Implement Algorithms", 1392 BCP 201, RFC 7696, DOI 10.17487/RFC7696, November 2015, 1393 . 1395 [tcpcrypt] 1396 Bittau, A., Hamburg, M., Handley, M., Mazieres, D., and D. 1397 Boneh, "The case for ubiquitous transport-level 1398 encryption", USENIX Security , 2010. 1400 Authors' Addresses 1402 Andrea Bittau 1403 Google 1404 345 Spear Street 1405 San Francisco, CA 94105 1406 US 1408 Email: bittau@google.com 1410 Daniel B. Giffin 1411 Stanford University 1412 353 Serra Mall, Room 288 1413 Stanford, CA 94305 1414 US 1416 Email: dbg@scs.stanford.edu 1417 Mark Handley 1418 University College London 1419 Gower St. 1420 London WC1E 6BT 1421 UK 1423 Email: M.Handley@cs.ucl.ac.uk 1425 David Mazieres 1426 Stanford University 1427 353 Serra Mall, Room 290 1428 Stanford, CA 94305 1429 US 1431 Email: dm@uun.org 1433 Quinn Slack 1434 Sourcegraph 1435 121 2nd St Ste 200 1436 San Francisco, CA 94105 1437 US 1439 Email: sqs@sourcegraph.com 1441 Eric W. Smith 1442 Kestrel Institute 1443 3260 Hillview Avenue 1444 Palo Alto, CA 94304 1445 US 1447 Email: eric.smith@kestrel.edu