idnits 2.17.00 (12 Aug 2021) /tmp/idnits39951/draft-ietf-tcpinc-tcpcrypt-09.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 2, 2017) is 1660 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 693 -- Looks like a reference, but probably isn't: '1' on line 693 == Missing Reference: 'K-1' is mentioned on line 693, but not defined == Missing Reference: 'RFC-TBD' is mentioned on line 997, but not defined == Outdated reference: draft-ietf-tcpinc-tcpeno has been published as RFC 8547 ** Obsolete normative reference: RFC 7539 (Obsoleted by RFC 8439) == Outdated reference: A later version (-06) exists of draft-ietf-tcpinc-api-05 Summary: 1 error (**), 0 flaws (~~), 5 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group A. Bittau 3 Internet-Draft Google 4 Intended status: Experimental D. Giffin 5 Expires: May 6, 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 2, 2017 16 Cryptographic protection of TCP Streams (tcpcrypt) 17 draft-ietf-tcpinc-tcpcrypt-09 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 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 6, 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 (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 . . . . . . . . . . . . . . . . . . . . . . . 8 74 3.5. Session Resumption . . . . . . . . . . . . . . . . . . . 9 75 3.6. Data Encryption and Authentication . . . . . . . . . . . 12 76 3.7. TCP Header Protection . . . . . . . . . . . . . . . . . . 13 77 3.8. Re-Keying . . . . . . . . . . . . . . . . . . . . . . . . 13 78 3.9. Keep-Alive . . . . . . . . . . . . . . . . . . . . . . . 14 79 4. Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . 15 80 4.1. Key-Exchange Messages . . . . . . . . . . . . . . . . . . 15 81 4.2. Encryption Frames . . . . . . . . . . . . . . . . . . . . 17 82 4.2.1. Plaintext . . . . . . . . . . . . . . . . . . . . . . 17 83 4.2.2. Associated Data . . . . . . . . . . . . . . . . . . . 18 84 4.2.3. Frame Nonce . . . . . . . . . . . . . . . . . . . . . 19 85 4.3. Constant Values . . . . . . . . . . . . . . . . . . . . . 19 86 5. Key-Agreement Schemes . . . . . . . . . . . . . . . . . . . . 19 87 6. AEAD Algorithms . . . . . . . . . . . . . . . . . . . . . . . 21 88 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 21 89 8. Security Considerations . . . . . . . . . . . . . . . . . . . 22 90 8.1. Asymmetric Roles . . . . . . . . . . . . . . . . . . . . 24 91 8.2. Verified Liveness . . . . . . . . . . . . . . . . . . . . 24 92 8.3. Mandatory Key-Agreement Schemes . . . . . . . . . . . . . 25 93 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 25 94 10. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 26 95 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 26 96 11.1. Normative References . . . . . . . . . . . . . . . . . . 26 97 11.2. Informative References . . . . . . . . . . . . . . . . . 27 98 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 28 100 1. Requirements Language 102 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 103 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 104 "OPTIONAL" in this document are to be interpreted as described in BCP 105 14 [RFC2119] [RFC8174] when, and only when, they appear in all 106 capitals, as shown here. 108 2. Introduction 110 This document describes tcpcrypt, an extension to TCP for 111 cryptographic protection of session data. Tcpcrypt was designed to 112 meet the following goals: 114 o Meet the requirements of the TCP Encryption Negotiation Option 115 (TCP-ENO) [I-D.ietf-tcpinc-tcpeno] for protecting connection data. 117 o Be amenable to small, self-contained implementations inside TCP 118 stacks. 120 o Minimize additional latency at connection startup. 122 o As much as possible, prevent connection failure in the presence of 123 NATs and other middleboxes that might normalize traffic or 124 otherwise manipulate TCP segments. 126 o Operate independently of IP addresses, making it possible to 127 authenticate resumed sessions efficiently even when either end 128 changes IP address. 130 A companion document [I-D.ietf-tcpinc-api] describes recommended 131 interfaces for configuring certain parameters of this protocol. 133 3. Encryption Protocol 135 This section describes the tcpcrypt protocol at an abstract level. 136 The concrete format of all messages is specified in Section 4. 138 3.1. Cryptographic Algorithms 140 Setting up a tcpcrypt connection employs three types of cryptographic 141 algorithms: 143 o A _key agreement scheme_ is used with a short-lived public key to 144 agree upon a shared secret. 146 o An _extract function_ is used to generate a pseudo-random key 147 (PRK) from some initial keying material, typically the output of 148 the key agreement scheme. The notation Extract(S, IKM) denotes 149 the output of the extract function with salt S and initial keying 150 material IKM. 152 o A _collision-resistant pseudo-random function (CPRF)_ is used to 153 generate multiple cryptographic keys from a pseudo-random key, 154 typically the output of the extract function. The CPRF produces 155 an arbitrary amount of Output Keying Material (OKM), and we use 156 the notation CPRF(K, CONST, L) to designate the first L bytes of 157 the OKM produced by the CPRF when parameterized by key K and the 158 constant CONST. 160 The Extract and CPRF functions used by the tcpcrypt variants defined 161 in this document are the Extract and Expand functions of HKDF 162 [RFC5869], which is built on HMAC [RFC2104]. These are defined as 163 follows in terms of the function "HMAC-Hash(key, value)" for a 164 negotiated "Hash" function such as SHA-256; the symbol | denotes 165 concatenation, and the counter concatenated to the right of CONST 166 occupies a single octet. 168 HKDF-Extract(salt, IKM) -> PRK 169 PRK = HMAC-Hash(salt, IKM) 171 HKDF-Expand(PRK, CONST, L) -> OKM 172 T(0) = empty string (zero length) 173 T(1) = HMAC-Hash(PRK, T(0) | CONST | 0x01) 174 T(2) = HMAC-Hash(PRK, T(1) | CONST | 0x02) 175 T(3) = HMAC-Hash(PRK, T(2) | CONST | 0x03) 176 ... 178 OKM = first L octets of T(1) | T(2) | T(3) | ... 179 where L < 255*OutputLength(Hash) 181 Figure 1: HKDF functions used for key derivation 183 Lastly, once tcpcrypt has been successfully set up and encryption 184 keys have been derived, an algorithm for Authenticated Encryption 185 with Associated Data (AEAD) is used to protect the confidentiality 186 and integrity of all transmitted application data. AEAD algorithms 187 use a single key to encrypt their input data and also to generate a 188 cryptographic tag to accompany the resulting ciphertext; when 189 decryption is performed, the tag allows authentication of the 190 encrypted data and of optional, associated plaintext data. 192 3.2. Protocol Negotiation 194 Tcpcrypt depends on TCP-ENO [I-D.ietf-tcpinc-tcpeno] to negotiate 195 whether encryption will be enabled for a connection, and also which 196 key-agreement scheme to use. TCP-ENO negotiates the use of a 197 particular TCP encryption protocol or _TEP_ by including protocol 198 identifiers in ENO suboptions. This document associates four TEP 199 identifiers with the tcpcrypt protocol, as listed in Table 4. Each 200 identifier indicates the use of a particular key-agreement scheme, 201 with an associated CPRF and length parameters. Future standards may 202 associate additional TEP identifiers with tcpcrypt, following the 203 assignment policy specified by TCP-ENO. 205 An active opener that wishes to negotiate the use of tcpcrypt 206 includes an ENO option in its SYN segment. That option includes 207 suboptions with tcpcrypt TEP identifiers indicating the key-agreement 208 schemes it is willing to enable. The active opener MAY additionally 209 include suboptions indicating support for encryption protocols other 210 than tcpcrypt, as well as global suboptions as specified by TCP-ENO. 212 If a passive opener receives an ENO option including tcpcrypt TEPs it 213 supports, it MAY then attach an ENO option to its SYN-ACK segment, 214 including _solely_ the TEP it wishes to enable. 216 To establish distinct roles for the two hosts in each connection, 217 tcpcrypt depends on the role-negotiation mechanism of TCP-ENO. As 218 one result of the negotiation process, TCP-ENO assigns hosts unique 219 roles abstractly called "A" at one end of the connection and "B" at 220 the other. Generally, an active opener plays the "A" role and a 221 passive opener plays the "B" role; but in the case of simultaneous 222 open, an additional mechanism breaks the symmetry and assigns a 223 distinct role to each host. TCP-ENO uses the terms "host A" and 224 "host B" to identify each end of a connection uniquely, and this 225 document employs those terms in the same way. 227 An ENO suboption includes a flag "v" which indicates the presence of 228 associated, variable-length data. In order to propose fresh key 229 agreement with a particular tcpcrypt TEP, a host sends a one-byte 230 suboption containing the TEP identifier and "v = 0". In order to 231 propose session resumption (described further below) with a 232 particular TEP, a host sends a variable-length suboption containing 233 the TEP identifier, the flag "v = 1", and an identifier derived from 234 a session secret previously negotiated with the same host and the 235 same TEP. 237 Once two hosts have exchanged SYN segments, TCP-ENO defines the 238 _negotiated TEP_ to be the last valid TEP identifier in the SYN 239 segment of host B (that is, the passive opener in the absence of 240 simultaneous open) that also occurs in that of host A. If there is 241 no such TEP, hosts MUST disable TCP-ENO and tcpcrypt. 243 If the negotiated TEP was sent by host B with "v = 0", it means that 244 fresh key agreement will be performed as described below in 245 Section 3.3. If it had "v = 1", the key-exchange messages will be 246 omitted in favor of determining keys via session-resumption as 247 described in Section 3.5, and protected application data may 248 immediately be sent as detailed in Section 3.6. 250 Note that the negotiated TEP is determined without reference to the 251 "v" bits in ENO suboptions, so if host A offers resumption with a 252 particular TEP and host B replies with a non-resumption suboption 253 with the same TEP, that may become the negotiated TEP and fresh key 254 agreement will be performed. That is, sending a resumption suboption 255 also implies willingness to perform fresh key agreement with the 256 indicated TEP. 258 As required by TCP-ENO, once a host has both sent and received an ACK 259 segment containing a valid ENO option, encryption MUST be enabled and 260 plaintext application data MUST NOT ever be exchanged on the 261 connection. If the negotiated TEP is among those listed in Table 4, 262 a host MUST follow the protocol described in this document. 264 3.3. Key Exchange 266 Following successful negotiation of a tcpcrypt TEP, all further 267 signaling is performed in the Data portion of TCP segments. Except 268 when resumption was negotiated (described below in Section 3.5), the 269 two hosts perform key exchange through two messages, "Init1" and 270 "Init2", at the start of the data streams of host A and host B, 271 respectively. These messages may span multiple TCP segments and need 272 not end at a segment boundary. However, the segment containing the 273 last byte of an "Init1" or "Init2" message MUST have TCP's push flag 274 (PSH) set. 276 The key exchange protocol, in abstract, proceeds as follows: 278 A -> B: Init1 = { INIT1_MAGIC, sym_cipher_list, N_A, PK_A } 279 B -> A: Init2 = { INIT2_MAGIC, sym_cipher, N_B, PK_B } 281 The concrete format of these messages is specified in Section 4.1. 283 The parameters are defined as follows: 285 o "INIT1_MAGIC", "INIT2_MAGIC": constants defined in Table 1. 287 o "sym_cipher_list": a list of symmetric ciphers (AEAD algorithms) 288 acceptable to host A. These are specified in Table 5. 290 o "sym_cipher": the symmetric cipher selected by host B from the 291 "sym_cipher_list" sent by host A. 293 o "N_A", "N_B": nonces chosen at random by hosts A and B, 294 respectively. 296 o "PK_A", "PK_B": ephemeral public keys for hosts A and B, 297 respectively. These, as well as their corresponding private keys, 298 are short-lived values that SHOULD be refreshed periodically. The 299 private keys SHOULD NOT ever be written to persistent storage. 301 The ephemeral secret ("ES") is the result of the key-agreement 302 algorithm (see Section 5) indicated by the negotiated TEP. The 303 inputs to the algorithm are the local host's ephemeral private key 304 and the remote host's ephemeral public key. For example, host A 305 would compute "ES" using its own private key (not transmitted) and 306 host B's public key, "PK_B". 308 The two sides then compute a pseudo-random key ("PRK"), from which 309 all session keys are derived, as follows: 311 PRK = Extract(N_A, eno-transcript | Init1 | Init2 | ES) 313 Above, "|" denotes concatenation; "eno-transcript" is the protocol- 314 negotiation transcript defined in Section 4.8 of 315 [I-D.ietf-tcpinc-tcpeno]; and "Init1" and "Init2" are the transmitted 316 encodings of the messages described in Section 4.1. 318 A series of "session secrets" are then computed from "PRK" as 319 follows: 321 ss[0] = PRK 322 ss[i] = CPRF(ss[i-1], CONST_NEXTK, K_LEN) 324 The value "ss[0]" is used to generate all key material for the 325 current connection. The values "ss[i]" for "i > 0" can be used to 326 avoid public key cryptography when establishing subsequent 327 connections between the same two hosts, as described in Section 3.5. 328 The "CONST_*" values are constants defined in Table 1. The length 329 "K_LEN" depends on the tcpcrypt TEP in use, and is specified in 330 Section 5. 332 Given a session secret "ss[i]", the two sides compute a series of 333 master keys as follows: 335 mk[0] = CPRF(ss[i], CONST_REKEY, K_LEN) 336 mk[j] = CPRF(mk[j-1], CONST_REKEY, K_LEN) 338 The process of advancing through the series of master keys is 339 described in Section 3.8. 341 Finally, each master key "mk[j]" is used to generate keys for 342 authenticated encryption: 344 k_ab[j] = CPRF(mk[j], CONST_KEY_A, ae_keylen) 345 k_ba[j] = CPRF(mk[j], CONST_KEY_B, ae_keylen) 347 In the first session derived from fresh key-agreement, keys "k_ab[j]" 348 are used by host A to encrypt and host B to decrypt, while keys 349 "k_ba[j]" are used by host B to encrypt and host A to decrypt. In a 350 resumed session, as described more thoroughly below in Section 3.5, 351 each host uses the keys in the same way as it did in the original 352 session, regardless of its role in the current session: for example, 353 if a host played role "A" in the first session, it will use keys 354 "k_ab[j]" to encrypt in each derived session. 356 The value "ae_keylen" depends on the authenticated-encryption 357 algorithm selected, and is given under "Key Length" in Table 5. 359 After host B sends "Init2" or host A receives it, that host may 360 immediately begin transmitting protected application data as 361 described in Section 3.6. 363 If host A receives "Init2" with a "sym_cipher" value that was not 364 present in the "sym_cipher_list" it previously transmitted in 365 "Init1", it MUST abort the connection and raise an error condition 366 distinct from the end-of-file condition. 368 Throughout this document, to "abort the connection" means to issue 369 the "Abort" command as described in [RFC0793], Section 3.8. That is, 370 the TCP connection is destroyed, RESET is transmitted, and the local 371 user is alerted to the abort event. 373 3.4. Session ID 375 TCP-ENO requires each TEP to define a _session ID_ value that 376 uniquely identifies each encrypted connection. 378 As required, a tcpcrypt session ID begins with the byte transmitted 379 by host B that contains the negotiated TEP identifier along with the 380 "v" bit. The remainder of the ID is derived from the session secret, 381 as follows: 383 session_id[i] = TEP-byte | CPRF(ss[i], CONST_SESSID, K_LEN) 385 Again, the length "K_LEN" depends on the TEP, and is specified in 386 Section 5. 388 3.5. Session Resumption 390 If two hosts have previously negotiated a session with a particular 391 session secret, they can establish a new connection without public- 392 key operations using the next session secret in the sequence derived 393 from the original PRK. 395 A host signals willingness to resume with a particular session secret 396 by sending a SYN segment with a resumption suboption: that is, an ENO 397 suboption whose value is the negotiated TEP identifier of the session 398 concatenated with half of the "resumption identifier" for the 399 session. 401 The resumption identifier is calculated from a session secret "ss[i]" 402 as follows: 404 resume[i] = CPRF(ss[i], CONST_RESUME, 18) 406 To name a session for resumption, a host sends either the first or 407 second half of the resumption identifier, according to the role it 408 played in the original session with secret "ss[0]". 410 A host that originally played role A and wishes to resume from a 411 cached session sends a suboption with the first half of the 412 resumption identifier: 414 byte 0 1 9 (10 bytes total) 415 +--------+--------+---...---+--------+ 416 | TEP- | resume[i]{0..8} | 417 | byte | | 418 +--------+--------+---...---+--------+ 420 Figure 2: Resumption suboption sent when original role was A. The 421 TEP-byte contains a tcpcrypt TEP identifier and v = 1. 423 Similarly, a host that originally played role B sends a suboption 424 with the second half of the resumption identifier: 426 byte 0 1 9 (10 bytes total) 427 +--------+--------+---...---+--------+ 428 | TEP- | resume[i]{9..17} | 429 | byte | | 430 +--------+--------+---...---+--------+ 432 Figure 3: Resumption suboption sent when original role was B. The 433 TEP-byte contains a tcpcrypt TEP identifier and v = 1. 435 If a passive opener receives a resumption suboption containing an 436 identifier-half it recognizes as being derived from a session secret 437 that it has cached, it SHOULD (with exceptions specified below) agree 438 to resume from the cached session by sending its own resumption 439 suboption, which will contain the other half of the identifier. 441 If the passive opener does not agree to resumption with a particular 442 TEP, it may either request fresh key exchange by responding with a 443 non-resumption suboption using the same TEP, or else respond to any 444 other received suboption. 446 If an active opener receives a resumption suboption for a particular 447 TEP and the received identifier-half does not match the "resume[i]" 448 value whose other half it previously sent in a resumption suboption 449 for the same TEP, it MUST ignore that suboption. In the typical case 450 that this was the only ENO suboption received, this means the host 451 MUST disable TCP-ENO and tcpcrypt: that is, it MUST NOT send any more 452 ENO options and MUST NOT encrypt the connection. 454 When a host concludes that TCP-ENO negotiation has succeeded for some 455 TEP that was received in a resumption suboption, it MUST then enable 456 encryption with that TEP, using the cached session secret, as 457 described in Section 3.6. 459 The session ID (Section 3.4) is constructed in the same way for 460 resumed sessions as it is for fresh ones. In this case the first 461 byte will always have "v = 1". The remainder of the ID is derived 462 from the cached session secret. 464 In the case of simultaneous open where TCP-ENO is able to establish 465 asymmetric roles, two hosts that simultaneously send SYN segments 466 with compatible resumption suboptions may resume the associated 467 session. 469 In a particular SYN segment, a host SHOULD NOT send more than one 470 resumption suboption, and MUST NOT send more than one resumption 471 suboption with the same TEP identifier. But in addition to any 472 resumption suboptions, an active opener MAY include non-resumption 473 suboptions describing other TEPs it supports (in addition to the TEP 474 in the resumption suboption). 476 After using "ss[i]" to compute "mk[0]", implementations SHOULD 477 compute and cache "ss[i+1]" for possible use by a later session, then 478 erase "ss[i]" from memory. Hosts SHOULD retain "ss[i+1]" until it is 479 used or the memory needs to be reclaimed. Hosts SHOULD NOT write a 480 cached "ss[i+1]" value to non-volatile storage. 482 When proposing resumption, the active opener MUST use the lowest 483 value of "i" that has not already been used (successfully or not) to 484 negotiate resumption with the same host and for the same pre-session 485 key "ss[0]". 487 A session secret may not be used to secure more than one TCP 488 connection. To prevent this, a host MUST NOT resume with a session 489 secret if it has ever enabled encryption in the past with the same 490 secret, in either role. In the event that two hosts simultaneously 491 send SYN segments to each other that propose resumption with the same 492 session secret but the two segments are not part of a simultaneous 493 open, both connections will have to revert to fresh key-exchange. To 494 avoid this limitation, implementations MAY choose to implement 495 session resumption such that a given pre-session key "ss[0]" is only 496 used for either passive or active opens at the same host, not both. 498 If two hosts have previously negotiated a tcpcrypt session, either 499 host may later initiate session resumption regardless of which host 500 was the active opener or played the "A" role in the previous session. 502 However, a given host must either encrypt with keys "k_ab[j]" for all 503 sessions derived from the same pre-session key "ss[0]", or with keys 504 "k_ba[j]". Thus, which keys a host uses to send segments is not 505 affected by the role it plays in the current connection: it depends 506 only on whether the host played the "A" or "B" role in the initial 507 session. 509 Implementations that cache session secrets MUST provide a means for 510 applications to control that caching. In particular, when an 511 application requests a new TCP connection, it must be able to specify 512 that during the connection no session secrets will be cached and all 513 resumption requests will be ignored in favor of fresh key exchange. 514 And for an established connection, an application must be able to 515 cause any cache state that was used in or resulted from establishing 516 the connection to be flushed. A companion document 517 [I-D.ietf-tcpinc-api] describes recommended interfaces for this 518 purpose. 520 3.6. Data Encryption and Authentication 522 Following key exchange (or its omission via session resumption), all 523 further communication in a tcpcrypt-enabled connection is carried out 524 within delimited _encryption frames_ that are encrypted and 525 authenticated using the agreed keys. 527 This protection is provided via algorithms for Authenticated 528 Encryption with Associated Data (AEAD). The particular algorithms 529 that may be used are listed in Table 5, and additional algorithms may 530 be specified according to the policy in Section 7. One algorithm is 531 selected during the negotiation described in Section 3.3. 533 The format of an encryption frame is specified in Section 4.2. A 534 sending host breaks its stream of application data into a series of 535 chunks. Each chunk is placed in the "data" portion of a "plaintext" 536 value, which is then encrypted to yield a frame's "ciphertext" field. 537 Chunks must be small enough that the ciphertext (whose length depends 538 on the AEAD cipher used, and is generally slightly longer than the 539 plaintext) has length less than 2^16 bytes. 541 An "associated data" value (see Section 4.2.2) is constructed for the 542 frame. It contains the frame's "control" field and the length of the 543 ciphertext. 545 A "frame nonce" value (see Section 4.2.3) is also constructed for the 546 frame but not explicitly transmitted. It contains an "offset" field 547 whose integer value is the zero-indexed byte offset of the beginning 548 of the current encryption frame in the underlying TCP datastream. 549 (That is, the offset in the framing stream, not the plaintext 550 application stream.) Because it is strictly necessary for the 551 security of the AEAD algorithms specified in this document, an 552 implementation MUST NOT ever transmit distinct frames with the same 553 nonce value under the same encryption key. In particular, a 554 retransmitted TCP segment MUST contain the same payload bytes for the 555 same TCP sequence numbers, and a host MUST NOT transmit more than 556 2^64 bytes in the underlying TCP datastream (which would cause the 557 "offset" field to wrap) before re-keying. 559 With reference to the "AEAD Interface" described in Section 2 of 560 [RFC5116], tcpcrypt invokes the AEAD algorithm with the secret key 561 "K" set to "k_ab[j]" or "k_ba[j]" for some "j", according to the 562 host's role as described in Section 3.3. The plaintext value serves 563 as "P", the associated data as "A", and the frame nonce as "N". The 564 output of the encryption operation, "C", is transmitted in the 565 frame's "ciphertext" field. 567 When a frame is received, tcpcrypt reconstructs the associated data 568 and frame nonce values (the former contains only data sent in the 569 clear, and the latter is implicit in the TCP stream), and provides 570 these and the ciphertext value to the the AEAD decryption operation. 571 The output of this operation is either a plaintext value "P" or the 572 special symbol FAIL. In the latter case, the implementation MUST 573 either drop the TCP segment(s) containing the frame or abort the 574 connection; but if it aborts, the implementation MUST raise an error 575 condition distinct from the end-of-file condition. 577 3.7. TCP Header Protection 579 The "ciphertext" field of the encryption frame contains protected 580 versions of certain TCP header values. 582 When the "URGp" bit is set, the "urgent" value indicates an offset 583 from the current frame's beginning offset; the sum of these offsets 584 gives the index of the last byte of urgent data in the application 585 datastream. 587 A sender MUST set the "FINp" bit on the last frame it sends in the 588 connection (unless it aborts the connection), and MUST NOT set "FINp" 589 on any other frame. 591 TCP sets the FIN flag when a sender has no more data, which with 592 tcpcrypt means setting FIN on the segment containing the last byte of 593 the last frame. However, a receiver MUST report the end-of-file 594 condition to the connection's local user when and only when it 595 receives a frame with the "FINp" bit set. If a host receives a 596 segment with the TCP FIN flag set but the received datastream 597 including this segment does not contain a frame with "FINp" set, the 598 host SHOULD abort the connection and raise an error condition 599 distinct from the end-of-file condition. But if there are 600 unacknowledged segments whose retransmission could potentially result 601 in a valid frame, the host MAY instead drop the segment with the TCP 602 FIN flag set. 604 3.8. Re-Keying 606 Re-keying allows hosts to wipe from memory keys that could decrypt 607 previously transmitted segments. It also allows the use of AEAD 608 ciphers that can securely encrypt only a bounded number of messages 609 under a given key. 611 As described above in Section 3.3, a master key "mk[j]" is used to 612 generate two encryption keys "k_ab[j]" and "k_ba[j]". We refer to 613 these as a _key-set_ with _generation number_ "j". Each host 614 maintains a _local generation number_ that determines which key-set 615 it uses to encrypt outgoing frames, and a _remote generation number_ 616 equal to the highest generation used in frames received from its 617 peer. Initially, these two generation numbers are set to zero. 619 A host MAY increment its local generation number beyond the remote 620 generation number it has recorded. We call this action _initiating 621 re-keying_. 623 When a host has incremented its local generation number and uses the 624 new key-set for the first time to encrypt an outgoing frame, it MUST 625 set "rekey = 1" for that frame. It MUST set this field to zero in 626 all other cases. 628 When a host receives a frame with "rekey = 1", it increments its 629 record of the remote generation number. If the remote generation 630 number is now greater than the local generation number, the receiver 631 MUST immediately increment its local generation number to match. 632 Moreover, if the receiver has not yet transmitted a segment with the 633 FIN flag set, it MUST immediately send a frame (with empty 634 application data if necessary) with "rekey = 1". 636 A host SHOULD NOT initiate more than one concurrent re-key operation 637 if it has no data to send; that is, it should not initiate re-keying 638 with an empty encryption frame more than once while its record of the 639 remote generation number is less than its own. 641 Note that when parts of the datastream are retransmitted, TCP 642 requires that implementations always send the same data bytes for the 643 same TCP sequence numbers. Thus, frame data in retransmitted 644 segments must be encrypted with the same key as when it was first 645 transmitted, regardless of the current local generation number. 647 Implementations SHOULD delete older-generation keys from memory once 648 they have received all frames they will need to decrypt with the old 649 keys and have encrypted all outgoing frames under the old keys. 651 3.9. Keep-Alive 653 Instead of using TCP Keep-Alives to verify that the remote endpoint 654 is still responsive, tcpcrypt implementations SHOULD employ the re- 655 keying mechanism for this purpose, as follows. When necessary, a 656 host SHOULD probe the liveness of its peer by initiating re-keying 657 and transmitting a new frame immediately (with empty application data 658 if necessary). 660 As described in Section 3.8, a host receiving a frame encrypted under 661 a generation number greater than its own MUST increment its own 662 generation number and (if it has not already transmitted a segment 663 with FIN set) immediately transmit a new frame (with zero-length 664 application data if necessary). 666 Implementations MAY use TCP Keep-Alives for purposes that do not 667 require endpoint authentication, as discussed in Section 8.2. 669 4. Encodings 671 This section provides byte-level encodings for values transmitted or 672 computed by the protocol. 674 4.1. Key-Exchange Messages 676 The "Init1" message has the following encoding: 678 byte 0 1 2 3 679 +-------+-------+-------+-------+ 680 | INIT1_MAGIC | 681 | | 682 +-------+-------+-------+-------+ 684 4 5 6 7 685 +-------+-------+-------+-------+ 686 | message_len | 687 | = M | 688 +-------+-------+-------+-------+ 690 8 691 +--------+-----+----+-----+----+---...---+-----+-----+ 692 |nciphers|sym_ |sym_ | |sym_ | 693 | = K |cipher[0] |cipher[1] | |cipher[K-1]| 694 +--------+-----+----+-----+----+---...---+-----+-----+ 696 2*K + 9 2*K + 9 + N_A_LEN 697 | | 698 v v 699 +-------+---...---+-------+-------+---...---+-------+ 700 | N_A | PK_A | 701 | | | 702 +-------+---...---+-------+-------+---...---+-------+ 704 M - 1 705 +-------+---...---+-------+ 706 | ignored | 707 | | 708 +-------+---...---+-------+ 710 The constant "INIT1_MAGIC" is defined in Table 1. The four-byte 711 field "message_len" gives the length of the entire "Init1" message, 712 encoded as a big-endian integer. The "nciphers" field contains an 713 integer value that specifies the number of two-byte symmetric-cipher 714 identifiers that follow. The "sym_cipher[i]" identifiers indicate 715 cryptographic algorithms in Table 5. The length "N_A_LEN" and the 716 length of "PK_A" are both determined by the negotiated TEP, as 717 described in Section 5. 719 Implementations of this protocol MUST construct "Init1" such that the 720 field "ignored" has zero length; that is, they must construct the 721 message such that its end, as determined by "message_len", coincides 722 with the end of the field "PK_A". When receiving "Init1", however, 723 implementations MUST permit and ignore any bytes following "PK_A". 725 The "Init2" message has the following encoding: 727 byte 0 1 2 3 728 +-------+-------+-------+-------+ 729 | INIT2_MAGIC | 730 | | 731 +-------+-------+-------+-------+ 733 4 5 6 7 8 9 734 +-------+-------+-------+-------+-------+-------+ 735 | message_len | sym_cipher | 736 | = M | | 737 +-------+-------+-------+-------+-------+-------+ 739 10 10 + N_B_LEN 740 | | 741 v v 742 +-------+---...---+-------+-------+---...---+-------+ 743 | N_B | PK_B | 744 | | | 745 +-------+---...---+-------+-------+---...---+-------+ 747 M - 1 748 +-------+---...---+-------+ 749 | ignored | 750 | | 751 +-------+---...---+-------+ 753 The constant "INIT2_MAGIC" is defined in Table 1. The four-byte 754 field "message_len" gives the length of the entire "Init2" message, 755 encoded as a big-endian integer. The "sym_cipher" value is a 756 selection from the symmetric-cipher identifiers in the previously- 757 received "Init1" message. The length "N_B_LEN" and the length of 758 "PK_B" are both determined by the negotiated TEP, as described in 759 Section 5. 761 Implementations of this protocol MUST construct "Init2" such that the 762 field "ignored" has zero length; that is, they must construct the 763 message such that its end, as determined by "message_len", coincides 764 with the end of the "PK_B" field. When receiving "Init2", however, 765 implementations MUST permit and ignore any bytes following "PK_B". 767 4.2. Encryption Frames 769 An _encryption frame_ comprises a control byte and a length-prefixed 770 ciphertext value: 772 byte 0 1 2 3 clen+2 773 +-------+-------+-------+-------+---...---+-------+ 774 |control| clen | ciphertext | 775 +-------+-------+-------+-------+---...---+-------+ 777 The field "clen" is an integer in big-endian format and gives the 778 length of the "ciphertext" field. 780 The byte "control" has this structure: 782 bit 7 1 0 783 +-------+---...---+-------+-------+ 784 | cres | rekey | 785 +-------+---...---+-------+-------+ 787 The seven-bit field "cres" is reserved; implementations MUST set 788 these bits to zero when sending, and MUST ignore them when receiving. 790 The use of the "rekey" field is described in Section 3.8. 792 4.2.1. Plaintext 794 The "ciphertext" field is the result of applying the negotiated 795 authenticated-encryption algorithm to a "plaintext" value, which has 796 one of these two formats: 798 byte 0 1 plen-1 799 +-------+-------+---...---+-------+ 800 | flags | data | 801 +-------+-------+---...---+-------+ 803 byte 0 1 2 3 plen-1 804 +-------+-------+-------+-------+---...---+-------+ 805 | flags | urgent | data | 806 +-------+-------+-------+-------+---...---+-------+ 808 (Note that "clen" in the previous section will generally be greater 809 than "plen", as the ciphertext produced by the authenticated- 810 encryption scheme must both encrypt the application data and provide 811 a way to verify its integrity.) 813 The "flags" byte has this structure: 815 bit 7 6 5 4 3 2 1 0 816 +----+----+----+----+----+----+----+----+ 817 | fres |URGp|FINp| 818 +----+----+----+----+----+----+----+----+ 820 The six-bit value "fres" is reserved; implementations MUST set these 821 six bits to zero when sending, and MUST ignore them when receiving. 823 When the "URGp" bit is set, it indicates that the "urgent" field is 824 present, and thus that the plaintext value has the second structure 825 variant above; otherwise the first variant is used. 827 The meaning of "urgent" and of the flag bits is described in 828 Section 3.7. 830 4.2.2. Associated Data 832 An encryption frame's "associated data" (which is supplied to the 833 AEAD algorithm when decrypting the ciphertext and verifying the 834 frame's integrity) has this format: 836 byte 0 1 2 837 +-------+-------+-------+ 838 |control| clen | 839 +-------+-------+-------+ 841 It contains the same values as the frame's "control" and "clen" 842 fields. 844 4.2.3. Frame Nonce 846 Lastly, a "frame nonce" (provided as input to the AEAD algorithm) has 847 this format: 849 byte 850 +------+------+------+------+ 851 0 | FRAME_NONCE_MAGIC | 852 +------+------+------+------+ 853 4 | | 854 + offset + 855 8 | | 856 +------+------+------+------+ 858 The 4-byte magic constant is defined in Table 1. The 8-byte "offset" 859 field contains an integer in big-endian format. Its value is 860 specified in Section 3.6. 862 4.3. Constant Values 864 The table below defines values for the constants used in the 865 protocol. 867 +------------+-------------------+ 868 | Value | Name | 869 +------------+-------------------+ 870 | 0x01 | CONST_NEXTK | 871 | 0x02 | CONST_SESSID | 872 | 0x03 | CONST_REKEY | 873 | 0x04 | CONST_KEY_A | 874 | 0x05 | CONST_KEY_B | 875 | 0x06 | CONST_RESUME | 876 | 0x15101a0e | INIT1_MAGIC | 877 | 0x097105e0 | INIT2_MAGIC | 878 | 0x44415441 | FRAME_NONCE_MAGIC | 879 +------------+-------------------+ 881 Table 1: Constant values used in the protocol 883 5. Key-Agreement Schemes 885 The TEP negotiated via TCP-ENO indicates the use of one of the key- 886 agreement schemes named in Table 4. For example, 887 "TCPCRYPT_ECDHE_P256" names the tcpcrypt protocol using ECDHE-P256 888 together with the CPRF and length parameters specified below. 890 All the TEPs specified in this document require the use of HKDF- 891 Expand-SHA256 as the CPRF, and these lengths for nonces and session 892 keys: 894 N_A_LEN: 32 bytes 895 N_B_LEN: 32 bytes 896 K_LEN: 32 bytes 898 If future documents assign additional TEPs for use with tcpcrypt, 899 they may specify different values for the lengths above. Note that 900 the minimum session ID length required by TCP-ENO, together with the 901 way tcpcrypt constructs session IDs, implies that "K_LEN" must have 902 length at least 32 bytes. 904 Key-agreement schemes ECDHE-P256 and ECDHE-P521 employ the ECSVDP-DH 905 secret value derivation primitive defined in [ieee1363]. The named 906 curves are defined in [nist-dss]. When the public-key values "PK_A" 907 and "PK_B" are transmitted as described in Section 4.1, they are 908 encoded with the "Elliptic Curve Point to Octet String Conversion 909 Primitive" described in Section E.2.3 of [ieee1363], and are prefixed 910 by a two-byte length in big-endian format: 912 byte 0 1 2 L - 1 913 +-------+-------+-------+---...---+-------+ 914 | pubkey_len | pubkey | 915 | = L | | 916 +-------+-------+-------+---...---+-------+ 918 Implementations SHOULD encode these "pubkey" values in "compressed 919 format", and MUST accept values encoded in "compressed", 920 "uncompressed" or "hybrid" formats. 922 Key-agreement schemes ECDHE-Curve25519 and ECDHE-Curve448 use the 923 functions X25519 and X448, respectively, to perform the Diffie-Helman 924 protocol as described in [RFC7748]. When using these ciphers, 925 public-key values "PK_A" and "PK_B" are transmitted directly with no 926 length prefix: 32 bytes for Curve25519, and 56 bytes for Curve448. 928 Implementations are required to implement certain TEPs, according to 929 Table 2. Note that system administrators may configure which TEPs a 930 host will negotiate, independent of these requirements. 932 +-------------+---------------------------+ 933 | Requirement | TEP | 934 +-------------+---------------------------+ 935 | MUST | TCPCRYPT_ECDHE_Curve25519 | 936 | SHOULD | TCPCRYPT_ECDHE_Curve448 | 937 | MAY | TCPCRYPT_ECDHE_P256 | 938 | MAY | TCPCRYPT_ECDHE_P521 | 939 +-------------+---------------------------+ 941 Table 2: Requirements for implementation of TEPs 943 6. AEAD Algorithms 945 Specifiers and key-lengths for AEAD algorithms are given in Table 5. 946 The algorithms "AEAD_AES_128_GCM" and "AEAD_AES_256_GCM" are 947 specified in [RFC5116]. The algorithm "AEAD_CHACHA20_POLY1305" is 948 specified in [RFC7539]. 950 Implementations are required to support certain algorithms according 951 to Table 3. Note that system administrators may configure which 952 algorithms a host will negotiate, independent of these requirements. 954 +-------------+------------------------+ 955 | Requirement | AEAD Algorithm | 956 +-------------+------------------------+ 957 | MUST | AEAD_AES_128_GCM | 958 | SHOULD | AEAD_AES_256_GCM | 959 | SHOULD | AEAD_CHACHA20_POLY1305 | 960 +-------------+------------------------+ 962 Table 3: Requirements for implementation of AEAD algorithms 964 7. IANA Considerations 966 Tcpcrypt's TEP identifiers will need to be incorporated in IANA's 967 "TCP encryption protocol identifiers" registry under the 968 "Transmission Control Protocol (TCP) Parameters" registry, as in the 969 following table. The various key-agreement schemes used by these 970 tcpcrypt variants are defined in Section 5. 972 +-------+---------------------------+-----------+ 973 | Value | Meaning | Reference | 974 +-------+---------------------------+-----------+ 975 | 0x21 | TCPCRYPT_ECDHE_P256 | [RFC-TBD] | 976 | 0x22 | TCPCRYPT_ECDHE_P521 | [RFC-TBD] | 977 | 0x23 | TCPCRYPT_ECDHE_Curve25519 | [RFC-TBD] | 978 | 0x24 | TCPCRYPT_ECDHE_Curve448 | [RFC-TBD] | 979 +-------+---------------------------+-----------+ 981 Table 4: TEP identifiers for use with tcpcrypt 983 In Section 4.1, this document defines "sym_cipher" specifiers for 984 which IANA is to maintain a new "tcpcrypt AEAD Algorithm" registry 985 under the "Transmission Control Protocol (TCP) Parameters" registry, 986 with initial values as given in the following table. The AEAD 987 algorithms named there are defined in Section 6. Future assignments 988 are to be made under the "RFC Required" policy detailed in [RFC8126], 989 relying on early allocation [RFC7120] to facilitate testing before an 990 RFC is finalized. 992 +--------+------------------------+------------+-----------+ 993 | Value | AEAD Algorithm | Key Length | Reference | 994 +--------+------------------------+------------+-----------+ 995 | 0x0001 | AEAD_AES_128_GCM | 16 bytes | [RFC-TBD] | 996 | 0x0002 | AEAD_AES_256_GCM | 32 bytes | [RFC-TBD] | 997 | 0x0010 | AEAD_CHACHA20_POLY1305 | 32 bytes | [RFC-TBD] | 998 +--------+------------------------+------------+-----------+ 1000 Table 5: Authenticated-encryption algorithms corresponding to 1001 sym_cipher specifiers in Init1 and Init2 messages. 1003 8. Security Considerations 1005 Public-key generation, public-key encryption, and shared-secret 1006 generation all require randomness. Other tcpcrypt functions may also 1007 require randomness, depending on the algorithms and modes of 1008 operation selected. A weak pseudo-random generator at either host 1009 will compromise tcpcrypt's security. Many of tcpcrypt's 1010 cryptographic functions require random input, and thus any host 1011 implementing tcpcrypt MUST have access to a cryptographically-secure 1012 source of randomness or pseudo-randomness. 1014 Most implementations will rely on a device's pseudo-random generator, 1015 seeded from hardware events and a seed carried over from the previous 1016 boot. Once a pseudo-random generator has been properly seeded, it 1017 can generate effectively arbitrary amounts of pseudo-random data. 1018 However, until a pseudo-random generator has been seeded with 1019 sufficient entropy, not only will tcpcrypt be insecure, it will 1020 reveal information that further weakens the security of the pseudo- 1021 random generator, potentially harming other applications. As 1022 required by TCP-ENO, implementations MUST NOT send ENO options unless 1023 they have access to an adequate source of randomness. 1025 The cipher-suites specified in this document all use HMAC-SHA256 to 1026 implement the collision-resistant pseudo-random function denoted by 1027 "CPRF". A collision-resistant function is one for which, for 1028 sufficiently large L, an attacker cannot find two distinct inputs 1029 "K_1", "CONST_1" and "K_2", "CONST_2" such that "CPRF(K_1, CONST_1, 1030 L) = CPRF(K_2, CONST_2, L)". Collision resistance is important to 1031 assure the uniqueness of session IDs, which are generated using the 1032 CPRF. 1034 All of the security considerations of TCP-ENO apply to tcpcrypt. In 1035 particular, tcpcrypt does not protect against active eavesdroppers 1036 unless applications authenticate the session ID. If it can be 1037 established that the session IDs computed at each end of the 1038 connection match, then tcpcrypt guarantees that no man-in-the-middle 1039 attacks occurred unless the attacker has broken the underlying 1040 cryptographic primitives (e.g., ECDH). A proof of this property for 1041 an earlier version of the protocol has been published [tcpcrypt]. 1043 To gain middlebox compatibility, tcpcrypt does not protect TCP 1044 headers. Hence, the protocol is vulnerable to denial-of-service from 1045 off-path attackers just as plain TCP is. Possible attacks include 1046 desynchronizing the underlying TCP stream, injecting RST or FIN 1047 segments, and forging rekey bits. These attacks will cause a 1048 tcpcrypt connection to hang or fail with an error, but not in any 1049 circumstance where plain TCP could continue uncorrupted. 1050 Implementations MUST give higher-level software a way to distinguish 1051 such errors from a clean end-of-stream (indicated by an authenticated 1052 "FINp" bit) so that applications can avoid semantic truncation 1053 attacks. 1055 There is no "key confirmation" step in tcpcrypt. This is not 1056 required because tcpcrypt's threat model includes the possibility of 1057 a connection to an adversary. If key negotiation is compromised and 1058 yields two different keys, all subsequent frames will be ignored due 1059 to failed integrity checks, causing the application's connection to 1060 hang. This is not a new threat because in plain TCP, an active 1061 attacker could have modified sequence and acknowledgement numbers to 1062 hang the connection anyway. 1064 Tcpcrypt uses short-lived public keys to provide forward secrecy. 1065 That is, once an implementation removes these keys from memory, a 1066 compromise of the system will not provide any means to derive the 1067 session keys for past connections. All currently-specified key 1068 agreement schemes involve ECDHE-based key agreement, meaning a new 1069 keypair can be efficiently computed for each connection. If 1070 implementations reuse these parameters, they SHOULD limit the 1071 lifetime of the private parameters as far as practical in order to 1072 minimize the number of past connections that are vulnerable. 1074 Attackers cannot force passive openers to move forward in their 1075 session resumption chain without guessing the content of the 1076 resumption identifier, which will be difficult without key knowledge. 1078 8.1. Asymmetric Roles 1080 Tcpcrypt transforms a shared pseudo-random key (PRK) into 1081 cryptographic session keys for each direction. Doing so requires an 1082 asymmetry in the protocol, as the key derivation function must be 1083 perturbed differently to generate different keys in each direction. 1084 Tcpcrypt includes other asymmetries in the roles of the two hosts, 1085 such as the process of negotiating algorithms (e.g., proposing vs. 1086 selecting cipher suites). 1088 8.2. Verified Liveness 1090 Many hosts implement TCP Keep-Alives [RFC1122] as an option for 1091 applications to ensure that the other end of a TCP connection still 1092 exists even when there is no data to be sent. A TCP Keep-Alive 1093 segment carries a sequence number one prior to the beginning of the 1094 send window, and may carry one byte of "garbage" data. Such a 1095 segment causes the remote side to send an acknowledgment. 1097 Unfortunately, tcpcrypt cannot cryptographically verify Keep-Alive 1098 acknowledgments. Hence, an attacker could prolong the existence of a 1099 session at one host after the other end of the connection no longer 1100 exists. (Such an attack might prevent a process with sensitive data 1101 from exiting, giving an attacker more time to compromise a host and 1102 extract the sensitive data.) 1104 To counter this threat, tcpcrypt specifies a way to stimulate the 1105 remote host to send verifiably fresh and authentic data, described in 1106 Section 3.9. 1108 The TCP keep-alive mechanism has also been used for its effects on 1109 intermediate nodes in the network, such as preventing flow state from 1110 expiring at NAT boxes or firewalls. As these purposes do not require 1111 the authentication of endpoints, implementations may safely 1112 accomplish them using either the existing TCP keep-alive mechanism or 1113 tcpcrypt's verified keep-alive mechanism. 1115 8.3. Mandatory Key-Agreement Schemes 1117 This document mandates that tcpcrypt implementations provide support 1118 for at least one key-agreement scheme: ECDHE using Curve25519. This 1119 choice of a single mandatory algorithm is the result of a difficult 1120 tradeoff between cryptographic diversity and the ease and security of 1121 actual deployment. 1123 The IETF's appraisal of best current practice on this matter 1124 [RFC7696] says, "Ideally, two independent sets of mandatory-to- 1125 implement algorithms will be specified, allowing for a primary suite 1126 and a secondary suite. This approach ensures that the secondary 1127 suite is widely deployed if a flaw is found in the primary one." 1129 To meet that ideal, it might appear natural to also mandate ECDHE 1130 using P-256, as this scheme is well-studied, widely implemented, and 1131 sufficiently different from the Curve25519-based scheme that it is 1132 unlikely they will both suffer from a single (non-quantum) 1133 cryptanalytic advance. 1135 However, implementing the Diffie-Hellman function using NIST elliptic 1136 curves (including those specified for use with tcpcrypt, P-256 and 1137 P-521) appears to be very difficult to achieve without introducing 1138 vulnerability to side-channel attacks [nist-ecc]. Although well- 1139 trusted implementations are available as part of large cryptographic 1140 libraries, these may be difficult to extract for use in operating- 1141 system kernels where tcpcrypt is usually best implemented. In 1142 contrast, the characteristics of Curve25519 together with its recent 1143 popularity has led to many safe and efficient implementations, 1144 including some that fit naturally into the kernel environment. 1146 [RFC7696] insists that, "The selected algorithms need to be resistant 1147 to side-channel attacks and also meet the performance, power, and 1148 code size requirements on a wide variety of platforms." On this 1149 principle, tcpcrypt excludes the NIST curves from the set of 1150 mandatory-to-implement key-agreement algorithms. 1152 Lastly, this document encourages (via SHOULD) support for key- 1153 agreement with Curve448 as this scheme appears likely to admit safe 1154 and efficient implementations; but it does not absolutely require 1155 such support, as well-proven implementations may not yet be 1156 available. 1158 9. Acknowledgments 1160 We are grateful for contributions, help, discussions, and feedback 1161 from the TCPINC working group and from other IETF reviewers, 1162 including Marcelo Bagnulo, David Black, Bob Briscoe, Jana Iyengar, 1163 Stephen Kent, Tero Kivinen, Mirja Kuhlewind, Yoav Nir, Christoph 1164 Paasch, Eric Rescorla, Kyle Rose, and Dale Worley. 1166 This work was funded by gifts from Intel (to Brad Karp) and from 1167 Google; by NSF award CNS-0716806 (A Clean-Slate Infrastructure for 1168 Information Flow Control); by DARPA CRASH under contract 1169 #N66001-10-2-4088; and by the Stanford Secure Internet of Things 1170 Project. 1172 10. Contributors 1174 Dan Boneh and Michael Hamburg were co-authors of the draft that 1175 became this document. 1177 11. References 1179 11.1. Normative References 1181 [I-D.ietf-tcpinc-tcpeno] 1182 Bittau, A., Giffin, D., Handley, M., Mazieres, D., and E. 1183 Smith, "TCP-ENO: Encryption Negotiation Option", draft- 1184 ietf-tcpinc-tcpeno-11 (work in progress), October 2017. 1186 [ieee1363] 1187 IEEE, "IEEE Standard Specifications for Public-Key 1188 Cryptography (IEEE Std 1363-2000)", 2000. 1190 [nist-dss] 1191 NIST, "FIPS PUB 186-4: Digital Signature Standard (DSS)", 1192 2013. 1194 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 1195 RFC 793, DOI 10.17487/RFC0793, September 1981, 1196 . 1198 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1199 Hashing for Message Authentication", RFC 2104, 1200 DOI 10.17487/RFC2104, February 1997, 1201 . 1203 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1204 Requirement Levels", BCP 14, RFC 2119, 1205 DOI 10.17487/RFC2119, March 1997, 1206 . 1208 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 1209 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1210 . 1212 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1213 Key Derivation Function (HKDF)", RFC 5869, 1214 DOI 10.17487/RFC5869, May 2010, 1215 . 1217 [RFC7120] Cotton, M., "Early IANA Allocation of Standards Track Code 1218 Points", BCP 100, RFC 7120, DOI 10.17487/RFC7120, January 1219 2014, . 1221 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1222 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 1223 . 1225 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 1226 for Security", RFC 7748, DOI 10.17487/RFC7748, January 1227 2016, . 1229 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 1230 Writing an IANA Considerations Section in RFCs", BCP 26, 1231 RFC 8126, DOI 10.17487/RFC8126, June 2017, 1232 . 1234 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1235 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1236 May 2017, . 1238 11.2. Informative References 1240 [I-D.ietf-tcpinc-api] 1241 Bittau, A., Boneh, D., Giffin, D., Handley, M., Mazieres, 1242 D., and E. Smith, "Interface Extensions for TCP-ENO and 1243 tcpcrypt", draft-ietf-tcpinc-api-05 (work in progress), 1244 September 2017. 1246 [nist-ecc] 1247 Bernstein, D. and T. Lange, "Failures in NIST's ECC 1248 standards", 2016, 1249 . 1251 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 1252 Communication Layers", STD 3, RFC 1122, 1253 DOI 10.17487/RFC1122, October 1989, 1254 . 1256 [RFC7696] Housley, R., "Guidelines for Cryptographic Algorithm 1257 Agility and Selecting Mandatory-to-Implement Algorithms", 1258 BCP 201, RFC 7696, DOI 10.17487/RFC7696, November 2015, 1259 . 1261 [tcpcrypt] 1262 Bittau, A., Hamburg, M., Handley, M., Mazieres, D., and D. 1263 Boneh, "The case for ubiquitous transport-level 1264 encryption", USENIX Security , 2010. 1266 Authors' Addresses 1268 Andrea Bittau 1269 Google 1270 345 Spear Street 1271 San Francisco, CA 94105 1272 US 1274 Email: bittau@google.com 1276 Daniel B. Giffin 1277 Stanford University 1278 353 Serra Mall, Room 288 1279 Stanford, CA 94305 1280 US 1282 Email: dbg@scs.stanford.edu 1284 Mark Handley 1285 University College London 1286 Gower St. 1287 London WC1E 6BT 1288 UK 1290 Email: M.Handley@cs.ucl.ac.uk 1292 David Mazieres 1293 Stanford University 1294 353 Serra Mall, Room 290 1295 Stanford, CA 94305 1296 US 1298 Email: dm@uun.org 1299 Quinn Slack 1300 Sourcegraph 1301 121 2nd St Ste 200 1302 San Francisco, CA 94105 1303 US 1305 Email: sqs@sourcegraph.com 1307 Eric W. Smith 1308 Kestrel Institute 1309 3260 Hillview Avenue 1310 Palo Alto, CA 94304 1311 US 1313 Email: eric.smith@kestrel.edu