idnits 2.17.1 draft-ietf-tcpinc-tcpcrypt-10.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 == Line 583 has weird spacing: '..._keylen ae_...' -- The document date (November 17, 2017) is 2351 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 732 -- Looks like a reference, but probably isn't: '1' on line 732 == Missing Reference: 'K-1' is mentioned on line 732, but not defined == Missing Reference: 'RFC-TBD' is mentioned on line 1040, but not defined == Outdated reference: A later version (-19) exists of draft-ietf-tcpinc-tcpeno-13 ** 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 (~~), 6 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 21, 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 November 17, 2017 16 Cryptographic protection of TCP Streams (tcpcrypt) 17 draft-ietf-tcpinc-tcpcrypt-10 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 may be transmitted. However, this cost can be 31 avoided between two hosts that have recently established a previous 32 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 http://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 21, 2018. 50 Copyright Notice 52 Copyright (c) 2017 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 (http://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 . . . . . . . . . . . 12 76 3.7. TCP Header Protection . . . . . . . . . . . . . . . . . . 14 77 3.8. Re-Keying . . . . . . . . . . . . . . . . . . . . . . . . 14 78 3.9. Keep-Alive . . . . . . . . . . . . . . . . . . . . . . . 15 79 4. Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . 16 80 4.1. Key-Exchange Messages . . . . . . . . . . . . . . . . . . 16 81 4.2. Encryption Frames . . . . . . . . . . . . . . . . . . . . 18 82 4.2.1. Plaintext . . . . . . . . . . . . . . . . . . . . . . 18 83 4.2.2. Associated Data . . . . . . . . . . . . . . . . . . . 19 84 4.2.3. Frame ID . . . . . . . . . . . . . . . . . . . . . . 19 85 4.3. Constant Values . . . . . . . . . . . . . . . . . . . . . 20 86 5. Key-Agreement Schemes . . . . . . . . . . . . . . . . . . . . 20 87 6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . . . 21 88 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 22 89 8. Security Considerations . . . . . . . . . . . . . . . . . . . 23 90 8.1. Asymmetric Roles . . . . . . . . . . . . . . . . . . . . 24 91 8.2. Verified Liveness . . . . . . . . . . . . . . . . . . . . 25 92 8.3. Mandatory Key-Agreement Schemes . . . . . . . . . . . . . 25 93 9. Experiments . . . . . . . . . . . . . . . . . . . . . . . . . 26 94 10. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 27 95 11. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 27 96 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 27 97 12.1. Normative References . . . . . . . . . . . . . . . . . . 27 98 12.2. Informative References . . . . . . . . . . . . . . . . . 28 99 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 29 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, typically the output of 149 the key agreement scheme. The notation Extract(S, IKM) denotes 150 the output of the extract function with salt S and initial keying 151 material 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 parameters. 203 Future standards may 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", and an identifier derived from 235 a session secret previously negotiated with the same host and the 236 same TEP. 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 it had "v = 1", the key-exchange messages will be 247 omitted in favor of determining keys via session-resumption as 248 described in Section 3.5, and protected application data may 249 immediately be sent as detailed in Section 3.6. 251 Note that the negotiated TEP is determined without reference to the 252 "v" bits in ENO suboptions, so if host A offers resumption with a 253 particular TEP and host B replies with a non-resumption suboption 254 with the same TEP, that may become the negotiated TEP and fresh key 255 agreement will be performed. That is, sending a resumption suboption 256 also implies willingness to perform fresh key agreement with the 257 indicated TEP. 259 As required by TCP-ENO, once a host has both sent and received an ACK 260 segment containing a valid ENO option, encryption MUST be enabled and 261 plaintext application data MUST NOT ever be exchanged on the 262 connection. If the negotiated TEP is among those listed in Table 4, 263 a host MUST follow the protocol described in this document. 265 3.3. Key Exchange 267 Following successful negotiation of a tcpcrypt TEP, all further 268 signaling is performed in the Data portion of TCP segments. Except 269 when resumption was negotiated (described below in Section 3.5), the 270 two hosts perform key exchange through two messages, "Init1" and 271 "Init2", at the start of the data streams of host A and host B, 272 respectively. These messages may span multiple TCP segments and need 273 not end at a segment boundary. However, the segment containing the 274 last byte of an "Init1" or "Init2" message MUST have TCP's push flag 275 (PSH) set. 277 The key exchange protocol, in abstract, proceeds as follows: 279 A -> B: Init1 = { INIT1_MAGIC, sym_cipher_list, N_A, PK_A } 280 B -> A: Init2 = { INIT2_MAGIC, sym_cipher, N_B, PK_B } 282 The concrete format of these messages is specified in Section 4.1. 284 The parameters are defined as follows: 286 o "INIT1_MAGIC", "INIT2_MAGIC": constants defined in Section 4.3. 288 o "sym_cipher_list": a list of symmetric ciphers (AEAD algorithms) 289 acceptable to host A. These are specified in Table 5 in 290 Section 7. 292 o "sym_cipher": the symmetric cipher selected by host B from the 293 "sym_cipher_list" sent by host A. 295 o "N_A", "N_B": nonces chosen at random by hosts A and B, 296 respectively. 298 o "PK_A", "PK_B": ephemeral public keys for hosts A and B, 299 respectively. These, as well as their corresponding private keys, 300 are short-lived values that MUST be refreshed as frequently as 301 practically possible. The private keys SHOULD NOT ever be written 302 to persistent storage. The security risks associated with the 303 storage of these keys are discussed in Section 8. 305 If a host receives an ephemeral public key from its peer and a 306 required key-validation step fails (see Section 5), it MUST abort the 307 connection and raise an error condition distinct from the end-of-file 308 condition. 310 The ephemeral secret ("ES") is the result of the key-agreement 311 algorithm (see Section 5) indicated by the negotiated TEP. The 312 inputs to the algorithm are the local host's ephemeral private key 313 and the remote host's ephemeral public key. For example, host A 314 would compute "ES" using its own private key (not transmitted) and 315 host B's public key, "PK_B". 317 The two sides then compute a pseudo-random key ("PRK"), from which 318 all session keys are derived, as follows: 320 PRK = Extract(N_A, eno-transcript | Init1 | Init2 | ES) 322 Above, "|" denotes concatenation; "eno-transcript" is the protocol- 323 negotiation transcript defined in Section 4.8 of 324 [I-D.ietf-tcpinc-tcpeno]; and "Init1" and "Init2" are the transmitted 325 encodings of the messages described in Section 4.1. 327 A series of "session secrets" are then computed from "PRK" as 328 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" can be used to 335 avoid public key cryptography when establishing subsequent 336 connections between the same two hosts, as described in Section 3.5. 337 The "CONST_*" values are constants defined in Section 4.3. The 338 length "K_LEN" depends on the tcpcrypt TEP in use, and is specified 339 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, 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. 350 Finally, each master key "mk[j]" is used to generate traffic keys for 351 protecting application data using authenticated encryption: 353 k_ab[j] = CPRF(mk[j], CONST_KEY_A, ae_keylen + 12) 354 k_ba[j] = CPRF(mk[j], CONST_KEY_B, ae_keylen + 12) 356 In the first session derived from fresh key-agreement, traffic keys 357 "k_ab[j]" are used by host A to encrypt and host B to decrypt, while 358 keys "k_ba[j]" are used by host B to encrypt and host A to decrypt. 359 In a resumed session, as described more thoroughly below in 360 Section 3.5, each host uses the keys in the same way as it did in the 361 original session, regardless of its role in the current session: for 362 example, if a host played role "A" in the first session, it will use 363 keys "k_ab[j]" to encrypt in each derived session. 365 The value "ae_keylen" depends on the authenticated-encryption 366 algorithm selected, and is given under "Key Length" in Table 5 in 367 Section 7. The algorithm uses the first "ae_keylen" bytes of each 368 traffic key as an authenticated-encryption key, and the following 12 369 bytes as a "nonce randomizer". 371 After host B sends "Init2" or host A receives it, that host may 372 immediately begin transmitting protected application data as 373 described in Section 3.6. 375 If host A receives "Init2" with a "sym_cipher" value that was not 376 present in the "sym_cipher_list" it previously transmitted in 377 "Init1", it MUST abort the connection and raise an error condition 378 distinct from the end-of-file condition. 380 Throughout this document, to "abort the connection" means to issue 381 the "Abort" command as described in [RFC0793], Section 3.8. That is, 382 the TCP connection is destroyed, RESET is transmitted, and the local 383 user is alerted to the abort event. 385 3.4. Session ID 387 TCP-ENO requires each TEP to define a _session ID_ value that 388 uniquely identifies each encrypted connection. 390 As required, a tcpcrypt session ID begins with the byte transmitted 391 by host B that contains the negotiated TEP identifier along with the 392 "v" bit. The remainder of the ID is derived from the session secret, 393 as follows: 395 session_id[i] = TEP-byte | CPRF(ss[i], CONST_SESSID, K_LEN) 397 Again, the length "K_LEN" depends on the TEP, and is specified in 398 Section 5. 400 3.5. Session Resumption 402 If two hosts have previously negotiated a session with secret 403 "ss[i-1]", they can establish a new connection without public-key 404 operations using "ss[i]", the next session secret in the sequence 405 derived from the original PRK. 407 A host signals willingness to resume with a particular session secret 408 by sending a SYN segment with a resumption suboption: that is, an ENO 409 suboption whose value is the negotiated TEP identifier of the 410 previous session concatenated with half of the "resumption 411 identifier" for the new session. 413 The resumption identifier is calculated from a session secret "ss[i]" 414 as follows: 416 resume[i] = CPRF(ss[i], CONST_RESUME, 18) 418 To name a session for resumption, a host sends either the first or 419 second half of the resumption identifier, according to the role it 420 played in the original session with secret "ss[0]". 422 A host that originally played role A and wishes to resume from a 423 cached session sends a suboption with the first half of the 424 resumption identifier: 426 byte 0 1 9 (10 bytes total) 427 +--------+--------+---...---+--------+ 428 | TEP- | resume[i]{0..8} | 429 | byte | | 430 +--------+--------+---...---+--------+ 432 Figure 2: Resumption suboption sent when original role was A. The 433 TEP-byte contains a tcpcrypt TEP identifier and v = 1. 435 Similarly, a host that originally played role B sends a suboption 436 with the second half of the resumption identifier: 438 byte 0 1 9 (10 bytes total) 439 +--------+--------+---...---+--------+ 440 | TEP- | resume[i]{9..17} | 441 | byte | | 442 +--------+--------+---...---+--------+ 444 Figure 3: Resumption suboption sent when original role was B. The 445 TEP-byte contains a tcpcrypt TEP identifier and v = 1. 447 If a passive opener receives a resumption suboption containing an 448 identifier-half that names a session secret that it has cached and 449 the subobtion's TEP matches the TEP used in the previous session, it 450 SHOULD (with exceptions specified below) agree to resume from the 451 cached session by sending its own resumption suboption, which will 452 contain the other half of the identifier. Otherwise, it MUST NOT 453 agree to resumption. 455 If the passive opener does not agree to resumption with a particular 456 TEP, it may either request fresh key exchange by responding with a 457 non-resumption suboption using the same TEP, or else respond to any 458 other received suboption. 460 If an active opener sends a resumption suboption with a particular 461 TEP and the appropriate half of a resumption identifier and then, in 462 the same TCP handshake, receives a resumption suboption with the same 463 TEP and an identifier-half that does _not_ match that resumption 464 identifier, it MUST ignore that suboption. In the typical case that 465 this was the only ENO suboption received, this means the host MUST 466 disable TCP-ENO and tcpcrypt: that is, it MUST NOT send any more ENO 467 options and MUST NOT encrypt the connection. 469 When a host concludes that TCP-ENO negotiation has succeeded for some 470 TEP that was received in a resumption suboption, it MUST then enable 471 encryption with that TEP, using the cached session secret, as 472 described in Section 3.6. 474 The session ID (Section 3.4) is constructed in the same way for 475 resumed sessions as it is for fresh ones. In this case the first 476 byte will always have "v = 1". The remainder of the ID is derived 477 from the cached session secret. 479 In the case of simultaneous open where TCP-ENO is able to establish 480 asymmetric roles, two hosts that simultaneously send SYN segments 481 with compatible resumption suboptions may resume the associated 482 session. 484 In a particular SYN segment, a host SHOULD NOT send more than one 485 resumption suboption (because this consumes TCP option space and is 486 unlikely to be a useful practice), and MUST NOT send more than one 487 resumption suboption with the same TEP identifier. But in addition 488 to any resumption suboptions, an active opener MAY include non- 489 resumption suboptions describing other TEPs it supports (in addition 490 to the TEP in the resumption suboption). 492 After using "ss[i]" to compute "mk[0]", implementations SHOULD 493 compute and cache "ss[i+1]" for possible use by a later session, then 494 erase "ss[i]" from memory. Hosts SHOULD retain "ss[i+1]" until it is 495 used or the memory needs to be reclaimed. Hosts SHOULD NOT write a 496 cached "ss[i+1]" value to non-volatile storage. 498 When proposing resumption, the active opener MUST use the lowest 499 value of "i" that has not already been used (successfully or not) to 500 negotiate resumption with the same host and for the same pre-session 501 key "ss[0]". 503 A session secret may not be used to secure more than one TCP 504 connection. To prevent this, a host MUST NOT resume with a session 505 secret if it has ever enabled encryption in the past with the same 506 secret, in either role. In the event that two hosts simultaneously 507 send SYN segments to each other that propose resumption with the same 508 session secret but the two segments are not part of a simultaneous 509 open, both connections will have to revert to fresh key-exchange. To 510 avoid this limitation, implementations MAY choose to implement 511 session resumption such that a given pre-session key "ss[0]" is only 512 used for either passive or active opens at the same host, not both. 514 If two hosts have previously negotiated a tcpcrypt session, either 515 host may later initiate session resumption regardless of which host 516 was the active opener or played the "A" role in the previous session. 518 However, a given host must either encrypt with keys "k_ab[j]" for all 519 sessions derived from the same pre-session key "ss[0]", or with keys 520 "k_ba[j]". Thus, which keys a host uses to send segments is not 521 affected by the role it plays in the current connection: it depends 522 only on whether the host played the "A" or "B" role in the initial 523 session. 525 Implementations that cache session secrets MUST provide a means for 526 applications to control that caching. In particular, when an 527 application requests a new TCP connection, it must be able to specify 528 that during the connection no session secrets will be cached and all 529 resumption requests will be ignored in favor of fresh key exchange. 530 And for an established connection, an application must be able to 531 cause any cache state that was used in or resulted from establishing 532 the connection to be flushed. A companion document 533 [I-D.ietf-tcpinc-api] describes recommended interfaces for this 534 purpose. 536 3.6. Data Encryption and Authentication 538 Following key exchange (or its omission via session resumption), all 539 further communication in a tcpcrypt-enabled connection is carried out 540 within delimited _encryption frames_ that are encrypted and 541 authenticated using the agreed keys. 543 This protection is provided via algorithms for Authenticated 544 Encryption with Associated Data (AEAD). The particular algorithms 545 that may be used are listed in Table 5 in Section 7, and additional 546 algorithms may be specified according to the policy in that section. 547 One algorithm is selected during the negotiation described in 548 Section 3.3. 550 The format of an encryption frame is specified in Section 4.2. A 551 sending host breaks its stream of application data into a series of 552 chunks. Each chunk is placed in the "data" portion of a "plaintext" 553 value, which is then encrypted to yield a frame's "ciphertext" field. 554 Chunks must be small enough that the ciphertext (whose length depends 555 on the AEAD cipher used, and is generally slightly longer than the 556 plaintext) has length less than 2^16 bytes. 558 An "associated data" value (see Section 4.2.2) is constructed for the 559 frame. It contains the frame's "control" field and the length of the 560 ciphertext. 562 A "frame ID" value (see Section 4.2.3) is also constructed for the 563 frame but not explicitly transmitted. It contains an "offset" field 564 whose integer value is the zero-indexed byte offset of the beginning 565 of the current encryption frame in the underlying TCP datastream. 566 (That is, the offset in the framing stream, not the plaintext 567 application stream.) Because it is strictly necessary for the 568 security of the AEAD algorithms specified in this document, an 569 implementation MUST NOT ever transmit distinct frames with the same 570 frame ID value under the same encryption key. In particular, a 571 retransmitted TCP segment MUST contain the same payload bytes for the 572 same TCP sequence numbers, and a host MUST NOT transmit more than 573 2^64 bytes in the underlying TCP datastream (which would cause the 574 "offset" field to wrap) before re-keying. 576 With reference to the "AEAD Interface" described in Section 2 of 577 [RFC5116], tcpcrypt invokes the AEAD algorithm with values taken from 578 the traffic key "k_ab[j]" or "k_ba[j]" for some "j", according to the 579 host's role as described in Section 3.3. 581 First, the traffic key is divided into two parts: 583 byte 0 ae_keylen ae_keylen + 11 584 | | | 585 v v v 586 +----+----+--...--+----+----+----+--...--+----+ 587 | K | NR | 588 +----+----+--...--+----+----+----+--...--+----+ 590 \_____________________________________________/ 591 traffic key 593 The first "ae_keylen" bytes of the traffic key provide the AEAD key 594 "K", while the remaining 12 bytes provide a "nonce randomizer" value 595 "NR". The frame ID is then combined via bitwise exclusive-or with 596 the nonce randomizer to yield "N", the AEAD nonce for the frame: 598 N = frame_ID xor NR 600 The plaintext value serves as "P", and the associated data as "A". 601 The output of the encryption operation, "C", is transmitted in the 602 frame's "ciphertext" field. 604 When a frame is received, tcpcrypt reconstructs the associated data 605 and frame ID values (the former contains only data sent in the clear, 606 and the latter is implicit in the TCP stream), computes the nonce N 607 as above, and provides these and the ciphertext value to the the AEAD 608 decryption operation. The output of this operation is either a 609 plaintext value "P" or the special symbol FAIL. In the latter case, 610 the implementation SHOULD abort the connection and raise an error 611 condition distinct from the end-of-file condition. But if none of 612 the TCP segment(s) containing the frame have been acknowledged and 613 retransmission could potentially result in a valid frame, an 614 implementation MAY instead drop these segments. 616 3.7. TCP Header Protection 618 The "ciphertext" field of the encryption frame contains protected 619 versions of certain TCP header values. 621 When the "URGp" bit is set, the "urgent" value indicates an offset 622 from the current frame's beginning offset; the sum of these offsets 623 gives the index of the last byte of urgent data in the application 624 datastream. 626 A sender MUST set the "FINp" bit on the last frame it sends in the 627 connection (unless it aborts the connection), and MUST NOT set "FINp" 628 on any other frame. 630 TCP sets the FIN flag when a sender has no more data, which with 631 tcpcrypt means setting FIN on the segment containing the last byte of 632 the last frame. However, a receiver MUST report the end-of-file 633 condition to the connection's local user when and only when it 634 receives a frame with the "FINp" bit set. If a host receives a 635 segment with the TCP FIN flag set but the received datastream 636 including this segment does not contain a frame with "FINp" set, the 637 host SHOULD abort the connection and raise an error condition 638 distinct from the end-of-file condition. But if there are 639 unacknowledged segments whose retransmission could potentially result 640 in a valid frame, the host MAY instead drop the segment with the TCP 641 FIN flag set. 643 3.8. Re-Keying 645 Re-keying allows hosts to wipe from memory keys that could decrypt 646 previously transmitted segments. It also allows the use of AEAD 647 ciphers that can securely encrypt only a bounded number of messages 648 under a given key. 650 As described above in Section 3.3, a master key "mk[j]" is used to 651 generate two encryption keys "k_ab[j]" and "k_ba[j]". We refer to 652 these as a _key-set_ with _generation number_ "j". Each host 653 maintains a _local generation number_ that determines which key-set 654 it uses to encrypt outgoing frames, and a _remote generation number_ 655 equal to the highest generation used in frames received from its 656 peer. Initially, these two generation numbers are set to zero. 658 A host MAY increment its local generation number beyond the remote 659 generation number it has recorded. We call this action _initiating 660 re-keying_. 662 When a host has incremented its local generation number and uses the 663 new key-set for the first time to encrypt an outgoing frame, it MUST 664 set "rekey = 1" for that frame. It MUST set this field to zero in 665 all other cases. 667 When a host receives a frame with "rekey = 1", it increments its 668 record of the remote generation number. If the remote generation 669 number is now greater than the local generation number, the receiver 670 MUST immediately increment its local generation number to match. 671 Moreover, if the receiver has not yet transmitted a segment with the 672 FIN flag set, it MUST immediately send a frame (with empty 673 application data if necessary) with "rekey = 1". 675 A host MUST NOT initiate more than one concurrent re-key operation if 676 it has no data to send; that is, it MUST NOT initiate re-keying with 677 an empty encryption frame more than once while its record of the 678 remote generation number is less than its own. 680 Note that when parts of the datastream are retransmitted, TCP 681 requires that implementations always send the same data bytes for the 682 same TCP sequence numbers. Thus, frame data in retransmitted 683 segments must be encrypted with the same key as when it was first 684 transmitted, regardless of the current local generation number. 686 Implementations SHOULD delete older-generation keys from memory once 687 they have received all frames they will need to decrypt with the old 688 keys and have encrypted all outgoing frames under the old keys. 690 3.9. Keep-Alive 692 Instead of using TCP Keep-Alives to verify that the remote endpoint 693 is still responsive, tcpcrypt implementations SHOULD employ the re- 694 keying mechanism for this purpose, as follows. When necessary, a 695 host SHOULD probe the liveness of its peer by initiating re-keying 696 and transmitting a new frame immediately (with empty application data 697 if necessary). 699 As described in Section 3.8, a host receiving a frame encrypted under 700 a generation number greater than its own MUST increment its own 701 generation number and (if it has not already transmitted a segment 702 with FIN set) immediately transmit a new frame (with zero-length 703 application data if necessary). 705 Implementations MAY use TCP Keep-Alives for purposes that do not 706 require endpoint authentication, as discussed in Section 8.2. 708 4. Encodings 710 This section provides byte-level encodings for values transmitted or 711 computed by the protocol. 713 4.1. Key-Exchange Messages 715 The "Init1" message has the following encoding: 717 byte 0 1 2 3 718 +-------+-------+-------+-------+ 719 | INIT1_MAGIC | 720 | | 721 +-------+-------+-------+-------+ 723 4 5 6 7 724 +-------+-------+-------+-------+ 725 | message_len | 726 | = M | 727 +-------+-------+-------+-------+ 729 8 730 +--------+-----+----+-----+----+---...---+-----+-----+ 731 |nciphers|sym_ |sym_ | |sym_ | 732 | = K |cipher[0] |cipher[1] | |cipher[K-1]| 733 +--------+-----+----+-----+----+---...---+-----+-----+ 735 2*K + 9 2*K + 9 + N_A_LEN 736 | | 737 v v 738 +-------+---...---+-------+-------+---...---+-------+ 739 | N_A | PK_A | 740 | | | 741 +-------+---...---+-------+-------+---...---+-------+ 743 M - 1 744 +-------+---...---+-------+ 745 | ignored | 746 | | 747 +-------+---...---+-------+ 749 The constant "INIT1_MAGIC" is defined in Section 4.3. The four-byte 750 field "message_len" gives the length of the entire "Init1" message, 751 encoded as a big-endian integer. The "nciphers" field contains an 752 integer value that specifies the number of two-byte symmetric-cipher 753 identifiers that follow. The "sym_cipher[i]" identifiers indicate 754 cryptographic algorithms in Table 5 in Section 7. The length 755 "N_A_LEN" and the length of "PK_A" are both determined by the 756 negotiated TEP, as described in Section 5. 758 Implementations of this protocol MUST construct "Init1" such that the 759 field "ignored" has zero length; that is, they must construct the 760 message such that its end, as determined by "message_len", coincides 761 with the end of the field "PK_A". When receiving "Init1", however, 762 implementations MUST permit and ignore any bytes following "PK_A". 764 The "Init2" message has the following encoding: 766 byte 0 1 2 3 767 +-------+-------+-------+-------+ 768 | INIT2_MAGIC | 769 | | 770 +-------+-------+-------+-------+ 772 4 5 6 7 8 9 773 +-------+-------+-------+-------+-------+-------+ 774 | message_len | sym_cipher | 775 | = M | | 776 +-------+-------+-------+-------+-------+-------+ 778 10 10 + N_B_LEN 779 | | 780 v v 781 +-------+---...---+-------+-------+---...---+-------+ 782 | N_B | PK_B | 783 | | | 784 +-------+---...---+-------+-------+---...---+-------+ 786 M - 1 787 +-------+---...---+-------+ 788 | ignored | 789 | | 790 +-------+---...---+-------+ 792 The constant "INIT2_MAGIC" is defined in Section 4.3. The four-byte 793 field "message_len" gives the length of the entire "Init2" message, 794 encoded as a big-endian integer. The "sym_cipher" value is a 795 selection from the symmetric-cipher identifiers in the previously- 796 received "Init1" message. The length "N_B_LEN" and the length of 797 "PK_B" are both determined by the negotiated TEP, as described in 798 Section 5. 800 Implementations of this protocol MUST construct "Init2" such that the 801 field "ignored" has zero length; that is, they must construct the 802 message such that its end, as determined by "message_len", coincides 803 with the end of the "PK_B" field. When receiving "Init2", however, 804 implementations MUST permit and ignore any bytes following "PK_B". 806 4.2. Encryption Frames 808 An _encryption frame_ comprises a control byte and a length-prefixed 809 ciphertext value: 811 byte 0 1 2 3 clen+2 812 +-------+-------+-------+-------+---...---+-------+ 813 |control| clen | ciphertext | 814 +-------+-------+-------+-------+---...---+-------+ 816 The field "clen" is an integer in big-endian format and gives the 817 length of the "ciphertext" field. 819 The byte "control" has this structure: 821 bit 7 1 0 822 +-------+---...---+-------+-------+ 823 | cres | rekey | 824 +-------+---...---+-------+-------+ 826 The seven-bit field "cres" is reserved; implementations MUST set 827 these bits to zero when sending, and MUST ignore them when receiving. 829 The use of the "rekey" field is described in Section 3.8. 831 4.2.1. Plaintext 833 The "ciphertext" field is the result of applying the negotiated 834 authenticated-encryption algorithm to a "plaintext" value, which has 835 one of these two formats: 837 byte 0 1 plen-1 838 +-------+-------+---...---+-------+ 839 | flags | data | 840 +-------+-------+---...---+-------+ 842 byte 0 1 2 3 plen-1 843 +-------+-------+-------+-------+---...---+-------+ 844 | flags | urgent | data | 845 +-------+-------+-------+-------+---...---+-------+ 847 (Note that "clen" in the previous section will generally be greater 848 than "plen", as the ciphertext produced by the authenticated- 849 encryption scheme must both encrypt the application data and provide 850 a way to verify its integrity.) 852 The "flags" byte has this structure: 854 bit 7 6 5 4 3 2 1 0 855 +----+----+----+----+----+----+----+----+ 856 | fres |URGp|FINp| 857 +----+----+----+----+----+----+----+----+ 859 The six-bit value "fres" is reserved; implementations MUST set these 860 six bits to zero when sending, and MUST ignore them when receiving. 862 When the "URGp" bit is set, it indicates that the "urgent" field is 863 present, and thus that the plaintext value has the second structure 864 variant above; otherwise the first variant is used. 866 The meaning of "urgent" and of the flag bits is described in 867 Section 3.7. 869 4.2.2. Associated Data 871 An encryption frame's "associated data" (which is supplied to the 872 AEAD algorithm when decrypting the ciphertext and verifying the 873 frame's integrity) has this format: 875 byte 0 1 2 876 +-------+-------+-------+ 877 |control| clen | 878 +-------+-------+-------+ 880 It contains the same values as the frame's "control" and "clen" 881 fields. 883 4.2.3. Frame ID 885 Lastly, a "frame ID" (used to construct the nonce for the AEAD 886 algorithm) has this format: 888 byte 889 +------+------+------+------+ 890 0 | FRAME_ID_MAGIC | 891 +------+------+------+------+ 892 4 | | 893 + offset + 894 8 | | 895 +------+------+------+------+ 897 The 4-byte magic constant is defined in Section 4.3. The 8-byte 898 "offset" field contains an integer in big-endian format. Its value 899 is specified in Section 3.6. 901 4.3. Constant Values 903 The table below defines values for the constants used in the 904 protocol. 906 +------------+----------------+ 907 | Value | Name | 908 +------------+----------------+ 909 | 0x01 | CONST_NEXTK | 910 | 0x02 | CONST_SESSID | 911 | 0x03 | CONST_REKEY | 912 | 0x04 | CONST_KEY_A | 913 | 0x05 | CONST_KEY_B | 914 | 0x06 | CONST_RESUME | 915 | 0x15101a0e | INIT1_MAGIC | 916 | 0x097105e0 | INIT2_MAGIC | 917 | 0x44415441 | FRAME_ID_MAGIC | 918 +------------+----------------+ 920 Table 1: Constant values used in the protocol 922 5. Key-Agreement Schemes 924 The TEP negotiated via TCP-ENO indicates the use of one of the key- 925 agreement schemes named in Table 4 in Section 7. For example, 926 "TCPCRYPT_ECDHE_P256" names the tcpcrypt protocol using ECDHE-P256 927 together with the CPRF and length parameters specified below. 929 All the TEPs specified in this document require the use of HKDF- 930 Expand-SHA256 as the CPRF, and these lengths for nonces and session 931 keys: 933 N_A_LEN: 32 bytes 934 N_B_LEN: 32 bytes 935 K_LEN: 32 bytes 937 If future documents assign additional TEPs for use with tcpcrypt, 938 they may specify different values for the lengths above. Note that 939 the minimum session ID length required by TCP-ENO, together with the 940 way tcpcrypt constructs session IDs, implies that "K_LEN" must have 941 length at least 32 bytes. 943 Key-agreement schemes ECDHE-P256 and ECDHE-P521 employ the ECSVDP-DH 944 secret value derivation primitive defined in [ieee1363]. The named 945 curves are defined in [nist-dss]. When the public-key values "PK_A" 946 and "PK_B" are transmitted as described in Section 4.1, they are 947 encoded with the "Elliptic Curve Point to Octet String Conversion 948 Primitive" described in Section E.2.3 of [ieee1363], and are prefixed 949 by a two-byte length in big-endian format: 951 byte 0 1 2 L - 1 952 +-------+-------+-------+---...---+-------+ 953 | pubkey_len | pubkey | 954 | = L | | 955 +-------+-------+-------+---...---+-------+ 957 Implementations MUST encode these "pubkey" values in "compressed 958 format". Implementations MUST validate these "pubkey" values 959 according to the algorithm in [ieee1363] Section A.16.10. 961 Key-agreement schemes ECDHE-Curve25519 and ECDHE-Curve448 use the 962 functions X25519 and X448, respectively, to perform the Diffie-Helman 963 protocol as described in [RFC7748]. When using these ciphers, 964 public-key values "PK_A" and "PK_B" are transmitted directly with no 965 length prefix: 32 bytes for Curve25519, and 56 bytes for Curve448. 967 Implementations are required to implement certain TEPs, according to 968 Table 2 below. Note that system administrators may configure which 969 TEPs a host will negotiate, independent of these requirements. 971 +-------------+---------------------------+ 972 | Requirement | TEP | 973 +-------------+---------------------------+ 974 | MUST | TCPCRYPT_ECDHE_Curve25519 | 975 | SHOULD | TCPCRYPT_ECDHE_Curve448 | 976 | MAY | TCPCRYPT_ECDHE_P256 | 977 | MAY | TCPCRYPT_ECDHE_P521 | 978 +-------------+---------------------------+ 980 Table 2: Requirements for implementation of TEPs 982 6. AEAD Algorithms 984 Specifiers and key-lengths for AEAD algorithms are given in Table 5 985 in Section 7. The algorithms "AEAD_AES_128_GCM" and 986 "AEAD_AES_256_GCM" are specified in [RFC5116]. The algorithm 987 "AEAD_CHACHA20_POLY1305" is specified in [RFC7539]. 989 Implementations are required to support certain algorithms according 990 to Table 3 below. Note that system administrators may configure 991 which algorithms a host will negotiate, independent of these 992 requirements. 994 +-------------+------------------------+ 995 | Requirement | AEAD Algorithm | 996 +-------------+------------------------+ 997 | MUST | AEAD_AES_128_GCM | 998 | SHOULD | AEAD_AES_256_GCM | 999 | SHOULD | AEAD_CHACHA20_POLY1305 | 1000 +-------------+------------------------+ 1002 Table 3: Requirements for implementation of AEAD algorithms 1004 7. IANA Considerations 1006 For use with TCP-ENO's negotiation mechanism, tcpcrypt's TEP 1007 identifiers will need to be incorporated in IANA's "TCP encryption 1008 protocol identifiers" registry under the "Transmission Control 1009 Protocol (TCP) Parameters" registry, as in Table 4 below. The 1010 various key-agreement schemes used by these tcpcrypt variants are 1011 defined in Section 5. 1013 +-------+---------------------------+-----------+ 1014 | Value | Meaning | Reference | 1015 +-------+---------------------------+-----------+ 1016 | 0x21 | TCPCRYPT_ECDHE_P256 | [RFC-TBD] | 1017 | 0x22 | TCPCRYPT_ECDHE_P521 | [RFC-TBD] | 1018 | 0x23 | TCPCRYPT_ECDHE_Curve25519 | [RFC-TBD] | 1019 | 0x24 | TCPCRYPT_ECDHE_Curve448 | [RFC-TBD] | 1020 +-------+---------------------------+-----------+ 1022 Table 4: TEP identifiers for use with tcpcrypt 1024 In Section 4.1, this document defines "sym_cipher" specifiers in the 1025 range 0x0001 to 0xFFFF inclusive, for which IANA is to maintain a new 1026 "tcpcrypt AEAD Algorithm" registry under the "Transmission Control 1027 Protocol (TCP) Parameters" registry. The initial values for this 1028 registry are given in Table 5 below. The AEAD algorithms named there 1029 are defined in Section 6. Future assignments are to be made upon 1030 satisfying either of two policies defined in [RFC8126]: "IETF Review" 1031 or (for non-IETF stream specifications) "Expert Review with RFC 1032 Required." IANA will furthermore provide early allocation [RFC7120] 1033 to facilitate testing before RFCs are finalized. 1035 +--------+------------------------+------------+-----------+ 1036 | Value | AEAD Algorithm | Key Length | Reference | 1037 +--------+------------------------+------------+-----------+ 1038 | 0x0001 | AEAD_AES_128_GCM | 16 bytes | [RFC-TBD] | 1039 | 0x0002 | AEAD_AES_256_GCM | 32 bytes | [RFC-TBD] | 1040 | 0x0010 | AEAD_CHACHA20_POLY1305 | 32 bytes | [RFC-TBD] | 1041 +--------+------------------------+------------+-----------+ 1043 Table 5: Authenticated-encryption algorithms corresponding to 1044 sym_cipher specifiers in Init1 and Init2 messages. 1046 8. Security Considerations 1048 All of the security considerations of TCP-ENO apply to tcpcrypt. In 1049 particular, tcpcrypt does not protect against active eavesdroppers 1050 unless applications authenticate the session ID. If it can be 1051 established that the session IDs computed at each end of the 1052 connection match, then tcpcrypt guarantees that no man-in-the-middle 1053 attacks occurred unless the attacker has broken the underlying 1054 cryptographic primitives (e.g., ECDH). A proof of this property for 1055 an earlier version of the protocol has been published [tcpcrypt]. 1057 To gain middlebox compatibility, tcpcrypt does not protect TCP 1058 headers. Hence, the protocol is vulnerable to denial-of-service from 1059 off-path attackers just as plain TCP is. Possible attacks include 1060 desynchronizing the underlying TCP stream, injecting RST or FIN 1061 segments, and forging re-key bits. These attacks will cause a 1062 tcpcrypt connection to hang or fail with an error, but not in any 1063 circumstance where plain TCP could continue uncorrupted. 1064 Implementations MUST give higher-level software a way to distinguish 1065 such errors from a clean end-of-stream (indicated by an authenticated 1066 "FINp" bit) so that applications can avoid semantic truncation 1067 attacks. 1069 There is no "key confirmation" step in tcpcrypt. This is not 1070 required because tcpcrypt's threat model includes the possibility of 1071 a connection to an adversary. If key negotiation is compromised and 1072 yields two different keys, all subsequent frames will be ignored due 1073 to failed integrity checks, causing the application's connection to 1074 hang. This is not a new threat because in plain TCP, an active 1075 attacker could have modified sequence and acknowledgement numbers to 1076 hang the connection anyway. 1078 Tcpcrypt uses short-lived public keys to provide forward secrecy. 1079 That is, once an implementation removes these keys from memory, a 1080 compromise of the system will not provide any means to derive the 1081 session keys for past connections. All currently-specified key 1082 agreement schemes involve ECDHE-based key agreement, meaning a new 1083 key-pair can be efficiently computed for each connection. If 1084 implementations reuse these parameters, they MUST limit the lifetime 1085 of the private parameters as far as practical in order to minimize 1086 the number of past connections that are vulnerable. Of course, 1087 placing private keys in persistent storage introduces severe risks 1088 that they may not be destroyed reliably and in a timely fashion, and 1089 SHOULD be avoided at all costs. 1091 Attackers cannot force passive openers to move forward in their 1092 session resumption chain without guessing the content of the 1093 resumption identifier, which will be difficult without key knowledge. 1095 The cipher-suites specified in this document all use HMAC-SHA256 to 1096 implement the collision-resistant pseudo-random function denoted by 1097 "CPRF". A collision-resistant function is one for which, for 1098 sufficiently large L, an attacker cannot find two distinct inputs 1099 (K_1, CONST_1) and (K_2, CONST_2) such that CPRF(K_1, CONST_1, L) = 1100 CPRF(K_2, CONST_2, L). Collision resistance is important to assure 1101 the uniqueness of session IDs, which are generated using the CPRF. 1103 Lastly, many of tcpcrypt's cryptographic functions require random 1104 input, and thus any host implementing tcpcrypt MUST have access to a 1105 cryptographically-secure source of randomness or pseudo-randomness. 1106 Recommendations on how to achieve this may be found in [RFC4086]. 1108 Most implementations will rely on a device's pseudo-random generator, 1109 seeded from hardware events and a seed carried over from the previous 1110 boot. Once a pseudo-random generator has been properly seeded, it 1111 can generate effectively arbitrary amounts of pseudo-random data. 1112 However, until a pseudo-random generator has been seeded with 1113 sufficient entropy, not only will tcpcrypt be insecure, it will 1114 reveal information that further weakens the security of the pseudo- 1115 random generator, potentially harming other applications. As 1116 required by TCP-ENO, implementations MUST NOT send ENO options unless 1117 they have access to an adequate source of randomness. 1119 8.1. Asymmetric Roles 1121 Tcpcrypt transforms a shared pseudo-random key (PRK) into 1122 cryptographic session keys for each direction. Doing so requires an 1123 asymmetry in the protocol, as the key derivation function must be 1124 perturbed differently to generate different keys in each direction. 1125 Tcpcrypt includes other asymmetries in the roles of the two hosts, 1126 such as the process of negotiating algorithms (e.g., proposing vs. 1127 selecting cipher suites). 1129 8.2. Verified Liveness 1131 Many hosts implement TCP Keep-Alives [RFC1122] as an option for 1132 applications to ensure that the other end of a TCP connection still 1133 exists even when there is no data to be sent. A TCP Keep-Alive 1134 segment carries a sequence number one prior to the beginning of the 1135 send window, and may carry one byte of "garbage" data. Such a 1136 segment causes the remote side to send an acknowledgment. 1138 Unfortunately, tcpcrypt cannot cryptographically verify Keep-Alive 1139 acknowledgments. Hence, an attacker could prolong the existence of a 1140 session at one host after the other end of the connection no longer 1141 exists. (Such an attack might prevent a process with sensitive data 1142 from exiting, giving an attacker more time to compromise a host and 1143 extract the sensitive data.) 1145 To counter this threat, tcpcrypt specifies a way to stimulate the 1146 remote host to send verifiably fresh and authentic data, described in 1147 Section 3.9. 1149 The TCP keep-alive mechanism has also been used for its effects on 1150 intermediate nodes in the network, such as preventing flow state from 1151 expiring at NAT boxes or firewalls. As these purposes do not require 1152 the authentication of endpoints, implementations may safely 1153 accomplish them using either the existing TCP keep-alive mechanism or 1154 tcpcrypt's verified keep-alive mechanism. 1156 8.3. Mandatory Key-Agreement Schemes 1158 This document mandates that tcpcrypt implementations provide support 1159 for at least one key-agreement scheme: ECDHE using Curve25519. This 1160 choice of a single mandatory algorithm is the result of a difficult 1161 tradeoff between cryptographic diversity and the ease and security of 1162 actual deployment. 1164 The IETF's appraisal of best current practice on this matter 1165 [RFC7696] says, "Ideally, two independent sets of mandatory-to- 1166 implement algorithms will be specified, allowing for a primary suite 1167 and a secondary suite. This approach ensures that the secondary 1168 suite is widely deployed if a flaw is found in the primary one." 1170 To meet that ideal, it might appear natural to also mandate ECDHE 1171 using P-256, as this scheme is well-studied, widely implemented, and 1172 sufficiently different from the Curve25519-based scheme that it is 1173 unlikely they will both suffer from a single (non-quantum) 1174 cryptanalytic advance. 1176 However, implementing the Diffie-Hellman function using NIST elliptic 1177 curves (including those specified for use with tcpcrypt, P-256 and 1178 P-521) appears to be very difficult to achieve without introducing 1179 vulnerability to side-channel attacks [nist-ecc]. Although well- 1180 trusted implementations are available as part of large cryptographic 1181 libraries, these may be difficult to extract for use in operating- 1182 system kernels where tcpcrypt is usually best implemented. In 1183 contrast, the characteristics of Curve25519 together with its recent 1184 popularity has led to many safe and efficient implementations, 1185 including some that fit naturally into the kernel environment. 1187 [RFC7696] insists that, "The selected algorithms need to be resistant 1188 to side-channel attacks and also meet the performance, power, and 1189 code size requirements on a wide variety of platforms." On this 1190 principle, tcpcrypt excludes the NIST curves from the set of 1191 mandatory-to-implement key-agreement algorithms. 1193 Lastly, this document encourages (via SHOULD) support for key- 1194 agreement with Curve448 as this scheme appears likely to admit safe 1195 and efficient implementations; but it does not absolutely require 1196 such support, as well-proven implementations may not yet be 1197 available. 1199 9. Experiments 1201 Some experience will be required to determine whether the tcpcrypt 1202 protocol can be deployed safely and successfully across the diverse 1203 environments of the global internet. 1205 Safety means that TCP implementations that support tcpcrypt are able 1206 to communicate reliably in all the same settings as they would 1207 without tcpcrypt. As described in [I-D.ietf-tcpinc-tcpeno] 1208 Section 9, this property can be subverted if middleboxes strip ENO 1209 options from non-SYN segments after allowing them in SYN segments; or 1210 if the particular communication patterns of tcpcrypt offend the 1211 policies of middleboxes doing deep-packet-inspection. 1213 Success, in addition to safety, means that hosts which implement 1214 tcpcrypt actually enable encryption when they connect to each other. 1215 This property depends on the network's treatment of the TCP-ENO 1216 handshake, and can be subverted if middleboxes merely strip unknown 1217 TCP options or if they terminate TCP connections and relay data back 1218 and forth unencrypted. 1220 Ease of implementation will be a further challenge to deployment. 1221 Because tcpcrypt requires encryption operations on frames that may 1222 span TCP segments, kernel implementations are forced to buffer 1223 segments in different ways than are necessary for plain TCP. More 1224 implementation experience will show how much additional code 1225 complexity is required in various operating systems, and what kind of 1226 performance effects can be expected. 1228 10. Acknowledgments 1230 We are grateful for contributions, help, discussions, and feedback 1231 from the TCPINC working group and from other IETF reviewers, 1232 including Marcelo Bagnulo, David Black, Bob Briscoe, Jana Iyengar, 1233 Stephen Kent, Tero Kivinen, Mirja Kuhlewind, Yoav Nir, Christoph 1234 Paasch, Eric Rescorla, Kyle Rose, and Dale Worley. 1236 This work was funded by gifts from Intel (to Brad Karp) and from 1237 Google; by NSF award CNS-0716806 (A Clean-Slate Infrastructure for 1238 Information Flow Control); by DARPA CRASH under contract 1239 #N66001-10-2-4088; and by the Stanford Secure Internet of Things 1240 Project. 1242 11. Contributors 1244 Dan Boneh and Michael Hamburg were co-authors of the draft that 1245 became this document. 1247 12. References 1249 12.1. Normative References 1251 [I-D.ietf-tcpinc-tcpeno] 1252 Bittau, A., Giffin, D., Handley, M., Mazieres, D., and E. 1253 Smith, "TCP-ENO: Encryption Negotiation Option", draft- 1254 ietf-tcpinc-tcpeno-13 (work in progress), November 2017. 1256 [ieee1363] 1257 IEEE, "IEEE Standard Specifications for Public-Key 1258 Cryptography (IEEE Std 1363-2000)", 2000. 1260 [nist-dss] 1261 NIST, "FIPS PUB 186-4: Digital Signature Standard (DSS)", 1262 2013. 1264 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 1265 RFC 793, DOI 10.17487/RFC0793, September 1981, 1266 . 1268 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1269 Hashing for Message Authentication", RFC 2104, 1270 DOI 10.17487/RFC2104, February 1997, . 1273 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1274 Requirement Levels", BCP 14, RFC 2119, 1275 DOI 10.17487/RFC2119, March 1997, . 1278 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 1279 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1280 . 1282 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1283 Key Derivation Function (HKDF)", RFC 5869, 1284 DOI 10.17487/RFC5869, May 2010, . 1287 [RFC7120] Cotton, M., "Early IANA Allocation of Standards Track Code 1288 Points", BCP 100, RFC 7120, DOI 10.17487/RFC7120, January 1289 2014, . 1291 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1292 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 1293 . 1295 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 1296 for Security", RFC 7748, DOI 10.17487/RFC7748, January 1297 2016, . 1299 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 1300 Writing an IANA Considerations Section in RFCs", BCP 26, 1301 RFC 8126, DOI 10.17487/RFC8126, June 2017, 1302 . 1304 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1305 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1306 May 2017, . 1308 12.2. Informative References 1310 [I-D.ietf-tcpinc-api] 1311 Bittau, A., Boneh, D., Giffin, D., Handley, M., Mazieres, 1312 D., and E. Smith, "Interface Extensions for TCP-ENO and 1313 tcpcrypt", draft-ietf-tcpinc-api-05 (work in progress), 1314 September 2017. 1316 [nist-ecc] 1317 Bernstein, D. and T. Lange, "Failures in NIST's ECC 1318 standards", 2016, . 1321 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 1322 Communication Layers", STD 3, RFC 1122, 1323 DOI 10.17487/RFC1122, October 1989, . 1326 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 1327 "Randomness Requirements for Security", BCP 106, RFC 4086, 1328 DOI 10.17487/RFC4086, June 2005, . 1331 [RFC7696] Housley, R., "Guidelines for Cryptographic Algorithm 1332 Agility and Selecting Mandatory-to-Implement Algorithms", 1333 BCP 201, RFC 7696, DOI 10.17487/RFC7696, November 2015, 1334 . 1336 [tcpcrypt] 1337 Bittau, A., Hamburg, M., Handley, M., Mazieres, D., and D. 1338 Boneh, "The case for ubiquitous transport-level 1339 encryption", USENIX Security , 2010. 1341 Authors' Addresses 1343 Andrea Bittau 1344 Google 1345 345 Spear Street 1346 San Francisco, CA 94105 1347 US 1349 Email: bittau@google.com 1351 Daniel B. Giffin 1352 Stanford University 1353 353 Serra Mall, Room 288 1354 Stanford, CA 94305 1355 US 1357 Email: dbg@scs.stanford.edu 1359 Mark Handley 1360 University College London 1361 Gower St. 1362 London WC1E 6BT 1363 UK 1365 Email: M.Handley@cs.ucl.ac.uk 1366 David Mazieres 1367 Stanford University 1368 353 Serra Mall, Room 290 1369 Stanford, CA 94305 1370 US 1372 Email: dm@uun.org 1374 Quinn Slack 1375 Sourcegraph 1376 121 2nd St Ste 200 1377 San Francisco, CA 94105 1378 US 1380 Email: sqs@sourcegraph.com 1382 Eric W. Smith 1383 Kestrel Institute 1384 3260 Hillview Avenue 1385 Palo Alto, CA 94304 1386 US 1388 Email: eric.smith@kestrel.edu