idnits 2.17.1 draft-ietf-tls-rfc2246-bis-13.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** It looks like you're using RFC 3978 boilerplate. You should update this to the boilerplate described in the IETF Trust License Policy document (see https://trustee.ietf.org/license-info), which is required now. -- Found old boilerplate from RFC 3978, Section 5.1 on line 17. -- Found old boilerplate from RFC 3978, Section 5.5 on line 4009. -- Found old boilerplate from RFC 3979, Section 5, paragraph 1 on line 3983. -- Found old boilerplate from RFC 3979, Section 5, paragraph 2 on line 3990. -- Found old boilerplate from RFC 3979, Section 5, paragraph 3 on line 3996. ** Found boilerplate matching RFC 3978, Section 5.4, paragraph 1 (on line 4001), which is fine, but *also* found old RFC 2026, Section 10.4C, paragraph 1 text on line 36. ** This document has an original RFC 3978 Section 5.4 Copyright Line, instead of the newer IETF Trust Copyright according to RFC 4748. ** This document has an original RFC 3978 Section 5.5 Disclaimer, instead of the newer disclaimer which includes the IETF Trust according to RFC 4748. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- ** The document seems to lack a 1id_guidelines paragraph about 6 months document validity -- however, there's a paragraph with a matching beginning. Boilerplate error? == No 'Intended status' indicated for this document; assuming Proposed Standard Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 24 instances of too long lines in the document, the longest one being 12 characters in excess of 72. == There are 1 instance of lines with non-RFC6890-compliant IPv4 addresses in the document. If these are example addresses, they should be changed. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the RFC 3978 Section 5.4 Copyright Line does not match the current year == Line 810 has weird spacing: '...gorithm bul...' == Line 3682 has weird spacing: '...tegrity and...' == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'SHOULD not' in this paragraph: After sending a hello request, servers SHOULD not repeat the request until the subsequent handshake negotiation is complete. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: Warning: Because the SessionID is transmitted without encryption or immediate MAC protection, servers MUST not place confidential information in session identifiers or let the contents of fake session identifiers cause any breach of security. (Note that the content of the handshake as a whole, including the SessionID, is protected by the Finished messages exchanged at the end of the handshake.) == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: Meaning of this message: With this message, the premaster secret is set, either though direct transmission of the RSA-encrypted secret, or by the transmission of Diffie-Hellman parameters which will allow each side to agree upon the same premaster secret. When the key exchange method is DH_RSA or DH_DSS, client certification has been requested, and the client was able to respond with a certificate which contained a Diffie-Hellman public key whose parameters (group and generator) matched those specified by the server in its certificate, this message MUST not contain any data. -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- Couldn't find a document date in the document -- date freshness check skipped. -- 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: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '0' on line 368 -- Looks like a reference, but probably isn't: '1' on line 368 -- Looks like a reference, but probably isn't: '3' on line 3366 -- Looks like a reference, but probably isn't: '9' on line 404 -- Looks like a reference, but probably isn't: '2' on line 2674 -- Looks like a reference, but probably isn't: '4' on line 439 -- Looks like a reference, but probably isn't: '8' on line 440 -- Looks like a reference, but probably isn't: '10' on line 534 -- Looks like a reference, but probably isn't: '20' on line 2747 -- Looks like a reference, but probably isn't: '48' on line 2983 -- Looks like a reference, but probably isn't: '32' on line 2985 == Missing Reference: 'ChangeCipherSpec' is mentioned on line 1633, but not defined -- Looks like a reference, but probably isn't: '28' on line 2669 -- Looks like a reference, but probably isn't: '16' on line 2742 -- Looks like a reference, but probably isn't: '46' on line 2780 -- Looks like a reference, but probably isn't: '12' on line 2803 == Missing Reference: 'PKCS1' is mentioned on line 2469, but not defined == Missing Reference: 'RFC 2434' is mentioned on line 2532, but not defined ** Obsolete undefined reference: RFC 2434 (Obsoleted by RFC 5226) == Missing Reference: 'RSADSI' is mentioned on line 3115, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'AES' -- Possible downref: Non-RFC (?) normative reference: ref. '3DES' -- Possible downref: Non-RFC (?) normative reference: ref. 'DES' -- Possible downref: Non-RFC (?) normative reference: ref. 'DSS' ** Downref: Normative reference to an Informational RFC: RFC 2104 (ref. 'HMAC') -- Possible downref: Non-RFC (?) normative reference: ref. 'IDEA' ** Downref: Normative reference to an Informational RFC: RFC 1321 (ref. 'MD5') ** Obsolete normative reference: RFC 2313 (ref. 'PKCS1A') (Obsoleted by RFC 2437) ** Obsolete normative reference: RFC 3447 (ref. 'PKCS1B') (Obsoleted by RFC 8017) ** Obsolete normative reference: RFC 3280 (ref. 'PKIX') (Obsoleted by RFC 5280) ** Downref: Normative reference to an Informational RFC: RFC 2268 (ref. 'RC2') -- Possible downref: Non-RFC (?) normative reference: ref. 'SCH' -- Possible downref: Non-RFC (?) normative reference: ref. 'SHA' ** Obsolete normative reference: RFC 3268 (ref. 'TLSAES') (Obsoleted by RFC 5246) ** Obsolete normative reference: RFC 3546 (ref. 'TLSEXT') (Obsoleted by RFC 4366) -- Obsolete informational reference (is this intentional?): RFC 2402 (ref. 'AH') (Obsoleted by RFC 4302, RFC 4305) -- Obsolete informational reference (is this intentional?): RFC 2406 (ref. 'ESP') (Obsoleted by RFC 4303, RFC 4305) -- Obsolete informational reference (is this intentional?): RFC 1750 (ref. 'RANDOM') (Obsoleted by RFC 4086) -- Obsolete informational reference (is this intentional?): RFC 1948 (ref. 'SEQNUM') (Obsoleted by RFC 6528) -- Obsolete informational reference (is this intentional?): RFC 793 (ref. 'TCP') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 1832 (ref. 'XDR') (Obsoleted by RFC 4506) Summary: 15 errors (**), 0 flaws (~~), 13 warnings (==), 36 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Tim Dierks 3 Independent 4 Eric Rescorla 5 INTERNET-DRAFT RTFM, Inc. 6 June 2005 (Expires December 2005) 8 The TLS Protocol 9 Version 1.1 11 Status of this Memo 13 By submitting this Internet-Draft, each author represents that 14 any applicable patent or other IPR claims of which he or she is 15 aware have been or will be disclosed, and any of which he or she 16 becomes aware will be disclosed, in accordance with Section 6 of 17 BCP 79. 19 Internet-Drafts are working documents of the Internet Engineering 20 Task Force (IETF), its areas, and its working groups. Note that other 21 groups may also distribute working documents as Internet-Drafts. 23 Internet-Drafts are draft documents valid for a maximum of six months 24 and may be updated, replaced, or obsoleted by other documents at any 25 time. It is inappropriate to use Internet-Drafts as reference 26 material or to cite them other than a "work in progress." 28 The list of current Internet-Drafts can be accessed at 29 http://www.ietf.org/1id-abstracts.html 31 The list of Internet-Draft Shadow Directories can be accessed at 32 http://www.ietf.org/shadow.html 34 Copyright Notice 36 Copyright (C) The Internet Society (2005). All Rights Reserved. 38 Abstract 40 This document specifies Version 1.1 of the Transport Layer Security 41 (TLS) protocol. The TLS protocol provides communications security 42 over the Internet. The protocol allows client/server applications to 43 communicate in a way that is designed to prevent eavesdropping, 44 tampering, or message forgery. 46 Table of Contents 48 1. Introduction 49 5 1.1 Differences from TLS 1.0 50 6 1.1 Requirements Terminology 51 7 2. Goals 52 7 3. Goals of this document 53 7 4. Presentation language 54 8 4.1. Basic block size 55 9 4.2. Miscellaneous 56 9 4.3. Vectors 57 9 4.4. Numbers 58 10 4.5. Enumerateds 59 10 4.6. Constructed types 60 11 4.6.1. Variants 61 12 4.7. Cryptographic attributes 62 13 4.8. Constants 63 14 5. HMAC and the pseudorandom function 64 14 6. The TLS Record Protocol 65 17 6.1. Connection states 66 18 6.2. Record layer 67 20 6.2.1. Fragmentation 68 20 6.2.2. Record compression and decompression 69 21 6.2.3. Record payload protection 70 22 6.2.3.1. Null or standard stream cipher 71 23 6.2.3.2. CBC block cipher 72 23 6.3. Key calculation 73 26 7. The TLS Handshaking Protocols 74 27 7.1. Change cipher spec protocol 75 28 7.2. Alert protocol 76 28 7.2.1. Closure alerts 77 29 7.2.2. Error alerts 78 30 7.3. Handshake Protocol overview 79 33 7.4. Handshake protocol 80 37 7.4.1. Hello messages 81 38 7.4.1.1. Hello request 82 38 7.4.1.2. Client hello 83 39 7.4.1.3. Server hello 84 41 7.4.2. Server certificate 85 42 7.4.3. Server key exchange message 86 44 7.4.4. Certificate request 87 46 7.4.5. Server hello done 88 48 7.4.6. Client certificate 89 48 7.4.7. Client key exchange message 90 48 7.4.7.1. RSA encrypted premaster secret message 91 49 7.4.7.2. Client Diffie-Hellman public value 92 51 7.4.8. Certificate verify 93 52 7.4.9. Finished 94 52 8. Cryptographic computations 95 53 8.1. Computing the master secret 96 54 8.1.1. RSA 97 55 8.1.2. Diffie-Hellman 98 55 9. Mandatory Cipher Suites 99 55 A. Protocol constant values 100 57 A.1. Record layer 101 57 A.2. Change cipher specs message 102 58 A.3. Alert messages 103 58 A.4. Handshake protocol 104 59 A.4.1. Hello messages 105 59 A.4.2. Server authentication and key exchange messages 106 60 A.4.3. Client authentication and key exchange messages 107 61 A.4.4. Handshake finalization message 108 62 A.5. The CipherSuite 109 62 A.6. The Security Parameters 110 65 B. Glossary 111 67 C. CipherSuite definitions 112 71 D. Implementation Notes 113 73 D.1 Random Number Generation and Seeding 114 73 D.2 Certificates and authentication 115 73 D.3 CipherSuites 116 73 E. Backward Compatibility With SSL 117 74 E.1. Version 2 client hello 118 75 E.2. Avoiding man-in-the-middle version rollback 119 76 F. Security analysis 120 78 F.1. Handshake protocol 121 78 F.1.1. Authentication and key exchange 122 78 F.1.1.1. Anonymous key exchange 123 78 F.1.1.2. RSA key exchange and authentication 124 79 F.1.1.3. Diffie-Hellman key exchange with authentication 125 80 F.1.2. Version rollback attacks 126 80 F.1.3. Detecting attacks against the handshake protocol 127 81 F.1.4. Resuming sessions 128 81 F.1.5. MD5 and SHA 129 82 F.2. Protecting application data 130 82 F.3. Explicit IVs 131 82 F.4 Security of Composite Cipher Modes 132 83 F.5 Denial of Service 133 84 F.6. Final notes 134 84 136 Change history 138 22-Jun-05 ekr@rtfm.com 139 * IESG comments 140 * IANA comments 141 * Cleaned up some references 143 31-May-05 ekr@rtfm.com 144 * IETF Last Call comments (minor cleanups) 145 03-Dec-04 ekr@rtfm.com 146 * Removed export cipher suites 148 26-Oct-04 ekr@rtfm.com 149 * Numerous cleanups from Last Call comments 151 10-Aug-04 ekr@rtfm.com 152 * Added clarifying material about interleaved application data. 154 27-Jul-04 ekr@rtfm.com 155 * Premature closes no longer cause a session to be nonresumable. 156 Response to WG consensus. 158 * Added IANA considerations and registry for cipher suites 159 and ClientCertificateTypes 161 26-Jun-03 ekr@rtfm.com 162 * Incorporated Last Call comments from Franke Marcus, Jack Lloyd, 163 Brad Wetmore, and others. 165 22-Apr-03 ekr@rtfm.com 166 * coverage of the Vaudenay, Boneh-Brumley, and KPR attacks 167 * cleaned up IV text a bit. 168 * Added discussion of Denial of Service attacks. 170 11-Feb-02 ekr@rtfm.com 171 * Clarified the behavior of empty certificate lists [Nelson Bolyard] 172 * Added text explaining the security implications of authenticate 173 then encrypt. 174 * Cleaned up the explicit IV text. 175 * Added some more acknowledgement names 177 02-Nov-02 ekr@rtfm.com 178 * Changed this to be TLS 1.1. 179 * Added fixes for the Rogaway and Vaudenay CBC attacks 180 * Separated references into normative and informative 182 01-Mar-02 ekr@rtfm.com 183 * Tightened up the language in F.1.1.2 [Peter Watkins] 184 * Fixed smart quotes [Bodo Moeller] 185 * Changed handling of padding errors to prevent CBC-based attack 186 [Bodo Moeller] 187 * Fixed certificate_list spec in the appendix [Aman Sawrup] 188 * Fixed a bug in the V2 definitions [Aman Sawrup] 189 * Fixed S 7.2.1 to point out that you don't need a close notify 190 if you just sent some other fatal alert [Andreas Sterbenz] 191 * Marked alert 41 reserved [Andreas Sterbenz] 192 * Changed S 7.4.2 to point out that 512-bit keys cannot be used for 193 signing [Andreas Sterbenz] 194 * Added reserved client key types from SSLv3 [Andreas Sterbenz] 195 * Changed EXPORT40 to "40-bit EXPORT" in S 9 [Andreas Sterbenz] 196 * Removed RSA patent statement [Andreas Sterbenz] 197 * Removed references to BSAFE and RSAREF [Andreas Sterbenz] 199 14-Feb-02 ekr@rtfm.com 200 * Re-converted to I-D from RFC 201 * Made RSA/3DES the mandatory cipher suite. 202 * Added discussion of the EncryptedPMS encoding and PMS version number 203 issues to 7.4.7.1 204 * Removed the requirement in 7.4.1.3 that the Server random must be 205 different from the Client random, since these are randomly generated 206 and we don't expect servers to reject Server random values which 207 coincidentally are the same as the Client random. 208 * Replaced may/should/must with MAY/SHOULD/MUST where appropriate. 209 In many cases, shoulds became MUSTs, where I believed that was the 210 actual sense of the text. Added an RFC 2119 bulletin. 211 * Clarified the meaning of "empty certificate" message. [Peter Gutmann] 212 * Redid the CertificateRequest grammar to allow no distinguished names. 213 [Peter Gutmann] 214 * Removed the reference to requiring the master secret to generate 215 the CertificateVerify in F.1.1 [Bodo Moeller] 216 * Deprecated EXPORT40. 217 * Fixed a bunch of errors in the SSLv2 backward compatible client hello. 219 1. Introduction 221 The primary goal of the TLS Protocol is to provide privacy and data 222 integrity between two communicating applications. The protocol is 223 composed of two layers: the TLS Record Protocol and the TLS Handshake 224 Protocol. At the lowest level, layered on top of some reliable 225 transport protocol (e.g., TCP[TCP]), is the TLS Record Protocol. The 226 TLS Record Protocol provides connection security that has two basic 227 properties: 229 - The connection is private. Symmetric cryptography is used for 230 data encryption (e.g., DES [DES], RC4 [SCH], etc.). The keys for 231 this symmetric encryption are generated uniquely for each 232 connection and are based on a secret negotiated by another 233 protocol (such as the TLS Handshake Protocol). The Record 234 Protocol can also be used without encryption. 236 - The connection is reliable. Message transport includes a message 237 integrity check using a keyed MAC. Secure hash functions (e.g., 238 SHA, MD5, etc.) are used for MAC computations. The Record 239 Protocol can operate without a MAC, but is generally only used in 240 this mode while another protocol is using the Record Protocol as 241 a transport for negotiating security parameters. 243 The TLS Record Protocol is used for encapsulation of various higher 244 level protocols. One such encapsulated protocol, the TLS Handshake 245 Protocol, allows the server and client to authenticate each other and 246 to negotiate an encryption algorithm and cryptographic keys before 247 the application protocol transmits or receives its first byte of 248 data. The TLS Handshake Protocol provides connection security that 249 has three basic properties: 251 - The peer's identity can be authenticated using asymmetric, or 252 public key, cryptography (e.g., RSA [RSA], DSS [DSS], etc.). This 253 authentication can be made optional, but is generally required 254 for at least one of the peers. 256 - The negotiation of a shared secret is secure: the negotiated 257 secret is unavailable to eavesdroppers, and for any authenticated 258 connection the secret cannot be obtained, even by an attacker who 259 can place himself in the middle of the connection. 261 - The negotiation is reliable: no attacker can modify the 262 negotiation communication without being detected by the parties 263 to the communication. 265 One advantage of TLS is that it is application protocol independent. 266 Higher level protocols can layer on top of the TLS Protocol 267 transparently. The TLS standard, however, does not specify how 268 protocols add security with TLS; the decisions on how to initiate TLS 269 handshaking and how to interpret the authentication certificates 270 exchanged are left up to the judgment of the designers and 271 implementors of protocols which run on top of TLS. 273 1.1 Differences from TLS 1.0 274 This document is a revision of the TLS 1.0 [TLS1.0] protocol which 275 contains some small security improvements, clarifications, and 276 editorial improvements. The major changes are: 278 - The implicit Initialization Vector (IV) is replaced with an 279 explicit 280 IV to protect against CBC attacks [CBCATT]. 282 - Handling of padding errors is changed to use the bad_record_mac 283 alert rather than the decryption_failed alert to protect against 284 CBC attacks. 286 - IANA registries are defined for protocol parameters. 288 - Premature closes no longer cause a session to be nonresumable. 290 - Additional informational notes were added for various new attacks 291 on TLS. 293 In addition, a number of minor clarifications and editorial 294 improvements were made. 296 1.1 Requirements Terminology 298 Keywords "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT" and 299 "MAY" that appear in this document are to be interpreted as described 300 in RFC 2119 [REQ]. 302 2. Goals 304 The goals of TLS Protocol, in order of their priority, are: 306 1. Cryptographic security: TLS should be used to establish a secure 307 connection between two parties. 309 2. Interoperability: Independent programmers should be able to 310 develop applications utilizing TLS that will then be able to 311 successfully exchange cryptographic parameters without knowledge 312 of one another's code. 314 3. Extensibility: TLS seeks to provide a framework into which new 315 public key and bulk encryption methods can be incorporated as 316 necessary. This will also accomplish two sub-goals: to prevent 317 the need to create a new protocol (and risking the introduction 318 of possible new weaknesses) and to avoid the need to implement an 319 entire new security library. 321 4. Relative efficiency: Cryptographic operations tend to be highly 322 CPU intensive, particularly public key operations. For this 323 reason, the TLS protocol has incorporated an optional session 324 caching scheme to reduce the number of connections that need to 325 be established from scratch. Additionally, care has been taken to 326 reduce network activity. 328 3. Goals of this document 330 This document and the TLS protocol itself are based on the SSL 3.0 331 Protocol Specification as published by Netscape. The differences 332 between this protocol and SSL 3.0 are not dramatic, but they are 333 significant enough that TLS 1.1, TLS 1.0, and SSL 3.0 do not 334 interoperate (although each protocol incorporates a mechanism by 335 which an implementation can back down prior versions. This document 336 is intended primarily for readers who will be implementing the 337 protocol and those doing cryptographic analysis of it. The 338 specification has been written with this in mind, and it is intended 339 to reflect the needs of those two groups. For that reason, many of 340 the algorithm-dependent data structures and rules are included in the 341 body of the text (as opposed to in an appendix), providing easier 342 access to them. 344 This document is not intended to supply any details of service 345 definition nor interface definition, although it does cover select 346 areas of policy as they are required for the maintenance of solid 347 security. 349 4. Presentation language 351 This document deals with the formatting of data in an external 352 representation. The following very basic and somewhat casually 353 defined presentation syntax will be used. The syntax draws from 354 several sources in its structure. Although it resembles the 355 programming language "C" in its syntax and XDR [XDR] in both its 356 syntax and intent, it would be risky to draw too many parallels. The 357 purpose of this presentation language is to document TLS only, not to 358 have general application beyond that particular goal. 360 4.1. Basic block size 362 The representation of all data items is explicitly specified. The 363 basic data block size is one byte (i.e. 8 bits). Multiple byte data 364 items are concatenations of bytes, from left to right, from top to 365 bottom. From the bytestream a multi-byte item (a numeric in the 366 example) is formed (using C notation) by: 368 value = (byte[0] << 8*(n-1)) | (byte[1] << 8*(n-2)) | 369 ... | byte[n-1]; 371 This byte ordering for multi-byte values is the commonplace network 372 byte order or big endian format. 374 4.2. Miscellaneous 376 Comments begin with "/*" and end with "*/". 378 Optional components are denoted by enclosing them in "[[ ]]" double 379 brackets. 381 Single byte entities containing uninterpreted data are of type 382 opaque. 384 4.3. Vectors 386 A vector (single dimensioned array) is a stream of homogeneous data 387 elements. The size of the vector may be specified at documentation 388 time or left unspecified until runtime. In either case the length 389 declares the number of bytes, not the number of elements, in the 390 vector. The syntax for specifying a new type T' that is a fixed 391 length vector of type T is 393 T T'[n]; 395 Here T' occupies n bytes in the data stream, where n is a multiple of 396 the size of T. The length of the vector is not included in the 397 encoded stream. 399 In the following example, Datum is defined to be three consecutive 400 bytes that the protocol does not interpret, while Data is three 401 consecutive Datum, consuming a total of nine bytes. 403 opaque Datum[3]; /* three uninterpreted bytes */ 404 Datum Data[9]; /* 3 consecutive 3 byte vectors */ 405 Variable length vectors are defined by specifying a subrange of legal 406 lengths, inclusively, using the notation . When 407 encoded, the actual length precedes the vector's contents in the byte 408 stream. The length will be in the form of a number consuming as many 409 bytes as required to hold the vector's specified maximum (ceiling) 410 length. A variable length vector with an actual length field of zero 411 is referred to as an empty vector. 413 T T'; 415 In the following example, mandatory is a vector that must contain 416 between 300 and 400 bytes of type opaque. It can never be empty. The 417 actual length field consumes two bytes, a uint16, sufficient to 418 represent the value 400 (see Section 4.4). On the other hand, longer 419 can represent up to 800 bytes of data, or 400 uint16 elements, and it 420 may be empty. Its encoding will include a two byte actual length 421 field prepended to the vector. The length of an encoded vector must 422 be an even multiple of the length of a single element (for example, a 423 17 byte vector of uint16 would be illegal). 425 opaque mandatory<300..400>; 426 /* length field is 2 bytes, cannot be empty */ 427 uint16 longer<0..800>; 428 /* zero to 400 16-bit unsigned integers */ 430 4.4. Numbers 432 The basic numeric data type is an unsigned byte (uint8). All larger 433 numeric data types are formed from fixed length series of bytes 434 concatenated as described in Section 4.1 and are also unsigned. The 435 following numeric types are predefined. 437 uint8 uint16[2]; 438 uint8 uint24[3]; 439 uint8 uint32[4]; 440 uint8 uint64[8]; 442 All values, here and elsewhere in the specification, are stored in 443 "network" or "big-endian" order; the uint32 represented by the hex 444 bytes 01 02 03 04 is equivalent to the decimal value 16909060. 446 4.5. Enumerateds 448 An additional sparse data type is available called enum. A field of 449 type enum can only assume the values declared in the definition. 450 Each definition is a different type. Only enumerateds of the same 451 type may be assigned or compared. Every element of an enumerated must 452 be assigned a value, as demonstrated in the following example. Since 453 the elements of the enumerated are not ordered, they can be assigned 454 any unique value, in any order. 456 enum { e1(v1), e2(v2), ... , en(vn) [[, (n)]] } Te; 458 Enumerateds occupy as much space in the byte stream as would its 459 maximal defined ordinal value. The following definition would cause 460 one byte to be used to carry fields of type Color. 462 enum { red(3), blue(5), white(7) } Color; 464 One may optionally specify a value without its associated tag to 465 force the width definition without defining a superfluous element. 466 In the following example, Taste will consume two bytes in the data 467 stream but can only assume the values 1, 2 or 4. 469 enum { sweet(1), sour(2), bitter(4), (32000) } Taste; 471 The names of the elements of an enumeration are scoped within the 472 defined type. In the first example, a fully qualified reference to 473 the second element of the enumeration would be Color.blue. Such 474 qualification is not required if the target of the assignment is well 475 specified. 477 Color color = Color.blue; /* overspecified, legal */ 478 Color color = blue; /* correct, type implicit */ 480 For enumerateds that are never converted to external representation, 481 the numerical information may be omitted. 483 enum { low, medium, high } Amount; 485 4.6. Constructed types 487 Structure types may be constructed from primitive types for 488 convenience. Each specification declares a new, unique type. The 489 syntax for definition is much like that of C. 491 struct { 492 T1 f1; 493 T2 f2; 494 ... 495 Tn fn; 496 } [[T]]; 497 The fields within a structure may be qualified using the type's name 498 using a syntax much like that available for enumerateds. For example, 499 T.f2 refers to the second field of the previous declaration. 500 Structure definitions may be embedded. 502 4.6.1. Variants 504 Defined structures may have variants based on some knowledge that is 505 available within the environment. The selector must be an enumerated 506 type that defines the possible variants the structure defines. There 507 must be a case arm for every element of the enumeration declared in 508 the select. The body of the variant structure may be given a label 509 for reference. The mechanism by which the variant is selected at 510 runtime is not prescribed by the presentation language. 512 struct { 513 T1 f1; 514 T2 f2; 515 .... 516 Tn fn; 517 select (E) { 518 case e1: Te1; 519 case e2: Te2; 520 .... 521 case en: Ten; 522 } [[fv]]; 523 } [[Tv]]; 525 For example: 527 enum { apple, orange } VariantTag; 528 struct { 529 uint16 number; 530 opaque string<0..10>; /* variable length */ 531 } V1; 532 struct { 533 uint32 number; 534 opaque string[10]; /* fixed length */ 535 } V2; 536 struct { 537 select (VariantTag) { /* value of selector is implicit */ 538 case apple: V1; /* VariantBody, tag = apple */ 539 case orange: V2; /* VariantBody, tag = orange */ 540 } variant_body; /* optional label on variant */ 541 } VariantRecord; 543 Variant structures may be qualified (narrowed) by specifying a value 544 for the selector prior to the type. For example, a 545 orange VariantRecord 547 is a narrowed type of a VariantRecord containing a variant_body of 548 type V2. 550 4.7. Cryptographic attributes 552 The four cryptographic operations digital signing, stream cipher 553 encryption, block cipher encryption, and public key encryption are 554 designated digitally-signed, stream-ciphered, block-ciphered, and 555 public-key-encrypted, respectively. A field's cryptographic 556 processing is specified by prepending an appropriate key word 557 designation before the field's type specification. Cryptographic keys 558 are implied by the current session state (see Section 6.1). 560 In digital signing, one-way hash functions are used as input for a 561 signing algorithm. A digitally-signed element is encoded as an opaque 562 vector <0..2^16-1>, where the length is specified by the signing 563 algorithm and key. 565 In RSA signing, a 36-byte structure of two hashes (one SHA and one 566 MD5) is signed (encrypted with the private key). It is encoded with 567 PKCS #1 block type 0 or type 1 as described in [PKCS1A]. 569 Note: the standard reference for PKCS#1 is now RFC 3447 [PKCS1B]. 570 However, to minimize differences with TLS 1.0 text, we are using the 571 terminology of RFC 2313 [PKCS1A]. 573 In DSS, the 20 bytes of the SHA hash are run directly through the 574 Digital Signing Algorithm with no additional hashing. This produces 575 two values, r and s. The DSS signature is an opaque vector, as above, 576 the contents of which are the DER encoding of: 578 Dss-Sig-Value ::= SEQUENCE { 579 r INTEGER, 580 s INTEGER 581 } 583 In stream cipher encryption, the plaintext is exclusive-ORed with an 584 identical amount of output generated from a cryptographically-secure 585 keyed pseudorandom number generator. 587 In block cipher encryption, every block of plaintext encrypts to a 588 block of ciphertext. All block cipher encryption is done in CBC 589 (Cipher Block Chaining) mode, and all items which are block-ciphered 590 will be an exact multiple of the cipher block length. 592 In public key encryption, a public key algorithm is used to encrypt 593 data in such a way that it can be decrypted only with the matching 594 private key. A public-key-encrypted element is encoded as an opaque 595 vector <0..2^16-1>, where the length is specified by the signing 596 algorithm and key. 598 An RSA encrypted value is encoded with PKCS #1 block type 2 as 599 described in [PKCS1A]. 601 In the following example: 603 stream-ciphered struct { 604 uint8 field1; 605 uint8 field2; 606 digitally-signed opaque hash[20]; 607 } UserType; 609 The contents of hash are used as input for the signing algorithm, 610 then the entire structure is encrypted with a stream cipher. The 611 length of this structure, in bytes would be equal to 2 bytes for 612 field1 and field2, plus two bytes for the length of the signature, 613 plus the length of the output of the signing algorithm. This is known 614 due to the fact that the algorithm and key used for the signing are 615 known prior to encoding or decoding this structure. 617 4.8. Constants 619 Typed constants can be defined for purposes of specification by 620 declaring a symbol of the desired type and assigning values to it. 621 Under-specified types (opaque, variable length vectors, and 622 structures that contain opaque) cannot be assigned values. No fields 623 of a multi-element structure or vector may be elided. 625 For example, 627 struct { 628 uint8 f1; 629 uint8 f2; 630 } Example1; 632 Example1 ex1 = {1, 4}; /* assigns f1 = 1, f2 = 4 */ 634 5. HMAC and the pseudorandom function 636 A number of operations in the TLS record and handshake layer required 637 a keyed MAC; this is a secure digest of some data protected by a 638 secret. Forging the MAC is infeasible without knowledge of the MAC 639 secret. The construction we use for this operation is known as HMAC, 640 described in [HMAC]. 642 HMAC can be used with a variety of different hash algorithms. TLS 643 uses it in the handshake with two different algorithms: MD5 and 644 SHA-1, denoting these as HMAC_MD5(secret, data) and HMAC_SHA(secret, 645 data). Additional hash algorithms can be defined by cipher suites and 646 used to protect record data, but MD5 and SHA-1 are hard coded into 647 the description of the handshaking for this version of the protocol. 649 In addition, a construction is required to do expansion of secrets 650 into blocks of data for the purposes of key generation or validation. 651 This pseudo-random function (PRF) takes as input a secret, a seed, 652 and an identifying label and produces an output of arbitrary length. 654 In order to make the PRF as secure as possible, it uses two hash 655 algorithms in a way which should guarantee its security if either 656 algorithm remains secure. 658 First, we define a data expansion function, P_hash(secret, data) 659 which uses a single hash function to expand a secret and seed into an 660 arbitrary quantity of output: 662 P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) + 663 HMAC_hash(secret, A(2) + seed) + 664 HMAC_hash(secret, A(3) + seed) + ... 666 Where + indicates concatenation. 668 A() is defined as: 669 A(0) = seed 670 A(i) = HMAC_hash(secret, A(i-1)) 672 P_hash can be iterated as many times as is necessary to produce the 673 required quantity of data. For example, if P_SHA-1 was being used to 674 create 64 bytes of data, it would have to be iterated 4 times 675 (through A(4)), creating 80 bytes of output data; the last 16 bytes 676 of the final iteration would then be discarded, leaving 64 bytes of 677 output data. 679 TLS's PRF is created by splitting the secret into two halves and 680 using one half to generate data with P_MD5 and the other half to 681 generate data with P_SHA-1, then exclusive-or'ing the outputs of 682 these two expansion functions together. 684 S1 and S2 are the two halves of the secret and each is the same 685 length. S1 is taken from the first half of the secret, S2 from the 686 second half. Their length is created by rounding up the length of the 687 overall secret divided by two; thus, if the original secret is an odd 688 number of bytes long, the last byte of S1 will be the same as the 689 first byte of S2. 691 L_S = length in bytes of secret; 692 L_S1 = L_S2 = ceil(L_S / 2); 693 The secret is partitioned into two halves (with the possibility of 694 one shared byte) as described above, S1 taking the first L_S1 bytes 695 and S2 the last L_S2 bytes. 697 The PRF is then defined as the result of mixing the two pseudorandom 698 streams by exclusive-or'ing them together. 700 PRF(secret, label, seed) = P_MD5(S1, label + seed) XOR 701 P_SHA-1(S2, label + seed); 703 The label is an ASCII string. It should be included in the exact form 704 it is given without a length byte or trailing null character. For 705 example, the label "slithy toves" would be processed by hashing the 706 following bytes: 708 73 6C 69 74 68 79 20 74 6F 76 65 73 710 Note that because MD5 produces 16 byte outputs and SHA-1 produces 20 711 byte outputs, the boundaries of their internal iterations will not be 712 aligned; to generate a 80 byte output will involve P_MD5 being 713 iterated through A(5), while P_SHA-1 will only iterate through A(4). 715 6. The TLS Record Protocol 717 The TLS Record Protocol is a layered protocol. At each layer, 718 messages may include fields for length, description, and content. 719 The Record Protocol takes messages to be transmitted, fragments the 720 data into manageable blocks, optionally compresses the data, applies 721 a MAC, encrypts, and transmits the result. Received data is 722 decrypted, verified, decompressed, and reassembled, then delivered to 723 higher level clients. 725 Four record protocol clients are described in this document: the 726 handshake protocol, the alert protocol, the change cipher spec 727 protocol, and the application data protocol. In order to allow 728 extension of the TLS protocol, additional record types can be 729 supported by the record protocol. Any new record types SHOULD 730 allocate type values immediately beyond the ContentType values for 731 the four record types described here (see Appendix A.1). All such 732 values must be defined by RFC 2434 Standards Action. See section 11 733 for IANA Considerations for ContentType values. 735 If a TLS implementation receives a record type it does not 736 understand, it SHOULD just ignore it. Any protocol designed for use 737 over TLS MUST be carefully designed to deal with all possible attacks 738 against it. Note that because the type and length of a record are 739 not protected by encryption, care SHOULD be taken to minimize the 740 value of traffic analysis of these values. 742 6.1. Connection states 744 A TLS connection state is the operating environment of the TLS Record 745 Protocol. It specifies a compression algorithm, encryption algorithm, 746 and MAC algorithm. In addition, the parameters for these algorithms 747 are known: the MAC secret and the bulk encryption keys for the 748 connection in both the read and the write directions. Logically, 749 there are always four connection states outstanding: the current read 750 and write states, and the pending read and write states. All records 751 are processed under the current read and write states. The security 752 parameters for the pending states can be set by the TLS Handshake 753 Protocol, and the Change Cipher Spec can selectively make either of 754 the pending states current, in which case the appropriate current 755 state is disposed of and replaced with the pending state; the pending 756 state is then reinitialized to an empty state. It is illegal to make 757 a state which has not been initialized with security parameters a 758 current state. The initial current state always specifies that no 759 encryption, compression, or MAC will be used. 761 The security parameters for a TLS Connection read and write state are 762 set by providing the following values: 764 connection end 765 Whether this entity is considered the "client" or the "server" in 766 this connection. 768 bulk encryption algorithm 769 An algorithm to be used for bulk encryption. This specification 770 includes the key size of this algorithm, how much of that key is 771 secret, whether it is a block or stream cipher, the block size of 772 the cipher (if appropriate). 774 MAC algorithm 775 An algorithm to be used for message authentication. This 776 specification includes the size of the hash which is returned by 777 the MAC algorithm. 779 compression algorithm 780 An algorithm to be used for data compression. This specification 781 must include all information the algorithm requires to do 782 compression. 784 master secret 785 A 48 byte secret shared between the two peers in the connection. 787 client random 788 A 32 byte value provided by the client. 790 server random 791 A 32 byte value provided by the server. 793 These parameters are defined in the presentation language as: 795 enum { server, client } ConnectionEnd; 797 enum { null, rc4, rc2, des, 3des, des40, idea, aes } BulkCipherAlgorithm; 799 enum { stream, block } CipherType; 801 enum { null, md5, sha } MACAlgorithm; 803 enum { null(0), (255) } CompressionMethod; 805 /* The algorithms specified in CompressionMethod, 806 BulkCipherAlgorithm, and MACAlgorithm may be added to. */ 808 struct { 809 ConnectionEnd entity; 810 BulkCipherAlgorithm bulk_cipher_algorithm; 811 CipherType cipher_type; 812 uint8 key_size; 813 uint8 key_material_length; 814 MACAlgorithm mac_algorithm; 815 uint8 hash_size; 816 CompressionMethod compression_algorithm; 817 opaque master_secret[48]; 818 opaque client_random[32]; 819 opaque server_random[32]; 820 } SecurityParameters; 822 The record layer will use the security parameters to generate the 823 following four items: 825 client write MAC secret 826 server write MAC secret 827 client write key 828 server write key 830 The client write parameters are used by the server when receiving and 831 processing records and vice-versa. The algorithm used for generating 832 these items from the security parameters is described in section 6.3. 834 Once the security parameters have been set and the keys have been 835 generated, the connection states can be instantiated by making them 836 the current states. These current states MUST be updated for each 837 record processed. Each connection state includes the following 838 elements: 840 compression state 841 The current state of the compression algorithm. 843 cipher state 844 The current state of the encryption algorithm. This will consist 845 of the scheduled key for that connection. For stream ciphers, 846 this will also contain whatever the necessary state information 847 is to allow the stream to continue to encrypt or decrypt data. 849 MAC secret 850 The MAC secret for this connection as generated above. 852 sequence number 853 Each connection state contains a sequence number, which is 854 maintained separately for read and write states. The sequence 855 number MUST be set to zero whenever a connection state is made 856 the active state. Sequence numbers are of type uint64 and may not 857 exceed 2^64-1. Sequence numbers do not wrap. If a TLS 858 implementation would need to wrap a sequence number it must 859 renegotiate instead. A sequence number is incremented after each 860 record: specifically, the first record which is transmitted under 861 a particular connection state MUST use sequence number 0. 863 6.2. Record layer 865 The TLS Record Layer receives uninterpreted data from higher layers 866 in non-empty blocks of arbitrary size. 868 6.2.1. Fragmentation 870 The record layer fragments information blocks into TLSPlaintext 871 records carrying data in chunks of 2^14 bytes or less. Client message 872 boundaries are not preserved in the record layer (i.e., multiple 873 client messages of the same ContentType MAY be coalesced into a 874 single TLSPlaintext record, or a single message MAY be fragmented 875 across several records). 877 struct { 878 uint8 major, minor; 879 } ProtocolVersion; 881 enum { 882 change_cipher_spec(20), alert(21), handshake(22), 883 application_data(23), (255) 884 } ContentType; 885 struct { 886 ContentType type; 887 ProtocolVersion version; 888 uint16 length; 889 opaque fragment[TLSPlaintext.length]; 890 } TLSPlaintext; 892 type 893 The higher level protocol used to process the enclosed fragment. 895 version 896 The version of the protocol being employed. This document 897 describes TLS Version 1.1, which uses the version { 3, 2 }. The 898 version value 3.2 is historical: TLS version 1.1 is a minor 899 modification to the TLS 1.0 protocol, which was itself a minor 900 modification to the SSL 3.0 protocol, which bears the version 901 value 3.0. (See Appendix A.1). 903 length 904 The length (in bytes) of the following TLSPlaintext.fragment. 905 The length should not exceed 2^14. 907 fragment 908 The application data. This data is transparent and treated as an 909 independent block to be dealt with by the higher level protocol 910 specified by the type field. 912 Note: Data of different TLS Record layer content types MAY be 913 interleaved. Application data is generally of higher precedence 914 for transmission than other content types and therefore handshake 915 records may be held if application data is pending. However, 916 records MUST be delivered to the network in the same order as 917 they are protected by the record layer. Recipients MUST receive 918 and process interleaved application layer traffic during 919 handshakes subsequent to the first one on a connection. 921 6.2.2. Record compression and decompression 923 All records are compressed using the compression algorithm defined in 924 the current session state. There is always an active compression 925 algorithm; however, initially it is defined as 926 CompressionMethod.null. The compression algorithm translates a 927 TLSPlaintext structure into a TLSCompressed structure. Compression 928 functions are initialized with default state information whenever a 929 connection state is made active. 931 Compression must be lossless and may not increase the content length 932 by more than 1024 bytes. If the decompression function encounters a 933 TLSCompressed.fragment that would decompress to a length in excess of 934 2^14 bytes, it should report a fatal decompression failure error. 936 struct { 937 ContentType type; /* same as TLSPlaintext.type */ 938 ProtocolVersion version;/* same as TLSPlaintext.version */ 939 uint16 length; 940 opaque fragment[TLSCompressed.length]; 941 } TLSCompressed; 943 length 944 The length (in bytes) of the following TLSCompressed.fragment. 945 The length should not exceed 2^14 + 1024. 947 fragment 948 The compressed form of TLSPlaintext.fragment. 950 Note: A CompressionMethod.null operation is an identity operation; no 951 fields are altered. 953 Implementation note: 954 Decompression functions are responsible for ensuring that 955 messages cannot cause internal buffer overflows. 957 6.2.3. Record payload protection 959 The encryption and MAC functions translate a TLSCompressed structure 960 into a TLSCiphertext. The decryption functions reverse the process. 961 The MAC of the record also includes a sequence number so that 962 missing, extra or repeated messages are detectable. 964 struct { 965 ContentType type; 966 ProtocolVersion version; 967 uint16 length; 968 select (CipherSpec.cipher_type) { 969 case stream: GenericStreamCipher; 970 case block: GenericBlockCipher; 971 } fragment; 972 } TLSCiphertext; 974 type 975 The type field is identical to TLSCompressed.type. 977 version 978 The version field is identical to TLSCompressed.version. 980 length 981 The length (in bytes) of the following TLSCiphertext.fragment. 982 The length may not exceed 2^14 + 2048. 984 fragment 985 The encrypted form of TLSCompressed.fragment, with the MAC. 987 6.2.3.1. Null or standard stream cipher 989 Stream ciphers (including BulkCipherAlgorithm.null - see Appendix 990 A.6) convert TLSCompressed.fragment structures to and from stream 991 TLSCiphertext.fragment structures. 993 stream-ciphered struct { 994 opaque content[TLSCompressed.length]; 995 opaque MAC[CipherSpec.hash_size]; 996 } GenericStreamCipher; 998 The MAC is generated as: 1000 HMAC_hash(MAC_write_secret, seq_num + TLSCompressed.type + 1001 TLSCompressed.version + TLSCompressed.length + 1002 TLSCompressed.fragment)); 1004 where "+" denotes concatenation. 1006 seq_num 1007 The sequence number for this record. 1009 hash 1010 The hashing algorithm specified by 1011 SecurityParameters.mac_algorithm. 1013 Note that the MAC is computed before encryption. The stream cipher 1014 encrypts the entire block, including the MAC. For stream ciphers that 1015 do not use a synchronization vector (such as RC4), the stream cipher 1016 state from the end of one record is simply used on the subsequent 1017 packet. If the CipherSuite is TLS_NULL_WITH_NULL_NULL, encryption 1018 consists of the identity operation (i.e., the data is not encrypted 1019 and the MAC size is zero implying that no MAC is used). 1020 TLSCiphertext.length is TLSCompressed.length plus 1021 CipherSpec.hash_size. 1023 6.2.3.2. CBC block cipher 1025 For block ciphers (such as RC2, DES, or AES), the encryption and MAC 1026 functions convert TLSCompressed.fragment structures to and from block 1027 TLSCiphertext.fragment structures. 1029 block-ciphered struct { 1030 opaque IV[CipherSpec.block_length]; 1031 opaque content[TLSCompressed.length]; 1032 opaque MAC[CipherSpec.hash_size]; 1033 uint8 padding[GenericBlockCipher.padding_length]; 1034 uint8 padding_length; 1035 } GenericBlockCipher; 1037 The MAC is generated as described in Section 6.2.3.1. 1039 IV 1040 Unlike previous versions of SSL and TLS, TLS 1.1 uses an explicit 1041 IV in order to prevent the attacks described by [CBCATT]. 1042 We recommend the following equivalently strong procedures. 1043 For clarity we use the following notation. 1045 IV -- the transmitted value of the IV field in the 1046 GenericBlockCipher structure. 1047 CBC residue -- the last ciphertext block of the previous record 1048 mask -- the actual value which the cipher XORs with the 1049 plaintext prior to encryption of the first cipher block 1050 of the record. 1052 In prior versions of TLS, there was no IV field and the CBC residue 1053 and mask were one and the same. See Sections 6.1, 6.2.3.2 and 6.3, 1054 of [TLS1.0] for details of TLS 1.0 IV handling. 1056 One of the following two algorithms SHOULD be used to generate the 1057 per-record IV: 1059 (1) Generate a cryptographically strong random string R of 1060 length CipherSpec.block_length. Place R 1061 in the IV field. Set the mask to R. Thus, the first 1062 cipher block will be encrypted as E(R XOR Data). 1064 (2) Generate a cryptographically strong random number R of 1065 length CipherSpec.block_length and prepend it to the plaintext 1066 prior to encryption. In 1067 this case either: 1069 (a) The cipher may use a fixed mask such as zero. 1070 (b) The CBC residue from the previous record may be used 1071 as the mask. This preserves maximum code compatibility 1072 with TLS 1.0 and SSL 3. It also has the advantage that 1073 it does not require the ability to quickly reset the IV, 1074 which is known to be a problem on some systems. 1076 In either 2(a) or 2(b) the data (R || data) is fed into the 1077 encryption process. The first cipher block (containing 1078 E(mask XOR R) is placed in the IV field. The first 1079 block of content contains E(IV XOR data) 1081 The following alternative procedure MAY be used: However, it has 1082 not been demonstrated to be equivalently cryptographically strong 1083 to the above procedures. The sender prepends a fixed block F to 1084 the plaintext (or alternatively a block generated with a weak 1085 PRNG). He then encrypts as in (2) above, using the CBC residue 1086 from the previous block as the mask for the prepended block. Note 1087 that in this case the mask for the first record transmitted by 1088 the application (the Finished) MUST be generated using a 1089 cryptographically strong PRNG. 1091 The decryption operation for all three alternatives is the same. 1092 The receiver decrypts the entire GenericBlockCipher structure and 1093 then discards the first cipher block, corresponding to the IV 1094 component. 1096 padding 1097 Padding that is added to force the length of the plaintext to be 1098 an integral multiple of the block cipher's block length. The 1099 padding MAY be any length up to 255 bytes long, as long as it 1100 results in the TLSCiphertext.length being an integral multiple of 1101 the block length. Lengths longer than necessary might be 1102 desirable to frustrate attacks on a protocol based on analysis of 1103 the lengths of exchanged messages. Each uint8 in the padding data 1104 vector MUST be filled with the padding length value. The receiver 1105 MUST check this padding and SHOULD use the bad_record_mac alert 1106 to indicate padding errors. 1108 padding_length 1109 The padding length MUST be such that the total size of the 1110 GenericBlockCipher structure is a multiple of the cipher's block 1111 length. Legal values range from zero to 255, inclusive. This 1112 length specifies the length of the padding field exclusive of the 1113 padding_length field itself. 1115 The encrypted data length (TLSCiphertext.length) is one more than the 1116 sum of TLSCompressed.length, CipherSpec.hash_size, and 1117 padding_length. 1119 Example: If the block length is 8 bytes, the content length 1120 (TLSCompressed.length) is 61 bytes, and the MAC length is 20 1121 bytes, the length before padding is 82 bytes (this does not 1122 include the IV, which may or may not be encrypted, as 1123 discussed above). Thus, the padding length modulo 8 must be 1124 equal to 6 in order to make the total length an even multiple 1125 of 8 bytes (the block length). The padding length can be 6, 1126 14, 22, and so on, through 254. If the padding length were the 1127 minimum necessary, 6, the padding would be 6 bytes, each 1128 containing the value 6. Thus, the last 8 octets of the 1129 GenericBlockCipher before block encryption would be xx 06 06 1130 06 06 06 06 06, where xx is the last octet of the MAC. 1132 Note: With block ciphers in CBC mode (Cipher Block Chaining), 1133 it is critical that the entire plaintext of the record be known 1134 before any ciphertext is transmitted. Otherwise it is possible 1135 for the attacker to mount the attack described in [CBCATT]. 1137 Implementation Note: Canvel et. al. [CBCTIME] have demonstrated a 1138 timing attack on CBC padding based on the time required to 1139 compute the MAC. In order to defend against this attack, 1140 implementations MUST ensure that record processing time is 1141 essentially the same whether or not the padding is correct. In 1142 general, the best way to to do this is to compute the MAC even if 1143 the padding is incorrect, and only then reject the packet. For 1144 instance, if the pad appears to be incorrect the implementation 1145 might assume a zero-length pad and then compute the MAC. This 1146 leaves a small timing channel, since MAC performance depends to 1147 some extent on the size of the data fragment, but it is not 1148 believed to be large enough to be exploitable due to the large 1149 block size of existing MACs and the small size of the timing 1150 signal. 1152 6.3. Key calculation 1154 The Record Protocol requires an algorithm to generate keys, and MAC 1155 secrets from the security parameters provided by the handshake 1156 protocol. 1158 The master secret is hashed into a sequence of secure bytes, which 1159 are assigned to the MAC secrets and keys required by the current 1160 connection state (see Appendix A.6). CipherSpecs require a client 1161 write MAC secret, a server write MAC secret, a client write key, and 1162 a server write key, which are generated from the master secret in 1163 that order. Unused values are empty. 1165 When generating keys and MAC secrets, the master secret is used as an 1166 entropy source. 1168 To generate the key material, compute 1170 key_block = PRF(SecurityParameters.master_secret, 1171 "key expansion", 1172 SecurityParameters.server_random + 1173 SecurityParameters.client_random); 1175 until enough output has been generated. Then the key_block is 1176 partitioned as follows: 1178 client_write_MAC_secret[SecurityParameters.hash_size] 1179 server_write_MAC_secret[SecurityParameters.hash_size] 1180 client_write_key[SecurityParameters.key_material_length] 1181 server_write_key[SecurityParameters.key_material_length] 1183 Implementation note: 1184 The currently defined which requires the most material is 1185 AES_256_CBC_SHA, defined in [TLSAES]. It requires 2 x 32 byte 1186 keys and 2 x 20 byte MAC secrets, for a total 104 bytes of key 1187 material. 1189 7. The TLS Handshaking Protocols 1191 TLS has three subprotocols which are used to allow peers to agree 1192 upon security parameters for the record layer, authenticate 1193 themselves, instantiate negotiated security parameters, and 1194 report error conditions to each other. 1196 The Handshake Protocol is responsible for negotiating a session, 1197 which consists of the following items: 1199 session identifier 1200 An arbitrary byte sequence chosen by the server to identify an 1201 active or resumable session state. 1203 peer certificate 1204 X509v3 [X509] certificate of the peer. This element of the 1205 state may be null. 1207 compression method 1208 The algorithm used to compress data prior to encryption. 1210 cipher spec 1211 Specifies the bulk data encryption algorithm (such as null, 1212 DES, etc.) and a MAC algorithm (such as MD5 or SHA). It also 1213 defines cryptographic attributes such as the hash_size. (See 1214 Appendix A.6 for formal definition) 1216 master secret 1217 48-byte secret shared between the client and server. 1219 is resumable 1220 A flag indicating whether the session can be used to initiate 1221 new connections. 1223 These items are then used to create security parameters for use by 1224 the Record Layer when protecting application data. Many connections 1225 can be instantiated using the same session through the resumption 1226 feature of the TLS Handshake Protocol. 1228 7.1. Change cipher spec protocol 1230 The change cipher spec protocol exists to signal transitions in 1231 ciphering strategies. The protocol consists of a single message, 1232 which is encrypted and compressed under the current (not the pending) 1233 connection state. The message consists of a single byte of value 1. 1235 struct { 1236 enum { change_cipher_spec(1), (255) } type; 1237 } ChangeCipherSpec; 1239 The change cipher spec message is sent by both the client and server 1240 to notify the receiving party that subsequent records will be 1241 protected under the newly negotiated CipherSpec and keys. Reception 1242 of this message causes the receiver to instruct the Record Layer to 1243 immediately copy the read pending state into the read current state. 1244 Immediately after sending this message, the sender MUST instruct the 1245 record layer to make the write pending state the write active state. 1246 (See section 6.1.) The change cipher spec message is sent during the 1247 handshake after the security parameters have been agreed upon, but 1248 before the verifying finished message is sent (see section 7.4.9). 1250 Note: if a rehandshake occurs while data is flowing on a connection, 1251 the communicating parties may continue to send data using the old 1252 CipherSpec. However, once the ChangeCipherSpec has been sent, the new 1253 CipherSpec MUST be used. The first side to send the ChangeCipherSpec 1254 does not know that the other side has finished computing the new 1255 keying material (e.g. if it has to perform a time consuming public 1256 key operation). Thus, a small window of time during which the 1257 recipient must buffer the data MAY exist. In practice, with modern 1258 machines this interval is likely to be fairly short. 1260 7.2. Alert protocol 1262 One of the content types supported by the TLS Record layer is the 1263 alert type. Alert messages convey the severity of the message and a 1264 description of the alert. Alert messages with a level of fatal result 1265 in the immediate termination of the connection. In this case, other 1266 connections corresponding to the session may continue, but the 1267 session identifier MUST be invalidated, preventing the failed session 1268 from being used to establish new connections. Like other messages, 1269 alert messages are encrypted and compressed, as specified by the 1270 current connection state. 1272 enum { warning(1), fatal(2), (255) } AlertLevel; 1274 enum { 1275 close_notify(0), 1276 unexpected_message(10), 1277 bad_record_mac(20), 1278 decryption_failed(21), 1279 record_overflow(22), 1280 decompression_failure(30), 1281 handshake_failure(40), 1282 no_certificate_RESERVED (41), 1283 bad_certificate(42), 1284 unsupported_certificate(43), 1285 certificate_revoked(44), 1286 certificate_expired(45), 1287 certificate_unknown(46), 1288 illegal_parameter(47), 1289 unknown_ca(48), 1290 access_denied(49), 1291 decode_error(50), 1292 decrypt_error(51), 1293 export_restriction_RESERVED(60), 1294 protocol_version(70), 1295 insufficient_security(71), 1296 internal_error(80), 1297 user_canceled(90), 1298 no_renegotiation(100), 1299 (255) 1300 } AlertDescription; 1302 struct { 1303 AlertLevel level; 1304 AlertDescription description; 1305 } Alert; 1307 7.2.1. Closure alerts 1309 The client and the server must share knowledge that the connection is 1310 ending in order to avoid a truncation attack. Either party may 1311 initiate the exchange of closing messages. 1313 close_notify 1314 This message notifies the recipient that the sender will not send 1315 any more messages on this connection. Note that as of TLS 1.1, 1316 failure to properly close a connection no longer requires that a 1317 session not be resumed. This is a change from TLS 1.0 to conform 1318 with widespread implementation practice. 1320 Either party may initiate a close by sending a close_notify alert. 1321 Any data received after a closure alert is ignored. 1323 Unless some other fatal alert has been transmitted, each party is 1324 required to send a close_notify alert before closing the write side 1325 of the connection. The other party MUST respond with a close_notify 1326 alert of its own and close down the connection immediately, 1327 discarding any pending writes. It is not required for the initiator 1328 of the close to wait for the responding close_notify alert before 1329 closing the read side of the connection. 1331 If the application protocol using TLS provides that any data may be 1332 carried over the underlying transport after the TLS connection is 1333 closed, the TLS implementation must receive the responding 1334 close_notify alert before indicating to the application layer that 1335 the TLS connection has ended. If the application protocol will not 1336 transfer any additional data, but will only close the underlying 1337 transport connection, then the implementation MAY choose to close the 1338 transport without waiting for the responding close_notify. No part of 1339 this standard should be taken to dictate the manner in which a usage 1340 profile for TLS manages its data transport, including when 1341 connections are opened or closed. 1343 Note: It is assumed that closing a connection reliably delivers 1344 pending data before destroying the transport. 1346 7.2.2. Error alerts 1348 Error handling in the TLS Handshake protocol is very simple. When an 1349 error is detected, the detecting party sends a message to the other 1350 party. Upon transmission or receipt of an fatal alert message, both 1351 parties immediately close the connection. Servers and clients MUST 1352 forget any session-identifiers, keys, and secrets associated with a 1353 failed connection. Thus, any connection terminated with a fatal alert 1354 MUST NOT be resumed. The following error alerts are defined: 1356 unexpected_message 1357 An inappropriate message was received. This alert is always fatal 1358 and should never be observed in communication between proper 1359 implementations. 1361 bad_record_mac 1362 This alert is returned if a record is received with an incorrect 1363 MAC. This alert also MUST be returned if an alert is sent because 1364 a TLSCiphertext decrypted in an invalid way: either it wasn't an 1365 even multiple of the block length, or its padding values, when 1366 checked, weren't correct. This message is always fatal. 1368 decryption_failed 1369 This alert MAY be returned if a TLSCiphertext decrypted in an 1370 invalid way: either it wasn't an even multiple of the block 1371 length, or its padding values, when checked, weren't correct. 1372 This message is always fatal. 1374 Note: Differentiating between bad_record_mac and 1375 decryption_failed alerts may permit certain attacks against CBC 1376 mode as used in TLS [CBCATT]. It is preferable to uniformly use 1377 the bad_record_mac alert to hide the specific type of the error. 1379 record_overflow 1380 A TLSCiphertext record was received which had a length more than 1381 2^14+2048 bytes, or a record decrypted to a TLSCompressed record 1382 with more than 2^14+1024 bytes. This message is always fatal. 1384 decompression_failure 1385 The decompression function received improper input (e.g. data 1386 that would expand to excessive length). This message is always 1387 fatal. 1389 handshake_failure 1390 Reception of a handshake_failure alert message indicates that the 1391 sender was unable to negotiate an acceptable set of security 1392 parameters given the options available. This is a fatal error. 1394 no_certificate_RESERVED 1395 This alert was used in SSLv3 but not in TLS. It should not be 1396 sent by compliant implementations. 1398 bad_certificate 1399 A certificate was corrupt, contained signatures that did not 1400 verify correctly, etc. 1402 unsupported_certificate 1403 A certificate was of an unsupported type. 1405 certificate_revoked 1406 A certificate was revoked by its signer. 1408 certificate_expired 1409 A certificate has expired or is not currently valid. 1411 certificate_unknown 1412 Some other (unspecified) issue arose in processing the 1413 certificate, rendering it unacceptable. 1415 illegal_parameter 1416 A field in the handshake was out of range or inconsistent with 1417 other fields. This is always fatal. 1419 unknown_ca 1420 A valid certificate chain or partial chain was received, but the 1421 certificate was not accepted because the CA certificate could not 1422 be located or couldn't be matched with a known, trusted CA. This 1423 message is always fatal. 1425 access_denied 1426 A valid certificate was received, but when access control was 1427 applied, the sender decided not to proceed with negotiation. 1428 This message is always fatal. 1430 decode_error 1431 A message could not be decoded because some field was out of the 1432 specified range or the length of the message was incorrect. This 1433 message is always fatal. 1435 decrypt_error 1436 A handshake cryptographic operation failed, including being 1437 unable to correctly verify a signature, decrypt a key exchange, 1438 or validate a finished message. 1440 export_restriction_RESERVED 1441 This alert was used in TLS 1.0 but not TLS 1.1. 1443 protocol_version 1444 The protocol version the client has attempted to negotiate is 1445 recognized, but not supported. (For example, old protocol 1446 versions might be avoided for security reasons). This message is 1447 always fatal. 1449 insufficient_security 1450 Returned instead of handshake_failure when a negotiation has 1451 failed specifically because the server requires ciphers more 1452 secure than those supported by the client. This message is always 1453 fatal. 1455 internal_error 1456 An internal error unrelated to the peer or the correctness of the 1457 protocol makes it impossible to continue (such as a memory 1458 allocation failure). This message is always fatal. 1460 user_canceled 1461 This handshake is being canceled for some reason unrelated to a 1462 protocol failure. If the user cancels an operation after the 1463 handshake is complete, just closing the connection by sending a 1464 close_notify is more appropriate. This alert should be followed 1465 by a close_notify. This message is generally a warning. 1467 no_renegotiation 1468 Sent by the client in response to a hello request or by the 1469 server in response to a client hello after initial handshaking. 1470 Either of these would normally lead to renegotiation; when that 1471 is not appropriate, the recipient should respond with this alert; 1472 at that point, the original requester can decide whether to 1473 proceed with the connection. One case where this would be 1474 appropriate would be where a server has spawned a process to 1475 satisfy a request; the process might receive security parameters 1476 (key length, authentication, etc.) at startup and it might be 1477 difficult to communicate changes to these parameters after that 1478 point. This message is always a warning. 1480 For all errors where an alert level is not explicitly specified, the 1481 sending party MAY determine at its discretion whether this is a fatal 1482 error or not; if an alert with a level of warning is received, the 1483 receiving party MAY decide at its discretion whether to treat this as 1484 a fatal error or not. However, all messages which are transmitted 1485 with a level of fatal MUST be treated as fatal messages. 1487 New alerts values MUST be defined by RFC 2434 Standards Action. See 1488 Section 11 for IANA Considerations for alert values. 1490 7.3. Handshake Protocol overview 1492 The cryptographic parameters of the session state are produced by the 1493 TLS Handshake Protocol, which operates on top of the TLS Record 1494 Layer. When a TLS client and server first start communicating, they 1495 agree on a protocol version, select cryptographic algorithms, 1496 optionally authenticate each other, and use public-key encryption 1497 techniques to generate shared secrets. 1499 The TLS Handshake Protocol involves the following steps: 1501 - Exchange hello messages to agree on algorithms, exchange random 1502 values, and check for session resumption. 1504 - Exchange the necessary cryptographic parameters to allow the 1505 client and server to agree on a premaster secret. 1507 - Exchange certificates and cryptographic information to allow the 1508 client and server to authenticate themselves. 1510 - Generate a master secret from the premaster secret and exchanged 1511 random values. 1513 - Provide security parameters to the record layer. 1515 - Allow the client and server to verify that their peer has 1516 calculated the same security parameters and that the handshake 1517 occurred without tampering by an attacker. 1519 Note that higher layers should not be overly reliant on TLS always 1520 negotiating the strongest possible connection between two peers: 1521 there are a number of ways a man in the middle attacker can attempt 1522 to make two entities drop down to the least secure method they 1523 support. The protocol has been designed to minimize this risk, but 1524 there are still attacks available: for example, an attacker could 1525 block access to the port a secure service runs on, or attempt to get 1526 the peers to negotiate an unauthenticated connection. The fundamental 1527 rule is that higher levels must be cognizant of what their security 1528 requirements are and never transmit information over a channel less 1529 secure than what they require. The TLS protocol is secure, in that 1530 any cipher suite offers its promised level of security: if you 1531 negotiate 3DES with a 1024 bit RSA key exchange with a host whose 1532 certificate you have verified, you can expect to be that secure. 1534 However, you SHOULD never send data over a link encrypted with 40 bit 1535 security unless you feel that data is worth no more than the effort 1536 required to break that encryption. 1538 These goals are achieved by the handshake protocol, which can be 1539 summarized as follows: The client sends a client hello message to 1540 which the server must respond with a server hello message, or else a 1541 fatal error will occur and the connection will fail. The client hello 1542 and server hello are used to establish security enhancement 1543 capabilities between client and server. The client hello and server 1544 hello establish the following attributes: Protocol Version, Session 1545 ID, Cipher Suite, and Compression Method. Additionally, two random 1546 values are generated and exchanged: ClientHello.random and 1547 ServerHello.random. 1549 The actual key exchange uses up to four messages: the server 1550 certificate, the server key exchange, the client certificate, and the 1551 client key exchange. New key exchange methods can be created by 1552 specifying a format for these messages and defining the use of the 1553 messages to allow the client and server to agree upon a shared 1554 secret. This secret MUST be quite long; currently defined key 1555 exchange methods exchange secrets which range from 48 to 128 bytes in 1556 length. 1558 Following the hello messages, the server will send its certificate, 1559 if it is to be authenticated. Additionally, a server key exchange 1560 message may be sent, if it is required (e.g. if their server has no 1561 certificate, or if its certificate is for signing only). If the 1562 server is authenticated, it may request a certificate from the 1563 client, if that is appropriate to the cipher suite selected. Now the 1564 server will send the server hello done message, indicating that the 1565 hello-message phase of the handshake is complete. The server will 1566 then wait for a client response. If the server has sent a certificate 1567 request message, the client must send the certificate message. The 1568 client key exchange message is now sent, and the content of that 1569 message will depend on the public key algorithm selected between the 1570 client hello and the server hello. If the client has sent a 1571 certificate with signing ability, a digitally-signed certificate 1572 verify message is sent to explicitly verify the certificate. 1574 At this point, a change cipher spec message is sent by the client, 1575 and the client copies the pending Cipher Spec into the current Cipher 1576 Spec. The client then immediately sends the finished message under 1577 the new algorithms, keys, and secrets. In response, the server will 1578 send its own change cipher spec message, transfer the pending to the 1579 current Cipher Spec, and send its finished message under the new 1580 Cipher Spec. At this point, the handshake is complete and the client 1581 and server may begin to exchange application layer data. (See flow 1582 chart below.) Application data MUST NOT be sent prior to the 1583 completion of the first handshake (before a cipher suite other 1584 TLS_NULL_WITH_NULL_NULL is established). 1585 Client Server 1587 ClientHello --------> 1588 ServerHello 1589 Certificate* 1590 ServerKeyExchange* 1591 CertificateRequest* 1592 <-------- ServerHelloDone 1593 Certificate* 1594 ClientKeyExchange 1595 CertificateVerify* 1596 [ChangeCipherSpec] 1597 Finished --------> 1598 [ChangeCipherSpec] 1599 <-------- Finished 1600 Application Data <-------> Application Data 1602 Fig. 1 - Message flow for a full handshake 1604 * Indicates optional or situation-dependent messages that are not 1605 always sent. 1607 Note: To help avoid pipeline stalls, ChangeCipherSpec is an 1608 independent TLS Protocol content type, and is not actually a TLS 1609 handshake message. 1611 When the client and server decide to resume a previous session or 1612 duplicate an existing session (instead of negotiating new security 1613 parameters) the message flow is as follows: 1615 The client sends a ClientHello using the Session ID of the session to 1616 be resumed. The server then checks its session cache for a match. If 1617 a match is found, and the server is willing to re-establish the 1618 connection under the specified session state, it will send a 1619 ServerHello with the same Session ID value. At this point, both 1620 client and server MUST send change cipher spec messages and proceed 1621 directly to finished messages. Once the re-establishment is complete, 1622 the client and server MAY begin to exchange application layer data. 1623 (See flow chart below.) If a Session ID match is not found, the 1624 server generates a new session ID and the TLS client and server 1625 perform a full handshake. 1627 Client Server 1629 ClientHello --------> 1630 ServerHello 1631 [ChangeCipherSpec] 1632 <-------- Finished 1633 [ChangeCipherSpec] 1634 Finished --------> 1635 Application Data <-------> Application Data 1637 Fig. 2 - Message flow for an abbreviated handshake 1639 The contents and significance of each message will be presented in 1640 detail in the following sections. 1642 7.4. Handshake protocol 1644 The TLS Handshake Protocol is one of the defined higher level clients 1645 of the TLS Record Protocol. This protocol is used to negotiate the 1646 secure attributes of a session. Handshake messages are supplied to 1647 the TLS Record Layer, where they are encapsulated within one or more 1648 TLSPlaintext structures, which are processed and transmitted as 1649 specified by the current active session state. 1651 enum { 1652 hello_request(0), client_hello(1), server_hello(2), 1653 certificate(11), server_key_exchange (12), 1654 certificate_request(13), server_hello_done(14), 1655 certificate_verify(15), client_key_exchange(16), 1656 finished(20), (255) 1657 } HandshakeType; 1659 struct { 1660 HandshakeType msg_type; /* handshake type */ 1661 uint24 length; /* bytes in message */ 1662 select (HandshakeType) { 1663 case hello_request: HelloRequest; 1664 case client_hello: ClientHello; 1665 case server_hello: ServerHello; 1666 case certificate: Certificate; 1667 case server_key_exchange: ServerKeyExchange; 1668 case certificate_request: CertificateRequest; 1669 case server_hello_done: ServerHelloDone; 1670 case certificate_verify: CertificateVerify; 1671 case client_key_exchange: ClientKeyExchange; 1672 case finished: Finished; 1673 } body; 1674 } Handshake; 1675 The handshake protocol messages are presented below in the order they 1676 MUST be sent; sending handshake messages in an unexpected order 1677 results in a fatal error. Unneeded handshake messages can be omitted, 1678 however. Note one exception to the ordering: the Certificate message 1679 is used twice in the handshake (from server to client, then from 1680 client to server), but described only in its first position. The one 1681 message which is not bound by these ordering rules is the Hello 1682 Request message, which can be sent at any time, but which should be 1683 ignored by the client if it arrives in the middle of a handshake. 1685 New Handshake message type values MUST be defined via RFC 2434 1686 Standards Action. See Section 11 for IANA Considerations for these 1687 values. 1689 7.4.1. Hello messages 1691 The hello phase messages are used to exchange security enhancement 1692 capabilities between the client and server. When a new session 1693 begins, the Record Layer's connection state encryption, hash, and 1694 compression algorithms are initialized to null. The current 1695 connection state is used for renegotiation messages. 1697 7.4.1.1. Hello request 1699 When this message will be sent: 1700 The hello request message MAY be sent by the server at any time. 1702 Meaning of this message: 1703 Hello request is a simple notification that the client should 1704 begin the negotiation process anew by sending a client hello 1705 message when convenient. This message will be ignored by the 1706 client if the client is currently negotiating a session. This 1707 message may be ignored by the client if it does not wish to 1708 renegotiate a session, or the client may, if it wishes, respond 1709 with a no_renegotiation alert. Since handshake messages are 1710 intended to have transmission precedence over application data, 1711 it is expected that the negotiation will begin before no more 1712 than a few records are received from the client. If the server 1713 sends a hello request but does not receive a client hello in 1714 response, it may close the connection with a fatal alert. 1716 After sending a hello request, servers SHOULD not repeat the request 1717 until the subsequent handshake negotiation is complete. 1719 Structure of this message: 1720 struct { } HelloRequest; 1721 Note: This message MUST NOT be included in the message hashes which are 1722 maintained throughout the handshake and used in the finished 1723 messages and the certificate verify message. 1725 7.4.1.2. Client hello 1727 When this message will be sent: 1728 When a client first connects to a server it is required to send 1729 the client hello as its first message. The client can also send a 1730 client hello in response to a hello request or on its own 1731 initiative in order to renegotiate the security parameters in an 1732 existing connection. 1734 Structure of this message: 1735 The client hello message includes a random structure, which is 1736 used later in the protocol. 1738 struct { 1739 uint32 gmt_unix_time; 1740 opaque random_bytes[28]; 1741 } Random; 1743 gmt_unix_time 1744 The current time and date in standard UNIX 32-bit format (seconds 1745 since the midnight starting Jan 1, 1970, GMT, ignoring leap 1746 seconds) according to the sender's internal clock. Clocks are not 1747 required to be set correctly by the basic TLS Protocol; higher 1748 level or application protocols may define additional 1749 requirements. 1751 random_bytes 1752 28 bytes generated by a secure random number generator. 1754 The client hello message includes a variable length session 1755 identifier. If not empty, the value identifies a session between the 1756 same client and server whose security parameters the client wishes to 1757 reuse. The session identifier MAY be from an earlier connection, this 1758 connection, or another currently active connection. The second option 1759 is useful if the client only wishes to update the random structures 1760 and derived values of a connection, while the third option makes it 1761 possible to establish several independent secure connections without 1762 repeating the full handshake protocol. These independent connections 1763 may occur sequentially or simultaneously; a SessionID becomes valid 1764 when the handshake negotiating it completes with the exchange of 1765 Finished messages and persists until removed due to aging or because 1766 a fatal error was encountered on a connection associated with the 1767 session. The actual contents of the SessionID are defined by the 1768 server. 1770 opaque SessionID<0..32>; 1772 Warning: 1773 Because the SessionID is transmitted without encryption or 1774 immediate MAC protection, servers MUST not place confidential 1775 information in session identifiers or let the contents of fake 1776 session identifiers cause any breach of security. (Note that the 1777 content of the handshake as a whole, including the SessionID, is 1778 protected by the Finished messages exchanged at the end of the 1779 handshake.) 1781 The CipherSuite list, passed from the client to the server in the 1782 client hello message, contains the combinations of cryptographic 1783 algorithms supported by the client in order of the client's 1784 preference (favorite choice first). Each CipherSuite defines a key 1785 exchange algorithm, a bulk encryption algorithm (including secret key 1786 length) and a MAC algorithm. The server will select a cipher suite 1787 or, if no acceptable choices are presented, return a handshake 1788 failure alert and close the connection. 1790 uint8 CipherSuite[2]; /* Cryptographic suite selector */ 1792 The client hello includes a list of compression algorithms supported 1793 by the client, ordered according to the client's preference. 1795 enum { null(0), (255) } CompressionMethod; 1797 struct { 1798 ProtocolVersion client_version; 1799 Random random; 1800 SessionID session_id; 1801 CipherSuite cipher_suites<2..2^16-1>; 1802 CompressionMethod compression_methods<1..2^8-1>; 1803 } ClientHello; 1805 client_version 1806 The version of the TLS protocol by which the client wishes to 1807 communicate during this session. This SHOULD be the latest 1808 (highest valued) version supported by the client. For this 1809 version of the specification, the version will be 3.2 (See 1810 Appendix E for details about backward compatibility). 1812 random 1813 A client-generated random structure. 1815 session_id 1816 The ID of a session the client wishes to use for this connection. 1817 This field should be empty if no session_id is available or the 1818 client wishes to generate new security parameters. 1820 cipher_suites 1821 This is a list of the cryptographic options supported by the 1822 client, with the client's first preference first. If the 1823 session_id field is not empty (implying a session resumption 1824 request) this vector MUST include at least the cipher_suite from 1825 that session. Values are defined in Appendix A.5. 1827 compression_methods 1828 This is a list of the compression methods supported by the 1829 client, sorted by client preference. If the session_id field is 1830 not empty (implying a session resumption request) it must include 1831 the compression_method from that session. This vector must 1832 contain, and all implementations must support, 1833 CompressionMethod.null. Thus, a client and server will always be 1834 able to agree on a compression method. 1836 After sending the client hello message, the client waits for a server 1837 hello message. Any other handshake message returned by the server 1838 except for a hello request is treated as a fatal error. 1840 Forward compatibility note: 1841 In the interests of forward compatibility, it is permitted for a 1842 client hello message to include extra data after the compression 1843 methods. This data MUST be included in the handshake hashes, but 1844 must otherwise be ignored. This is the only handshake message for 1845 which this is legal; for all other messages, the amount of data 1846 in the message MUST match the description of the message 1847 precisely. 1849 Note: For the intended use of trailing data in the ClientHello, see RFC 1850 3546 [TLSEXT]. 1852 7.4.1.3. Server hello 1854 When this message will be sent: 1855 The server will send this message in response to a client hello 1856 message when it was able to find an acceptable set of algorithms. 1857 If it cannot find such a match, it will respond with a handshake 1858 failure alert. 1860 Structure of this message: 1861 struct { 1862 ProtocolVersion server_version; 1863 Random random; 1864 SessionID session_id; 1865 CipherSuite cipher_suite; 1866 CompressionMethod compression_method; 1867 } ServerHello; 1869 server_version 1870 This field will contain the lower of that suggested by the client 1871 in the client hello and the highest supported by the server. For 1872 this version of the specification, the version is 3.2 (See 1873 Appendix E for details about backward compatibility). 1875 random 1876 This structure is generated by the server and MUST be 1877 independently generated from the ClientHello.random. 1879 session_id 1880 This is the identity of the session corresponding to this 1881 connection. If the ClientHello.session_id was non-empty, the 1882 server will look in its session cache for a match. If a match is 1883 found and the server is willing to establish the new connection 1884 using the specified session state, the server will respond with 1885 the same value as was supplied by the client. This indicates a 1886 resumed session and dictates that the parties must proceed 1887 directly to the finished messages. Otherwise this field will 1888 contain a different value identifying the new session. The server 1889 may return an empty session_id to indicate that the session will 1890 not be cached and therefore cannot be resumed. If a session is 1891 resumed, it must be resumed using the same cipher suite it was 1892 originally negotiated with. 1894 cipher_suite 1895 The single cipher suite selected by the server from the list in 1896 ClientHello.cipher_suites. For resumed sessions this field is the 1897 value from the state of the session being resumed. 1899 compression_method 1900 The single compression algorithm selected by the server from the 1901 list in ClientHello.compression_methods. For resumed sessions 1902 this field is the value from the resumed session state. 1904 7.4.2. Server certificate 1906 When this message will be sent: 1907 The server MUST send a certificate whenever the agreed-upon key 1908 exchange method is not an anonymous one. This message will always 1909 immediately follow the server hello message. 1911 Meaning of this message: 1912 The certificate type MUST be appropriate for the selected cipher 1913 suite's key exchange algorithm, and is generally an X.509v3 1914 certificate. It MUST contain a key which matches the key exchange 1915 method, as follows. Unless otherwise specified, the signing 1916 algorithm for the certificate MUST be the same as the algorithm 1917 for the certificate key. Unless otherwise specified, the public 1918 key MAY be of any length. 1920 Key Exchange Algorithm Certificate Key Type 1922 RSA RSA public key; the certificate MUST 1923 allow the key to be used for encryption. 1925 DHE_DSS DSS public key. 1927 DHE_RSA RSA public key which can be used for 1928 signing. 1930 DH_DSS Diffie-Hellman key. The algorithm used 1931 to sign the certificate MUST be DSS. 1933 DH_RSA Diffie-Hellman key. The algorithm used 1934 to sign the certificate MUST be RSA. 1936 All certificate profiles, key and cryptographic formats are defined 1937 by the IETF PKIX working group [PKIX]. When a key usage extension is 1938 present, the digitalSignature bit MUST be set for the key to be 1939 eligible for signing, as described above, and the keyEncipherment bit 1940 MUST be present to allow encryption, as described above. The 1941 keyAgreement bit must be set on Diffie-Hellman certificates. 1943 As CipherSuites which specify new key exchange methods are specified 1944 for the TLS Protocol, they will imply certificate format and the 1945 required encoded keying information. 1947 Structure of this message: 1948 opaque ASN.1Cert<1..2^24-1>; 1950 struct { 1951 ASN.1Cert certificate_list<0..2^24-1>; 1952 } Certificate; 1954 certificate_list 1955 This is a sequence (chain) of X.509v3 certificates. The sender's 1956 certificate must come first in the list. Each following 1957 certificate must directly certify the one preceding it. Because 1958 certificate validation requires that root keys be distributed 1959 independently, the self-signed certificate which specifies the 1960 root certificate authority may optionally be omitted from the 1961 chain, under the assumption that the remote end must already 1962 possess it in order to validate it in any case. 1964 The same message type and structure will be used for the client's 1965 response to a certificate request message. Note that a client MAY 1966 send no certificates if it does not have an appropriate certificate 1967 to send in response to the server's authentication request. 1969 Note: PKCS #7 [PKCS7] is not used as the format for the certificate 1970 vector because PKCS #6 [PKCS6] extended certificates are not 1971 used. Also PKCS #7 defines a SET rather than a SEQUENCE, making 1972 the task of parsing the list more difficult. 1974 7.4.3. Server key exchange message 1976 When this message will be sent: 1977 This message will be sent immediately after the server 1978 certificate message (or the server hello message, if this is an 1979 anonymous negotiation). 1981 The server key exchange message is sent by the server only when 1982 the server certificate message (if sent) does not contain enough 1983 data to allow the client to exchange a premaster secret. This is 1984 true for the following key exchange methods: 1986 DHE_DSS 1987 DHE_RSA 1988 DH_anon 1990 It is not legal to send the server key exchange message for the 1991 following key exchange methods: 1993 RSA 1994 DH_DSS 1995 DH_RSA 1997 Meaning of this message: 1998 This message conveys cryptographic information to allow the 1999 client to communicate the premaster secret: either an RSA public 2000 key to encrypt the premaster secret with, or a Diffie-Hellman 2001 public key with which the client can complete a key exchange 2002 (with the result being the premaster secret.) 2004 As additional CipherSuites are defined for TLS which include new key 2005 exchange algorithms, the server key exchange message will be sent if 2006 and only if the certificate type associated with the key exchange 2007 algorithm does not provide enough information for the client to 2008 exchange a premaster secret. 2010 Structure of this message: 2011 enum { rsa, diffie_hellman } KeyExchangeAlgorithm; 2013 struct { 2014 opaque rsa_modulus<1..2^16-1>; 2015 opaque rsa_exponent<1..2^16-1>; 2016 } ServerRSAParams; 2018 rsa_modulus 2019 The modulus of the server's temporary RSA key. 2021 rsa_exponent 2022 The public exponent of the server's temporary RSA key. 2024 struct { 2025 opaque dh_p<1..2^16-1>; 2026 opaque dh_g<1..2^16-1>; 2027 opaque dh_Ys<1..2^16-1>; 2028 } ServerDHParams; /* Ephemeral DH parameters */ 2030 dh_p 2031 The prime modulus used for the Diffie-Hellman operation. 2033 dh_g 2034 The generator used for the Diffie-Hellman operation. 2036 dh_Ys 2037 The server's Diffie-Hellman public value (g^X mod p). 2039 struct { 2040 select (KeyExchangeAlgorithm) { 2041 case diffie_hellman: 2042 ServerDHParams params; 2043 Signature signed_params; 2044 case rsa: 2045 ServerRSAParams params; 2046 Signature signed_params; 2047 }; 2048 } ServerKeyExchange; 2050 struct { 2051 select (KeyExchangeAlgorithm) { 2052 case diffie_hellman: 2053 ServerDHParams params; 2054 case rsa: 2055 ServerRSAParams params; 2056 }; 2057 } ServerParams; 2058 params 2059 The server's key exchange parameters. 2061 signed_params 2062 For non-anonymous key exchanges, a hash of the corresponding 2063 params value, with the signature appropriate to that hash 2064 applied. 2066 md5_hash 2067 MD5(ClientHello.random + ServerHello.random + ServerParams); 2069 sha_hash 2070 SHA(ClientHello.random + ServerHello.random + ServerParams); 2072 enum { anonymous, rsa, dsa } SignatureAlgorithm; 2074 struct { 2075 select (SignatureAlgorithm) { 2076 case anonymous: struct { }; 2077 case rsa: 2078 digitally-signed struct { 2079 opaque md5_hash[16]; 2080 opaque sha_hash[20]; 2081 }; 2082 case dsa: 2083 digitally-signed struct { 2084 opaque sha_hash[20]; 2085 }; 2086 }; 2087 }; 2088 } Signature; 2090 7.4.4. Certificate request 2092 When this message will be sent: 2093 A non-anonymous server can optionally request a certificate from 2094 the client, if appropriate for the selected cipher suite. This 2095 message, if sent, will immediately follow the Server Key Exchange 2096 message (if it is sent; otherwise, the Server Certificate 2097 message). 2099 Structure of this message: 2100 enum { 2101 rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4), 2102 rsa_ephemeral_dh_RESERVED(5), dss_ephemeral_dh_RESERVED(6), 2103 fortezza_dms_RESERVED(20), 2104 (255) 2105 } ClientCertificateType; 2107 opaque DistinguishedName<1..2^16-1>; 2109 struct { 2110 ClientCertificateType certificate_types<1..2^8-1>; 2111 DistinguishedName certificate_authorities<0..2^16-1>; 2112 } CertificateRequest; 2114 certificate_types 2115 This field is a list of the types of certificates requested, 2116 sorted in order of the server's preference. 2118 certificate_authorities 2119 A list of the distinguished names of acceptable certificate 2120 authorities. These distinguished names may specify a desired 2121 distinguished name for a root CA or for a subordinate CA; 2122 thus, this message can be used both to describe known roots 2123 and a desired authorization space. If the 2124 certificate_authorities list is empty then the client MAY 2125 send any certificate of the appropriate 2126 ClientCertificateType, unless there is some external 2127 arrangement to the contrary. 2129 ClientCertificateType values are divided into three groups: 2131 1. Values from 0 (zero) through 63 decimal (0x3F) inclusive are 2132 reserved for IETF Standards Track protocols. 2134 2. Values from 64 decimal (0x40) through 223 decimal (0xDF) inclusive 2135 are reserved for assignment for non-Standards Track methods. 2137 3. Values from 224 decimal (0xE0) through 255 decimal (0xFF) 2138 inclusive are reserved for private use. 2140 Additional information describing the role of IANA in the 2141 allocation of ClientCertificateType code points is described 2142 in Section 11. 2144 Note: Values listed as RESERVED may not be used. They were used in SSLv3. 2146 Note: DistinguishedName is derived from [X501]. DistinguishedNames are 2147 represented in DER-encoded format. 2149 Note: It is a fatal handshake_failure alert for an anonymous server to 2150 request client authentication. 2152 7.4.5. Server hello done 2154 When this message will be sent: 2155 The server hello done message is sent by the server to indicate 2156 the end of the server hello and associated messages. After 2157 sending this message the server will wait for a client response. 2159 Meaning of this message: 2160 This message means that the server is done sending messages to 2161 support the key exchange, and the client can proceed with its 2162 phase of the key exchange. 2164 Upon receipt of the server hello done message the client SHOULD 2165 verify that the server provided a valid certificate if required 2166 and check that the server hello parameters are acceptable. 2168 Structure of this message: 2169 struct { } ServerHelloDone; 2171 7.4.6. Client certificate 2173 When this message will be sent: 2174 This is the first message the client can send after receiving a 2175 server hello done message. This message is only sent if the 2176 server requests a certificate. If no suitable certificate is 2177 available, the client SHOULD send a certificate message 2178 containing no certificates. That is, the certificate_list 2179 structure has a length of zero. If client authentication is 2180 required by the server for the handshake to continue, it may 2181 respond with a fatal handshake failure alert. Client certificates 2182 are sent using the Certificate structure defined in Section 2183 7.4.2. 2185 Note: When using a static Diffie-Hellman based key exchange method 2186 (DH_DSS or DH_RSA), if client authentication is requested, the 2187 Diffie-Hellman group and generator encoded in the client's 2188 certificate MUST match the server specified Diffie-Hellman 2189 parameters if the client's parameters are to be used for the key 2190 exchange. 2192 7.4.7. Client key exchange message 2194 When this message will be sent: 2195 This message is always sent by the client. It MUST immediately 2196 follow the client certificate message, if it is sent. Otherwise 2197 it MUST be the first message sent by the client after it receives 2198 the server hello done message. 2200 Meaning of this message: 2201 With this message, the premaster secret is set, either though 2202 direct transmission of the RSA-encrypted secret, or by the 2203 transmission of Diffie-Hellman parameters which will allow each 2204 side to agree upon the same premaster secret. When the key 2205 exchange method is DH_RSA or DH_DSS, client certification has 2206 been requested, and the client was able to respond with a 2207 certificate which contained a Diffie-Hellman public key whose 2208 parameters (group and generator) matched those specified by the 2209 server in its certificate, this message MUST not contain any 2210 data. 2212 Structure of this message: 2213 The choice of messages depends on which key exchange method has 2214 been selected. See Section 7.4.3 for the KeyExchangeAlgorithm 2215 definition. 2217 struct { 2218 select (KeyExchangeAlgorithm) { 2219 case rsa: EncryptedPreMasterSecret; 2220 case diffie_hellman: ClientDiffieHellmanPublic; 2221 } exchange_keys; 2222 } ClientKeyExchange; 2224 7.4.7.1. RSA encrypted premaster secret message 2226 Meaning of this message: 2227 If RSA is being used for key agreement and authentication, the 2228 client generates a 48-byte premaster secret, encrypts it using 2229 the public key from the server's certificate or the temporary RSA 2230 key provided in a server key exchange message, and sends the 2231 result in an encrypted premaster secret message. This structure 2232 is a variant of the client key exchange message, not a message in 2233 itself. 2235 Structure of this message: 2236 struct { 2237 ProtocolVersion client_version; 2238 opaque random[46]; 2239 } PreMasterSecret; 2241 client_version 2242 The latest (newest) version supported by the client. This is 2243 used to detect version roll-back attacks. Upon receiving the 2244 premaster secret, the server SHOULD check that this value 2245 matches the value transmitted by the client in the client 2246 hello message. 2248 random 2249 46 securely-generated random bytes. 2251 struct { 2252 public-key-encrypted PreMasterSecret pre_master_secret; 2253 } EncryptedPreMasterSecret; 2255 pre_master_secret 2256 This random value is generated by the client and is used to 2257 generate the master secret, as specified in Section 8.1. 2259 Note: An attack discovered by Daniel Bleichenbacher [BLEI] can be used 2260 to attack a TLS server which is using PKCS#1 v 1.5 encoded RSA. 2261 The attack takes advantage of the fact that by failing in 2262 different ways, a TLS server can be coerced into revealing 2263 whether a particular message, when decrypted, is properly PKCS#1 2264 v1.5 formatted or not. 2266 The best way to avoid vulnerability to this attack is to treat 2267 incorrectly formatted messages in a manner indistinguishable from 2268 correctly formatted RSA blocks. Thus, when it receives an 2269 incorrectly formatted RSA block, a server should generate a 2270 random 48-byte value and proceed using it as the premaster 2271 secret. Thus, the server will act identically whether the 2272 received RSA block is correctly encoded or not. 2274 [PKCS1B] defines a newer version of PKCS#1 encoding that is more 2275 secure against the Bleichenbacher attack. However, for maximal 2276 compatibility with TLS 1.0, TLS 1.1 retains the original 2277 encoding. No variants of the Bleichenbacher attack are known to 2278 exist provided that the above recommendations are followed. 2280 Implementation Note: public-key-encrypted data is represented as an 2281 opaque vector <0..2^16-1> (see section 4.7). Thus the RSA- 2282 encrypted PreMasterSecret in a ClientKeyExchange is preceded by 2283 two length bytes. These bytes are redundant in the case of RSA 2284 because the EncryptedPreMasterSecret is the only data in the 2285 ClientKeyExchange and its length can therefore be unambiguously 2286 determined. The SSLv3 specification was not clear about the 2287 encoding of public-key-encrypted data and therefore many SSLv3 2288 implementations do not include the the length bytes, encoding the 2289 RSA encrypted data directly in the ClientKeyExchange message. 2291 This specification requires correct encoding of the 2292 EncryptedPreMasterSecret complete with length bytes. The 2293 resulting PDU is incompatible with many SSLv3 implementations. 2294 Implementors upgrading from SSLv3 must modify their 2295 implementations to generate and accept the correct encoding. 2297 Implementors who wish to be compatible with both SSLv3 and TLS 2298 should make their implementation's behavior dependent on the 2299 protocol version. 2301 Implementation Note: It is now known that remote timing-based attacks 2302 on SSL are possible, at least when the client and server are on 2303 the same LAN. Accordingly, implementations which use static RSA 2304 keys SHOULD use RSA blinding or some other anti-timing technique, 2305 as described in [TIMING]. 2307 Note: The version number in the PreMasterSecret MUST be the version 2308 offered by the client in the ClientHello, not the version 2309 negotiated for the connection. This feature is designed to 2310 prevent rollback attacks. Unfortunately, many implementations use 2311 the negotiated version instead and therefore checking the version 2312 number may lead to failure to interoperate with such incorrect 2313 client implementations. Client implementations MUST and Server 2314 implementations MAY check the version number. In practice, since 2315 the TLS handshake MACs prevent downgrade and no good attacks are 2316 known on those MACs, ambiguity is not considered a serious 2317 security risk. Note that if servers choose to to check the 2318 version number, they should randomize the PreMasterSecret in case 2319 of error, rather than generate an alert, in order to avoid 2320 variants on the Bleichenbacher attack. [KPR03] 2322 7.4.7.2. Client Diffie-Hellman public value 2324 Meaning of this message: 2325 This structure conveys the client's Diffie-Hellman public value 2326 (Yc) if it was not already included in the client's certificate. 2327 The encoding used for Yc is determined by the enumerated 2328 PublicValueEncoding. This structure is a variant of the client 2329 key exchange message, not a message in itself. 2331 Structure of this message: 2332 enum { implicit, explicit } PublicValueEncoding; 2334 implicit 2335 If the client certificate already contains a suitable Diffie- 2336 Hellman key, then Yc is implicit and does not need to be sent 2337 again. In this case, the client key exchange message will be 2338 sent, but MUST be empty. 2340 explicit 2341 Yc needs to be sent. 2343 struct { 2344 select (PublicValueEncoding) { 2345 case implicit: struct { }; 2346 case explicit: opaque dh_Yc<1..2^16-1>; 2347 } dh_public; 2348 } ClientDiffieHellmanPublic; 2350 dh_Yc 2351 The client's Diffie-Hellman public value (Yc). 2353 7.4.8. Certificate verify 2355 When this message will be sent: 2356 This message is used to provide explicit verification of a client 2357 certificate. This message is only sent following a client 2358 certificate that has signing capability (i.e. all certificates 2359 except those containing fixed Diffie-Hellman parameters). When 2360 sent, it MUST immediately follow the client key exchange message. 2362 Structure of this message: 2363 struct { 2364 Signature signature; 2365 } CertificateVerify; 2367 The Signature type is defined in 7.4.3. 2369 CertificateVerify.signature.md5_hash 2370 MD5(handshake_messages); 2372 CertificateVerify.signature.sha_hash 2373 SHA(handshake_messages); 2375 Here handshake_messages refers to all handshake messages sent or 2376 received starting at client hello up to but not including this 2377 message, including the type and length fields of the handshake 2378 messages. This is the concatenation of all the Handshake structures 2379 as defined in 7.4 exchanged thus far. 2381 7.4.9. Finished 2383 When this message will be sent: 2384 A finished message is always sent immediately after a change 2385 cipher spec message to verify that the key exchange and 2386 authentication processes were successful. It is essential that a 2387 change cipher spec message be received between the other 2388 handshake messages and the Finished message. 2390 Meaning of this message: 2391 The finished message is the first protected with the just- 2392 negotiated algorithms, keys, and secrets. Recipients of finished 2393 messages MUST verify that the contents are correct. Once a side 2394 has sent its Finished message and received and validated the 2395 Finished message from its peer, it may begin to send and receive 2396 application data over the connection. 2398 struct { 2399 opaque verify_data[12]; 2400 } Finished; 2402 verify_data 2403 PRF(master_secret, finished_label, MD5(handshake_messages) + 2404 SHA-1(handshake_messages)) [0..11]; 2406 finished_label 2407 For Finished messages sent by the client, the string "client 2408 finished". For Finished messages sent by the server, the 2409 string "server finished". 2411 handshake_messages 2412 All of the data from all messages in this handshake (not 2413 including any HelloRequest messages) up to but not including 2414 this message. This is only data visible at the handshake 2415 layer and does not include record layer headers. This is the 2416 concatenation of all the Handshake structures as defined in 2417 7.4 exchanged thus far. 2419 It is a fatal error if a finished message is not preceded by a change 2420 cipher spec message at the appropriate point in the handshake. 2422 The value handshake_messages includes all handshake messages starting 2423 at client hello up to, but not including, this finished message. This 2424 may be different from handshake_messages in Section 7.4.8 because it 2425 would include the certificate verify message (if sent). Also, the 2426 handshake_messages for the finished message sent by the client will 2427 be different from that for the finished message sent by the server, 2428 because the one which is sent second will include the prior one. 2430 Note: Change cipher spec messages, alerts and any other record types 2431 are not handshake messages and are not included in the hash 2432 computations. Also, Hello Request messages are omitted from 2433 handshake hashes. 2435 8. Cryptographic computations 2437 In order to begin connection protection, the TLS Record Protocol 2438 requires specification of a suite of algorithms, a master secret, and 2439 the client and server random values. The authentication, encryption, 2440 and MAC algorithms are determined by the cipher_suite selected by the 2441 server and revealed in the server hello message. The compression 2442 algorithm is negotiated in the hello messages, and the random values 2443 are exchanged in the hello messages. All that remains is to calculate 2444 the master secret. 2446 8.1. Computing the master secret 2448 For all key exchange methods, the same algorithm is used to convert 2449 the pre_master_secret into the master_secret. The pre_master_secret 2450 should be deleted from memory once the master_secret has been 2451 computed. 2453 master_secret = PRF(pre_master_secret, "master secret", 2454 ClientHello.random + ServerHello.random) 2455 [0..47]; 2457 The master secret is always exactly 48 bytes in length. The length of 2458 the premaster secret will vary depending on key exchange method. 2460 8.1.1. RSA 2462 When RSA is used for server authentication and key exchange, a 2463 48-byte pre_master_secret is generated by the client, encrypted under 2464 the server's public key, and sent to the server. The server uses its 2465 private key to decrypt the pre_master_secret. Both parties then 2466 convert the pre_master_secret into the master_secret, as specified 2467 above. 2469 RSA digital signatures are performed using PKCS #1 [PKCS1] block type 2470 1. RSA public key encryption is performed using PKCS #1 block type 2. 2472 8.1.2. Diffie-Hellman 2474 A conventional Diffie-Hellman computation is performed. The 2475 negotiated key (Z) is used as the pre_master_secret, and is converted 2476 into the master_secret, as specified above. Leading bytes of Z that 2477 contain all zero bits are stripped before it is used as the 2478 pre_master_secret. 2480 Note: Diffie-Hellman parameters are specified by the server, and may 2481 be either ephemeral or contained within the server's certificate. 2483 9. Mandatory Cipher Suites 2485 In the absence of an application profile standard specifying 2486 otherwise, a TLS compliant application MUST implement the cipher 2487 suite TLS_RSA_WITH_3DES_EDE_CBC_SHA. 2489 10. Application data protocol 2491 Application data messages are carried by the Record Layer and are 2492 fragmented, compressed and encrypted based on the current connection 2493 state. The messages are treated as transparent data to the record 2494 layer. 2496 11. IANA Considerations 2498 This document describes a number of new registries to be created by 2499 IANA. We recommend that they be placed as individual registries items 2500 under a common TLS category. 2502 Section 7.4.3 describes a TLS ClientCertificateType Registry to be 2503 maintained by the IANA, as defining a number of such code point 2504 identifiers. ClientCertificateType identifiers with values in the 2505 range 0-63 (decimal) inclusive are assigned via RFC 2434 Standards 2506 Action. Values from the range 64-223 (decimal) inclusive are assigned 2507 via [RFC 2434] Specification Required. Identifier values from 2508 224-255 (decimal) inclusive are reserved for RFC 2434 Private Use. 2509 The registry will be initially populated with the values in this 2510 document, Section 7.4.4. 2512 Section A.5 describes a TLS Cipher Suite Registry to be maintained by 2513 the IANA, as well as defining a number of such cipher suite 2514 identifiers. Cipher suite values with the first byte in the range 2515 0-191 (decimal) inclusive are assigned via RFC 2434 Standards Action. 2516 Values with the first byte in the range 192-254 (decimal) are 2517 assigned via RFC 2434 Specification Required. Values with the first 2518 byte 255 (decimal) are reserved for RFC 2434 Private Use. The 2519 registry will be initially populated with the values from Section A.5 2520 of this document, [TLSAES], and Section 3 of [TLSKRB]. 2522 Section 6 requires that all ContentType values be defined by RFC 2434 2523 Standards Action. IANA SHOULD create a TLS ContentType registry, 2524 initially populated with values from Section 6.2.1 of this document. 2525 Future values MUST be allocated via Standards Action as described in 2526 [RFC 2434]. 2528 Section 7.2.2 requires that all Alert values be defined by RFC 2434 2529 Standards Action. IANA SHOULD create a TLS Alert registry, initially 2530 populated with values from Section 7.2 of this document and Section 4 2531 of [TLSEXT]. Future values MUST be allocated via Standards Action as 2532 described in [RFC 2434]. 2534 Section 7.4 requires that all HandshakeType values be defined by RFC 2535 2434 Standards Action. IANA SHOULD create a TLS HandshakeType 2536 registry, initially populated with values from Section 7.4 of this 2537 document and Section 2.4 of [TLSEXT]. Future values MUST be 2538 allocated via Standards Action as described in [RFC2434]. 2540 A. Protocol constant values 2542 This section describes protocol types and constants. 2544 A.1. Record layer 2546 struct { 2547 uint8 major, minor; 2548 } ProtocolVersion; 2550 ProtocolVersion version = { 3, 2 }; /* TLS v1.1 */ 2552 enum { 2553 change_cipher_spec(20), alert(21), handshake(22), 2554 application_data(23), (255) 2555 } ContentType; 2557 struct { 2558 ContentType type; 2559 ProtocolVersion version; 2560 uint16 length; 2561 opaque fragment[TLSPlaintext.length]; 2562 } TLSPlaintext; 2564 struct { 2565 ContentType type; 2566 ProtocolVersion version; 2567 uint16 length; 2568 opaque fragment[TLSCompressed.length]; 2569 } TLSCompressed; 2571 struct { 2572 ContentType type; 2573 ProtocolVersion version; 2574 uint16 length; 2575 select (CipherSpec.cipher_type) { 2576 case stream: GenericStreamCipher; 2577 case block: GenericBlockCipher; 2578 } fragment; 2579 } TLSCiphertext; 2581 stream-ciphered struct { 2582 opaque content[TLSCompressed.length]; 2583 opaque MAC[CipherSpec.hash_size]; 2584 } GenericStreamCipher; 2586 block-ciphered struct { 2587 opaque IV[CipherSpec.block_length]; 2588 opaque content[TLSCompressed.length]; 2589 opaque MAC[CipherSpec.hash_size]; 2590 uint8 padding[GenericBlockCipher.padding_length]; 2591 uint8 padding_length; 2592 } GenericBlockCipher; 2594 A.2. Change cipher specs message 2596 struct { 2597 enum { change_cipher_spec(1), (255) } type; 2598 } ChangeCipherSpec; 2600 A.3. Alert messages 2602 enum { warning(1), fatal(2), (255) } AlertLevel; 2604 enum { 2605 close_notify(0), 2606 unexpected_message(10), 2607 bad_record_mac(20), 2608 decryption_failed(21), 2609 record_overflow(22), 2610 decompression_failure(30), 2611 handshake_failure(40), 2612 no_certificate_RESERVED (41), 2613 bad_certificate(42), 2614 unsupported_certificate(43), 2615 certificate_revoked(44), 2616 certificate_expired(45), 2617 certificate_unknown(46), 2618 illegal_parameter(47), 2619 unknown_ca(48), 2620 access_denied(49), 2621 decode_error(50), 2622 decrypt_error(51), 2623 export_restriction_RESERVED(60), 2624 protocol_version(70), 2625 insufficient_security(71), 2626 internal_error(80), 2627 user_canceled(90), 2628 no_renegotiation(100), 2629 (255) 2630 } AlertDescription; 2632 struct { 2633 AlertLevel level; 2634 AlertDescription description; 2635 } Alert; 2636 A.4. Handshake protocol 2638 enum { 2639 hello_request(0), client_hello(1), server_hello(2), 2640 certificate(11), server_key_exchange (12), 2641 certificate_request(13), server_hello_done(14), 2642 certificate_verify(15), client_key_exchange(16), 2643 finished(20), (255) 2644 } HandshakeType; 2646 struct { 2647 HandshakeType msg_type; 2648 uint24 length; 2649 select (HandshakeType) { 2650 case hello_request: HelloRequest; 2651 case client_hello: ClientHello; 2652 case server_hello: ServerHello; 2653 case certificate: Certificate; 2654 case server_key_exchange: ServerKeyExchange; 2655 case certificate_request: CertificateRequest; 2656 case server_hello_done: ServerHelloDone; 2657 case certificate_verify: CertificateVerify; 2658 case client_key_exchange: ClientKeyExchange; 2659 case finished: Finished; 2660 } body; 2661 } Handshake; 2663 A.4.1. Hello messages 2665 struct { } HelloRequest; 2667 struct { 2668 uint32 gmt_unix_time; 2669 opaque random_bytes[28]; 2670 } Random; 2672 opaque SessionID<0..32>; 2674 uint8 CipherSuite[2]; 2676 enum { null(0), (255) } CompressionMethod; 2678 struct { 2679 ProtocolVersion client_version; 2680 Random random; 2681 SessionID session_id; 2682 CipherSuite cipher_suites<2..2^16-1>; 2683 CompressionMethod compression_methods<1..2^8-1>; 2684 } ClientHello; 2686 struct { 2687 ProtocolVersion server_version; 2688 Random random; 2689 SessionID session_id; 2690 CipherSuite cipher_suite; 2691 CompressionMethod compression_method; 2692 } ServerHello; 2694 A.4.2. Server authentication and key exchange messages 2696 opaque ASN.1Cert<2^24-1>; 2698 struct { 2699 ASN.1Cert certificate_list<0..2^24-1>; 2700 } Certificate; 2702 enum { rsa, diffie_hellman } KeyExchangeAlgorithm; 2704 struct { 2705 opaque rsa_modulus<1..2^16-1>; 2706 opaque rsa_exponent<1..2^16-1>; 2707 } ServerRSAParams; 2709 struct { 2710 opaque dh_p<1..2^16-1>; 2711 opaque dh_g<1..2^16-1>; 2712 opaque dh_Ys<1..2^16-1>; 2713 } ServerDHParams; 2715 struct { 2716 select (KeyExchangeAlgorithm) { 2717 case diffie_hellman: 2718 ServerDHParams params; 2719 Signature signed_params; 2720 case rsa: 2721 ServerRSAParams params; 2722 Signature signed_params; 2723 }; 2724 } ServerKeyExchange; 2726 enum { anonymous, rsa, dsa } SignatureAlgorithm; 2728 struct { 2729 select (KeyExchangeAlgorithm) { 2730 case diffie_hellman: 2731 ServerDHParams params; 2732 case rsa: 2733 ServerRSAParams params; 2734 }; 2735 } ServerParams; 2737 struct { 2738 select (SignatureAlgorithm) { 2739 case anonymous: struct { }; 2740 case rsa: 2741 digitally-signed struct { 2742 opaque md5_hash[16]; 2743 opaque sha_hash[20]; 2744 }; 2745 case dsa: 2746 digitally-signed struct { 2747 opaque sha_hash[20]; 2748 }; 2749 }; 2750 }; 2751 } Signature; 2753 enum { 2754 rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4), 2755 rsa_ephemeral_dh_RESERVED(5), dss_ephemeral_dh_RESERVED(6), 2756 fortezza_dms_RESERVED(20), 2757 (255) 2758 } ClientCertificateType; 2760 opaque DistinguishedName<1..2^16-1>; 2762 struct { 2763 ClientCertificateType certificate_types<1..2^8-1>; 2764 DistinguishedName certificate_authorities<0..2^16-1>; 2765 } CertificateRequest; 2767 struct { } ServerHelloDone; 2769 A.4.3. Client authentication and key exchange messages 2771 struct { 2772 select (KeyExchangeAlgorithm) { 2773 case rsa: EncryptedPreMasterSecret; 2774 case diffie_hellman: ClientDiffieHellmanPublic; 2775 } exchange_keys; 2776 } ClientKeyExchange; 2778 struct { 2779 ProtocolVersion client_version; 2780 opaque random[46]; 2781 } PreMasterSecret; 2783 struct { 2784 public-key-encrypted PreMasterSecret pre_master_secret; 2785 } EncryptedPreMasterSecret; 2787 enum { implicit, explicit } PublicValueEncoding; 2789 struct { 2790 select (PublicValueEncoding) { 2791 case implicit: struct {}; 2792 case explicit: opaque DH_Yc<1..2^16-1>; 2793 } dh_public; 2794 } ClientDiffieHellmanPublic; 2796 struct { 2797 Signature signature; 2798 } CertificateVerify; 2800 A.4.4. Handshake finalization message 2802 struct { 2803 opaque verify_data[12]; 2804 } Finished; 2806 A.5. The CipherSuite 2808 The following values define the CipherSuite codes used in the client 2809 hello and server hello messages. 2811 A CipherSuite defines a cipher specification supported in TLS Version 2812 1.1. 2814 TLS_NULL_WITH_NULL_NULL is specified and is the initial state of a 2815 TLS connection during the first handshake on that channel, but must 2816 not be negotiated, as it provides no more protection than an 2817 unsecured connection. 2819 CipherSuite TLS_NULL_WITH_NULL_NULL = { 0x00,0x00 }; 2821 The following CipherSuite definitions require that the server provide 2822 an RSA certificate that can be used for key exchange. The server may 2823 request either an RSA or a DSS signature-capable certificate in the 2824 certificate request message. 2826 CipherSuite TLS_RSA_WITH_NULL_MD5 = { 0x00,0x01 }; 2827 CipherSuite TLS_RSA_WITH_NULL_SHA = { 0x00,0x02 }; 2828 CipherSuite TLS_RSA_WITH_RC4_128_MD5 = { 0x00,0x04 }; 2829 CipherSuite TLS_RSA_WITH_RC4_128_SHA = { 0x00,0x05 }; 2830 CipherSuite TLS_RSA_WITH_IDEA_CBC_SHA = { 0x00,0x07 }; 2831 CipherSuite TLS_RSA_WITH_DES_CBC_SHA = { 0x00,0x09 }; 2832 CipherSuite TLS_RSA_WITH_3DES_EDE_CBC_SHA = { 0x00,0x0A }; 2834 The following CipherSuite definitions are used for server- 2835 authenticated (and optionally client-authenticated) Diffie-Hellman. 2836 DH denotes cipher suites in which the server's certificate contains 2837 the Diffie-Hellman parameters signed by the certificate authority 2838 (CA). DHE denotes ephemeral Diffie-Hellman, where the Diffie-Hellman 2839 parameters are signed by a DSS or RSA certificate, which has been 2840 signed by the CA. The signing algorithm used is specified after the 2841 DH or DHE parameter. The server can request an RSA or DSS signature- 2842 capable certificate from the client for client authentication or it 2843 may request a Diffie-Hellman certificate. Any Diffie-Hellman 2844 certificate provided by the client must use the parameters (group and 2845 generator) described by the server. 2847 CipherSuite TLS_DH_DSS_WITH_DES_CBC_SHA = { 0x00,0x0C }; 2848 CipherSuite TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = { 0x00,0x0D }; 2849 CipherSuite TLS_DH_RSA_WITH_DES_CBC_SHA = { 0x00,0x0F }; 2850 CipherSuite TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = { 0x00,0x10 }; 2851 CipherSuite TLS_DHE_DSS_WITH_DES_CBC_SHA = { 0x00,0x12 }; 2852 CipherSuite TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = { 0x00,0x13 }; 2853 CipherSuite TLS_DHE_RSA_WITH_DES_CBC_SHA = { 0x00,0x15 }; 2854 CipherSuite TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = { 0x00,0x16 }; 2856 The following cipher suites are used for completely anonymous Diffie- 2857 Hellman communications in which neither party is authenticated. Note 2858 that this mode is vulnerable to man-in-the-middle attacks and is 2859 therefore deprecated. 2861 CipherSuite TLS_DH_anon_WITH_RC4_128_MD5 = { 0x00,0x18 }; 2862 CipherSuite TLS_DH_anon_WITH_DES_CBC_SHA = { 0x00,0x1A }; 2863 CipherSuite TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = { 0x00,0x1B }; 2865 When SSLv3 and TLS 1.0 were designed, the United States restricted 2866 the export of cryptographic software containing certain strong 2867 encryption algorithms. A series of cipher suites were designed to 2868 operate at reduced key lengths in order to comply with those 2869 regulations. Due to advances in computer performance, these 2870 algorithms are now unacceptably weak and export restrictions have 2871 since been loosened. TLS 1.1 implementations MUST NOT negotiate these 2872 cipher suites in TLS 1.1 mode. However, for backward compatibility 2873 they may be offered in the ClientHello for use with TLS 1.0 or SSLv3 2874 only servers. TLS 1.1 clients MUST check that the server did not 2875 choose one of these cipher suites during the handshake. These 2876 ciphersuites are listed below for informational purposes and to 2877 reserve the numbers. 2879 CipherSuite TLS_RSA_EXPORT_WITH_RC4_40_MD5 = { 0x00,0x03 }; 2880 CipherSuite TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = { 0x00,0x06 }; 2881 CipherSuite TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = { 0x00,0x08 }; 2882 CipherSuite TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = { 0x00,0x0B }; 2883 CipherSuite TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = { 0x00,0x0E }; 2884 CipherSuite TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = { 0x00,0x11 }; 2885 CipherSuite TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = { 0x00,0x14 }; 2886 CipherSuite TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = { 0x00,0x17 }; 2887 CipherSuite TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = { 0x00,0x19 }; 2889 The following cipher suites were defined in [TLSKRB] and are included 2890 here for completeness. See [TLSKRB] for details: 2892 CipherSuite TLS_KRB5_WITH_DES_CBC_SHA = { 0x00,0x1E }; 2893 CipherSuite TLS_KRB5_WITH_3DES_EDE_CBC_SHA = { 0x00,0x1F }; 2894 CipherSuite TLS_KRB5_WITH_RC4_128_SHA = { 0x00,0x20 }; 2895 CipherSuite TLS_KRB5_WITH_IDEA_CBC_SHA = { 0x00,0x21 }; 2896 CipherSuite TLS_KRB5_WITH_DES_CBC_MD5 = { 0x00,0x22 }; 2897 CipherSuite TLS_KRB5_WITH_3DES_EDE_CBC_MD5 = { 0x00,0x23 }; 2898 CipherSuite TLS_KRB5_WITH_RC4_128_MD5 = { 0x00,0x24 }; 2899 CipherSuite TLS_KRB5_WITH_IDEA_CBC_MD5 = { 0x00,0x25 }; 2901 The following exportable cipher suites were defined in [TLSKRB] and 2902 are included here for completeness. TLS 1.1 implementations MUST NOT 2903 negotiate these cipher suites. 2905 CipherSuite TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA = { 0x00,0x26 2906 }; 2907 CipherSuite TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA = { 0x00,0x27 2908 }; 2909 CipherSuite TLS_KRB5_EXPORT_WITH_RC4_40_SHA = { 0x00,0x28 2910 }; 2911 CipherSuite TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 = { 0x00,0x29 2912 }; 2913 CipherSuite TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 = { 0x00,0x2A 2914 }; 2915 CipherSuite TLS_KRB5_EXPORT_WITH_RC4_40_MD5 = { 0x00,0x2B 2916 }; 2918 The following cipher suites were defined in [TLSAES] and are included 2919 here for completeness. See [TLSAES] for details: 2921 CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA = { 0x00, 0x2F }; 2922 CipherSuite TLS_DH_DSS_WITH_AES_128_CBC_SHA = { 0x00, 0x30 }; 2923 CipherSuite TLS_DH_RSA_WITH_AES_128_CBC_SHA = { 0x00, 0x31 }; 2924 CipherSuite TLS_DHE_DSS_WITH_AES_128_CBC_SHA = { 0x00, 0x32 }; 2925 CipherSuite TLS_DHE_RSA_WITH_AES_128_CBC_SHA = { 0x00, 0x33 }; 2926 CipherSuite TLS_DH_anon_WITH_AES_128_CBC_SHA = { 0x00, 0x34 }; 2928 CipherSuite TLS_RSA_WITH_AES_256_CBC_SHA = { 0x00, 0x35 }; 2929 CipherSuite TLS_DH_DSS_WITH_AES_256_CBC_SHA = { 0x00, 0x36 }; 2930 CipherSuite TLS_DH_RSA_WITH_AES_256_CBC_SHA = { 0x00, 0x37 }; 2931 CipherSuite TLS_DHE_DSS_WITH_AES_256_CBC_SHA = { 0x00, 0x38 }; 2932 CipherSuite TLS_DHE_RSA_WITH_AES_256_CBC_SHA = { 0x00, 0x39 }; 2933 CipherSuite TLS_DH_anon_WITH_AES_256_CBC_SHA = { 0x00, 0x3A }; 2935 The cipher suite space is divided into three regions: 2937 1. Cipher suite values with first byte 0x00 (zero) 2938 through decimal 191 (0xBF) inclusive are reserved for the IETF 2939 Standards Track protocols. 2941 2. Cipher suite values with first byte decimal 192 (0xC0) 2942 through decimal 254 (0xFE) inclusive are reserved 2943 for assignment for non-Standards Track methods. 2945 3. Cipher suite values with first byte 0xFF are 2946 reserved for private use. 2947 Additional information describing the role of IANA in the allocation 2948 of cipher suite code points is described in Section 11. 2950 Note: The cipher suite values { 0x00, 0x1C } and { 0x00, 0x1D } are 2951 reserved to avoid collision with Fortezza-based cipher suites in SSL 2952 3. 2954 A.6. The Security Parameters 2956 These security parameters are determined by the TLS Handshake 2957 Protocol and provided as parameters to the TLS Record Layer in order 2958 to initialize a connection state. SecurityParameters includes: 2960 enum { null(0), (255) } CompressionMethod; 2962 enum { server, client } ConnectionEnd; 2964 enum { null, rc4, rc2, des, 3des, des40, aes, idea } 2965 BulkCipherAlgorithm; 2967 enum { stream, block } CipherType; 2969 enum { null, md5, sha } MACAlgorithm; 2971 /* The algorithms specified in CompressionMethod, 2972 BulkCipherAlgorithm, and MACAlgorithm may be added to. */ 2974 struct { 2975 ConnectionEnd entity; 2976 BulkCipherAlgorithm bulk_cipher_algorithm; 2977 CipherType cipher_type; 2978 uint8 key_size; 2979 uint8 key_material_length; 2980 MACAlgorithm mac_algorithm; 2981 uint8 hash_size; 2982 CompressionMethod compression_algorithm; 2983 opaque master_secret[48]; 2984 opaque client_random[32]; 2985 opaque server_random[32]; 2986 } SecurityParameters; 2987 B. Glossary 2989 Advanced Encryption Standard (AES) 2990 AES is a widely used symmetric encryption algorithm. 2991 AES is 2992 a block cipher with a 128, 192, or 256 bit keys and a 16 byte 2993 block size. [AES] TLS currently only supports the 128 and 256 2994 bit key sizes. 2996 application protocol 2997 An application protocol is a protocol that normally layers 2998 directly on top of the transport layer (e.g., TCP/IP). Examples 2999 include HTTP, TELNET, FTP, and SMTP. 3001 asymmetric cipher 3002 See public key cryptography. 3004 authentication 3005 Authentication is the ability of one entity to determine the 3006 identity of another entity. 3008 block cipher 3009 A block cipher is an algorithm that operates on plaintext in 3010 groups of bits, called blocks. 64 bits is a common block size. 3012 bulk cipher 3013 A symmetric encryption algorithm used to encrypt large quantities 3014 of data. 3016 cipher block chaining (CBC) 3017 CBC is a mode in which every plaintext block encrypted with a 3018 block cipher is first exclusive-ORed with the previous ciphertext 3019 block (or, in the case of the first block, with the 3020 initialization vector). For decryption, every block is first 3021 decrypted, then exclusive-ORed with the previous ciphertext block 3022 (or IV). 3024 certificate 3025 As part of the X.509 protocol (a.k.a. ISO Authentication 3026 framework), certificates are assigned by a trusted Certificate 3027 Authority and provide a strong binding between a party's identity 3028 or some other attributes and its public key. 3030 client 3031 The application entity that initiates a TLS connection to a 3032 server. This may or may not imply that the client initiated the 3033 underlying transport connection. The primary operational 3034 difference between the server and client is that the server is 3035 generally authenticated, while the client is only optionally 3036 authenticated. 3038 client write key 3039 The key used to encrypt data written by the client. 3041 client write MAC secret 3042 The secret data used to authenticate data written by the client. 3044 connection 3045 A connection is a transport (in the OSI layering model 3046 definition) that provides a suitable type of service. For TLS, 3047 such connections are peer to peer relationships. The connections 3048 are transient. Every connection is associated with one session. 3050 Data Encryption Standard 3051 DES is a very widely used symmetric encryption algorithm. DES is 3052 a block cipher with a 56 bit key and an 8 byte block size. Note 3053 that in TLS, for key generation purposes, DES is treated as 3054 having an 8 byte key length (64 bits), but it still only provides 3055 56 bits of protection. (The low bit of each key byte is presumed 3056 to be set to produce odd parity in that key byte.) DES can also 3057 be operated in a mode where three independent keys and three 3058 encryptions are used for each block of data; this uses 168 bits 3059 of key (24 bytes in the TLS key generation method) and provides 3060 the equivalent of 112 bits of security. [DES], [3DES] 3062 Digital Signature Standard (DSS) 3063 A standard for digital signing, including the Digital Signing 3064 Algorithm, approved by the National Institute of Standards and 3065 Technology, defined in NIST FIPS PUB 186, "Digital Signature 3066 Standard," published May, 1994 by the U.S. Dept. of Commerce. 3067 [DSS] 3069 digital signatures 3070 Digital signatures utilize public key cryptography and one-way 3071 hash functions to produce a signature of the data that can be 3072 authenticated, and is difficult to forge or repudiate. 3074 handshake 3075 An initial negotiation between client and server that establishes 3076 the parameters of their transactions. 3078 Initialization Vector (IV) 3079 When a block cipher is used in CBC mode, the initialization 3080 vector is exclusive-ORed with the first plaintext block prior to 3081 encryption. 3083 IDEA 3084 A 64-bit block cipher designed by Xuejia Lai and James Massey. 3085 [IDEA] 3087 Message Authentication Code (MAC) 3088 A Message Authentication Code is a one-way hash computed from a 3089 message and some secret data. It is difficult to forge without 3090 knowing the secret data. Its purpose is to detect if the message 3091 has been altered. 3093 master secret 3094 Secure secret data used for generating encryption keys, MAC 3095 secrets, and IVs. 3097 MD5 3098 MD5 is a secure hashing function that converts an arbitrarily 3099 long data stream into a digest of fixed size (16 bytes). [MD5] 3101 public key cryptography 3102 A class of cryptographic techniques employing two-key ciphers. 3103 Messages encrypted with the public key can only be decrypted with 3104 the associated private key. Conversely, messages signed with the 3105 private key can be verified with the public key. 3107 one-way hash function 3108 A one-way transformation that converts an arbitrary amount of 3109 data into a fixed-length hash. It is computationally hard to 3110 reverse the transformation or to find collisions. MD5 and SHA are 3111 examples of one-way hash functions. 3113 RC2 3114 A block cipher developed by Ron Rivest at RSA Data Security, Inc. 3115 [RSADSI] described in [RC2]. 3117 RC4 3118 A stream cipher invented by Ron Rivest. A compatible cipher is 3119 described in [SCH]. 3121 RSA 3122 A very widely used public-key algorithm that can be used for 3123 either encryption or digital signing. [RSA] 3125 server 3126 The server is the application entity that responds to requests 3127 for connections from clients. See also under client. 3129 session 3130 A TLS session is an association between a client and a server. 3131 Sessions are created by the handshake protocol. Sessions define a 3132 set of cryptographic security parameters, which can be shared 3133 among multiple connections. Sessions are used to avoid the 3134 expensive negotiation of new security parameters for each 3135 connection. 3137 session identifier 3138 A session identifier is a value generated by a server that 3139 identifies a particular session. 3141 server write key 3142 The key used to encrypt data written by the server. 3144 server write MAC secret 3145 The secret data used to authenticate data written by the server. 3147 SHA 3148 The Secure Hash Algorithm is defined in FIPS PUB 180-2. It 3149 produces a 20-byte output. Note that all references to SHA 3150 actually use the modified SHA-1 algorithm. [SHA] 3152 SSL 3153 Netscape's Secure Socket Layer protocol [SSL3]. TLS is based on 3154 SSL Version 3.0 3156 stream cipher 3157 An encryption algorithm that converts a key into a 3158 cryptographically-strong keystream, which is then exclusive-ORed 3159 with the plaintext. 3161 symmetric cipher 3162 See bulk cipher. 3164 Transport Layer Security (TLS) 3165 This protocol; also, the Transport Layer Security working group 3166 of the Internet Engineering Task Force (IETF). See "Comments" at 3167 the end of this document. 3169 C. CipherSuite definitions 3171 CipherSuite Key Cipher Hash 3172 Exchange 3174 TLS_NULL_WITH_NULL_NULL NULL NULL NULL 3175 TLS_RSA_WITH_NULL_MD5 RSA NULL MD5 3176 TLS_RSA_WITH_NULL_SHA RSA NULL SHA 3177 TLS_RSA_WITH_RC4_128_MD5 RSA RC4_128 MD5 3178 TLS_RSA_WITH_RC4_128_SHA RSA RC4_128 SHA 3179 TLS_RSA_WITH_IDEA_CBC_SHA RSA IDEA_CBC SHA 3180 TLS_RSA_WITH_DES_CBC_SHA RSA DES_CBC SHA 3181 TLS_RSA_WITH_3DES_EDE_CBC_SHA RSA 3DES_EDE_CBC SHA 3182 TLS_DH_DSS_WITH_DES_CBC_SHA DH_DSS DES_CBC SHA 3183 TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA DH_DSS 3DES_EDE_CBC SHA 3184 TLS_DH_RSA_WITH_DES_CBC_SHA DH_RSA DES_CBC SHA 3185 TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA DH_RSA 3DES_EDE_CBC SHA 3186 TLS_DHE_DSS_WITH_DES_CBC_SHA DHE_DSS DES_CBC SHA 3187 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA DHE_DSS 3DES_EDE_CBC SHA 3188 TLS_DHE_RSA_WITH_DES_CBC_SHA DHE_RSA DES_CBC SHA 3189 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA DHE_RSA 3DES_EDE_CBC SHA 3190 TLS_DH_anon_WITH_RC4_128_MD5 DH_anon RC4_128 MD5 3191 TLS_DH_anon_WITH_DES_CBC_SHA DH_anon DES_CBC SHA 3192 TLS_DH_anon_WITH_3DES_EDE_CBC_SHA DH_anon 3DES_EDE_CBC SHA 3194 Key 3195 Exchange 3196 Algorithm Description Key size limit 3198 DHE_DSS Ephemeral DH with DSS signatures None 3199 DHE_RSA Ephemeral DH with RSA signatures None 3200 DH_anon Anonymous DH, no signatures None 3201 DH_DSS DH with DSS-based certificates None 3202 DH_RSA DH with RSA-based certificates None 3203 RSA = none 3204 NULL No key exchange N/A 3205 RSA RSA key exchange None 3207 Key Expanded IV Block 3208 Cipher Type Material Key Material Size Size 3210 NULL Stream 0 0 0 N/A 3211 IDEA_CBC Block 16 16 8 8 3212 RC2_CBC_40 Block 5 16 8 8 3213 RC4_40 Stream 5 16 0 N/A 3214 RC4_128 Stream 16 16 0 N/A 3215 DES40_CBC Block 5 8 8 8 3216 DES_CBC Block 8 8 8 8 3217 3DES_EDE_CBC Block 24 24 8 8 3219 Type 3220 Indicates whether this is a stream cipher or a block cipher 3221 running in CBC mode. 3223 Key Material 3224 The number of bytes from the key_block that are used for 3225 generating the write keys. 3227 Expanded Key Material 3228 The number of bytes actually fed into the encryption algorithm 3230 IV Size 3231 How much data needs to be generated for the initialization 3232 vector. Zero for stream ciphers; equal to the block size for 3233 block ciphers. 3235 Block Size 3236 The amount of data a block cipher enciphers in one chunk; a 3237 block cipher running in CBC mode can only encrypt an even 3238 multiple of its block size. 3240 Hash Hash Padding 3241 function Size Size 3242 NULL 0 0 3243 MD5 16 48 3244 SHA 20 40 3245 D. Implementation Notes 3247 The TLS protocol cannot prevent many common security mistakes. This 3248 section provides several recommendations to assist implementors. 3250 D.1 Random Number Generation and Seeding 3252 TLS requires a cryptographically-secure pseudorandom number generator 3253 (PRNG). Care must be taken in designing and seeding PRNGs. PRNGs 3254 based on secure hash operations, most notably MD5 and/or SHA, are 3255 acceptable, but cannot provide more security than the size of the 3256 random number generator state. (For example, MD5-based PRNGs usually 3257 provide 128 bits of state.) 3259 To estimate the amount of seed material being produced, add the 3260 number of bits of unpredictable information in each seed byte. For 3261 example, keystroke timing values taken from a PC compatible's 18.2 Hz 3262 timer provide 1 or 2 secure bits each, even though the total size of 3263 the counter value is 16 bits or more. To seed a 128-bit PRNG, one 3264 would thus require approximately 100 such timer values. 3266 [RANDOM] provides guidance on the generation of random values. 3268 D.2 Certificates and authentication 3270 Implementations are responsible for verifying the integrity of 3271 certificates and should generally support certificate revocation 3272 messages. Certificates should always be verified to ensure proper 3273 signing by a trusted Certificate Authority (CA). The selection and 3274 addition of trusted CAs should be done very carefully. Users should 3275 be able to view information about the certificate and root CA. 3277 D.3 CipherSuites 3279 TLS supports a range of key sizes and security levels, including some 3280 which provide no or minimal security. A proper implementation will 3281 probably not support many cipher suites. For example, 40-bit 3282 encryption is easily broken, so implementations requiring strong 3283 security should not allow 40-bit keys. Similarly, anonymous Diffie- 3284 Hellman is strongly discouraged because it cannot prevent man-in-the- 3285 middle attacks. Applications should also enforce minimum and maximum 3286 key sizes. For example, certificate chains containing 512-bit RSA 3287 keys or signatures are not appropriate for high-security 3288 applications. 3290 E. Backward Compatibility With SSL 3292 For historical reasons and in order to avoid a profligate consumption 3293 of reserved port numbers, application protocols which are secured by 3294 TLS 1.1, TLS 1.0, SSL 3.0, and SSL 2.0 all frequently share the same 3295 connection port: for example, the https protocol (HTTP secured by SSL 3296 or TLS) uses port 443 regardless of which security protocol it is 3297 using. Thus, some mechanism must be determined to distinguish and 3298 negotiate among the various protocols. 3300 TLS versions 1.1, 1.0, and SSL 3.0 are very similar; thus, supporting 3301 both is easy. TLS clients who wish to negotiate with such older 3302 servers SHOULD send client hello messages using the SSL 3.0 record 3303 format and client hello structure, sending {3, 2} for the version 3304 field to note that they support TLS 1.1. If the server supports only 3305 TLS 1.0 or SSL 3.0, it will respond with a downrev 3.0 server hello; 3306 if it supports TLS 1.1 it will respond with a TLS 1.1 server hello. 3307 The negotiation then proceeds as appropriate for the negotiated 3308 protocol. 3310 Similarly, a TLS 1.1 server which wishes to interoperate with TLS 3311 1.0 or SSL 3.0 clients SHOULD accept SSL 3.0 client hello messages 3312 and respond with a SSL 3.0 server hello if an SSL 3.0 client hello 3313 with a version field of {3, 0} is received, denoting that this client 3314 does not support TLS. Similarly, if a SSL 3.0 or TLS 1.0 hello with a 3315 version field of {3, 1} is received, the server SHOULD respond with a 3316 TLS 1.0 hello with a version field of {3, 1}. 3318 Whenever a client already knows the highest protocol known to a 3319 server (for example, when resuming a session), it SHOULD initiate the 3320 connection in that native protocol. 3322 TLS 1.1 clients that support SSL Version 2.0 servers MUST send SSL 3323 Version 2.0 client hello messages [SSL2]. TLS servers SHOULD accept 3324 either client hello format if they wish to support SSL 2.0 clients on 3325 the same connection port. The only deviations from the Version 2.0 3326 specification are the ability to specify a version with a value of 3327 three and the support for more ciphering types in the CipherSpec. 3329 Warning: The ability to send Version 2.0 client hello messages will be 3330 phased out with all due haste. Implementors SHOULD make every 3331 effort to move forward as quickly as possible. Version 3.0 3332 provides better mechanisms for moving to newer versions. 3334 The following cipher specifications are carryovers from SSL Version 3335 2.0. These are assumed to use RSA for key exchange and 3336 authentication. 3338 V2CipherSpec TLS_RC4_128_WITH_MD5 = { 0x01,0x00,0x80 }; 3339 V2CipherSpec TLS_RC4_128_EXPORT40_WITH_MD5 = { 0x02,0x00,0x80 }; 3340 V2CipherSpec TLS_RC2_CBC_128_CBC_WITH_MD5 = { 0x03,0x00,0x80 }; 3341 V2CipherSpec TLS_RC2_CBC_128_CBC_EXPORT40_WITH_MD5 3342 = { 0x04,0x00,0x80 }; 3343 V2CipherSpec TLS_IDEA_128_CBC_WITH_MD5 = { 0x05,0x00,0x80 }; 3344 V2CipherSpec TLS_DES_64_CBC_WITH_MD5 = { 0x06,0x00,0x40 }; 3345 V2CipherSpec TLS_DES_192_EDE3_CBC_WITH_MD5 = { 0x07,0x00,0xC0 }; 3347 Cipher specifications native to TLS can be included in Version 2.0 3348 client hello messages using the syntax below. Any V2CipherSpec 3349 element with its first byte equal to zero will be ignored by Version 3350 2.0 servers. Clients sending any of the above V2CipherSpecs SHOULD 3351 also include the TLS equivalent (see Appendix A.5): 3353 V2CipherSpec (see TLS name) = { 0x00, CipherSuite }; 3355 Note: TLS 1.1 clients may generate the SSLv2 EXPORT cipher suites in 3356 handshakes for backward compatibility but MUST NOT negotiate them in 3357 TLS 1.1 mode. 3359 E.1. Version 2 client hello 3361 The Version 2.0 client hello message is presented below using this 3362 document's presentation model. The true definition is still assumed 3363 to be the SSL Version 2.0 specification. Note that this message MUST 3364 be sent directly on the wire, not wrapped as an SSLv3 record 3366 uint8 V2CipherSpec[3]; 3368 struct { 3369 uint16 msg_length; 3370 uint8 msg_type; 3371 Version version; 3372 uint16 cipher_spec_length; 3373 uint16 session_id_length; 3374 uint16 challenge_length; 3375 V2CipherSpec cipher_specs[V2ClientHello.cipher_spec_length]; 3376 opaque session_id[V2ClientHello.session_id_length]; 3377 opaque challenge[V2ClientHello.challenge_length; 3378 } V2ClientHello; 3380 msg_length 3381 This field is the length of the following data in bytes. The high 3382 bit MUST be 1 and is not part of the length. 3384 msg_type 3385 This field, in conjunction with the version field, identifies a 3386 version 2 client hello message. The value SHOULD be one (1). 3388 version 3389 The highest version of the protocol supported by the client 3390 (equals ProtocolVersion.version, see Appendix A.1). 3392 cipher_spec_length 3393 This field is the total length of the field cipher_specs. It 3394 cannot be zero and MUST be a multiple of the V2CipherSpec length 3395 (3). 3397 session_id_length 3398 This field MUST have a value of zero. 3400 challenge_length 3401 The length in bytes of the client's challenge to the server to 3402 authenticate itself. When using the SSLv2 backward compatible 3403 handshake the client MUST use a 32-byte challenge. 3405 cipher_specs 3406 This is a list of all CipherSpecs the client is willing and able 3407 to use. There MUST be at least one CipherSpec acceptable to the 3408 server. 3410 session_id 3411 This field MUST be empty. 3413 challenge 3414 The client challenge to the server for the server to identify 3415 itself is a (nearly) arbitrary length random. The TLS server will 3416 right justify the challenge data to become the ClientHello.random 3417 data (padded with leading zeroes, if necessary), as specified in 3418 this protocol specification. If the length of the challenge is 3419 greater than 32 bytes, only the last 32 bytes are used. It is 3420 legitimate (but not necessary) for a V3 server to reject a V2 3421 ClientHello that has fewer than 16 bytes of challenge data. 3423 Note: Requests to resume a TLS session MUST use a TLS client hello. 3425 E.2. Avoiding man-in-the-middle version rollback 3427 When TLS clients fall back to Version 2.0 compatibility mode, they 3428 SHOULD use special PKCS #1 block formatting. This is done so that TLS 3429 servers will reject Version 2.0 sessions with TLS-capable clients. 3431 When TLS clients are in Version 2.0 compatibility mode, they set the 3432 right-hand (least-significant) 8 random bytes of the PKCS padding 3433 (not including the terminal null of the padding) for the RSA 3434 encryption of the ENCRYPTED-KEY-DATA field of the CLIENT-MASTER-KEY 3435 to 0x03 (the other padding bytes are random). After decrypting the 3436 ENCRYPTED-KEY-DATA field, servers that support TLS SHOULD issue an 3437 error if these eight padding bytes are 0x03. Version 2.0 servers 3438 receiving blocks padded in this manner will proceed normally. 3440 F. Security analysis 3442 The TLS protocol is designed to establish a secure connection between 3443 a client and a server communicating over an insecure channel. This 3444 document makes several traditional assumptions, including that 3445 attackers have substantial computational resources and cannot obtain 3446 secret information from sources outside the protocol. Attackers are 3447 assumed to have the ability to capture, modify, delete, replay, and 3448 otherwise tamper with messages sent over the communication channel. 3449 This appendix outlines how TLS has been designed to resist a variety 3450 of attacks. 3452 F.1. Handshake protocol 3454 The handshake protocol is responsible for selecting a CipherSpec and 3455 generating a Master Secret, which together comprise the primary 3456 cryptographic parameters associated with a secure session. The 3457 handshake protocol can also optionally authenticate parties who have 3458 certificates signed by a trusted certificate authority. 3460 F.1.1. Authentication and key exchange 3462 TLS supports three authentication modes: authentication of both 3463 parties, server authentication with an unauthenticated client, and 3464 total anonymity. Whenever the server is authenticated, the channel is 3465 secure against man-in-the-middle attacks, but completely anonymous 3466 sessions are inherently vulnerable to such attacks. Anonymous 3467 servers cannot authenticate clients. If the server is authenticated, 3468 its certificate message must provide a valid certificate chain 3469 leading to an acceptable certificate authority. Similarly, 3470 authenticated clients must supply an acceptable certificate to the 3471 server. Each party is responsible for verifying that the other's 3472 certificate is valid and has not expired or been revoked. 3474 The general goal of the key exchange process is to create a 3475 pre_master_secret known to the communicating parties and not to 3476 attackers. The pre_master_secret will be used to generate the 3477 master_secret (see Section 8.1). The master_secret is required to 3478 generate the finished messages, encryption keys, and MAC secrets (see 3479 Sections 7.4.8, 7.4.9 and 6.3). By sending a correct finished 3480 message, parties thus prove that they know the correct 3481 pre_master_secret. 3483 F.1.1.1. Anonymous key exchange 3485 Completely anonymous sessions can be established using RSA or Diffie- 3486 Hellman for key exchange. With anonymous RSA, the client encrypts a 3487 pre_master_secret with the server's uncertified public key extracted 3488 from the server key exchange message. The result is sent in a client 3489 key exchange message. Since eavesdroppers do not know the server's 3490 private key, it will be infeasible for them to decode the 3491 pre_master_secret. 3493 Note: No anonymous RSA Cipher Suites are defined in this document. 3495 With Diffie-Hellman, the server's public parameters are contained in 3496 the server key exchange message and the client's are sent in the 3497 client key exchange message. Eavesdroppers who do not know the 3498 private values should not be able to find the Diffie-Hellman result 3499 (i.e. the pre_master_secret). 3501 Warning: Completely anonymous connections only provide protection 3502 against passive eavesdropping. Unless an independent tamper- 3503 proof channel is used to verify that the finished messages 3504 were not replaced by an attacker, server authentication is 3505 required in environments where active man-in-the-middle 3506 attacks are a concern. 3508 F.1.1.2. RSA key exchange and authentication 3510 With RSA, key exchange and server authentication are combined. The 3511 public key may be either contained in the server's certificate or may 3512 be a temporary RSA key sent in a server key exchange message. When 3513 temporary RSA keys are used, they are signed by the server's RSA 3514 certificate. The signature includes the current ClientHello.random, 3515 so old signatures and temporary keys cannot be replayed. Servers may 3516 use a single temporary RSA key for multiple negotiation sessions. 3518 Note: The temporary RSA key option is useful if servers need large 3519 certificates but must comply with government-imposed size limits 3520 on keys used for key exchange. 3522 Note that if ephemeral RSA is not used, compromise of the server's 3523 static RSA key results in a loss of confidentiality for all sessions 3524 protected under that static key. TLS users desiring Perfect Forward 3525 Secrecy should use DHE cipher suites. The damage done by exposure of 3526 a private key can be limited by changing one's private key (and 3527 certificate) frequently. 3529 After verifying the server's certificate, the client encrypts a 3530 pre_master_secret with the server's public key. By successfully 3531 decoding the pre_master_secret and producing a correct finished 3532 message, the server demonstrates that it knows the private key 3533 corresponding to the server certificate. 3535 When RSA is used for key exchange, clients are authenticated using 3536 the certificate verify message (see Section 7.4.8). The client signs 3537 a value derived from the master_secret and all preceding handshake 3538 messages. These handshake messages include the server certificate, 3539 which binds the signature to the server, and ServerHello.random, 3540 which binds the signature to the current handshake process. 3542 F.1.1.3. Diffie-Hellman key exchange with authentication 3544 When Diffie-Hellman key exchange is used, the server can either 3545 supply a certificate containing fixed Diffie-Hellman parameters or 3546 can use the server key exchange message to send a set of temporary 3547 Diffie-Hellman parameters signed with a DSS or RSA certificate. 3548 Temporary parameters are hashed with the hello.random values before 3549 signing to ensure that attackers do not replay old parameters. In 3550 either case, the client can verify the certificate or signature to 3551 ensure that the parameters belong to the server. 3553 If the client has a certificate containing fixed Diffie-Hellman 3554 parameters, its certificate contains the information required to 3555 complete the key exchange. Note that in this case the client and 3556 server will generate the same Diffie-Hellman result (i.e., 3557 pre_master_secret) every time they communicate. To prevent the 3558 pre_master_secret from staying in memory any longer than necessary, 3559 it should be converted into the master_secret as soon as possible. 3560 Client Diffie-Hellman parameters must be compatible with those 3561 supplied by the server for the key exchange to work. 3563 If the client has a standard DSS or RSA certificate or is 3564 unauthenticated, it sends a set of temporary parameters to the server 3565 in the client key exchange message, then optionally uses a 3566 certificate verify message to authenticate itself. 3568 If the same DH keypair is to be used for multiple handshakes, either 3569 because the client or server has a certificate containing a fixed DH 3570 keypair or because the server is reusing DH keys, care must be taken 3571 to prevent small subgroup attacks. Implementations SHOULD follow the 3572 guidelines found in [SUBGROUP]. 3574 Small subgroup attacks are most easily avoided by using one of the 3575 DHE ciphersuites and generating a fresh DH private key (X) for each 3576 handshake. If a suitable base (such as 2) is chosen, g^X mod p can be 3577 computed very quickly so the performance cost is minimized. 3578 Additionally, using a fresh key for each handshake provides Perfect 3579 Forward Secrecy. Implementations SHOULD generate a new X for each 3580 handshake when using DHE ciphersuites. 3582 F.1.2. Version rollback attacks 3583 Because TLS includes substantial improvements over SSL Version 2.0, 3584 attackers may try to make TLS-capable clients and servers fall back 3585 to Version 2.0. This attack can occur if (and only if) two TLS- 3586 capable parties use an SSL 2.0 handshake. 3588 Although the solution using non-random PKCS #1 block type 2 message 3589 padding is inelegant, it provides a reasonably secure way for Version 3590 3.0 servers to detect the attack. This solution is not secure against 3591 attackers who can brute force the key and substitute a new ENCRYPTED- 3592 KEY-DATA message containing the same key (but with normal padding) 3593 before the application specified wait threshold has expired. Parties 3594 concerned about attacks of this scale should not be using 40-bit 3595 encryption keys anyway. Altering the padding of the least-significant 3596 8 bytes of the PKCS padding does not impact security for the size of 3597 the signed hashes and RSA key lengths used in the protocol, since 3598 this is essentially equivalent to increasing the input block size by 3599 8 bytes. 3601 F.1.3. Detecting attacks against the handshake protocol 3603 An attacker might try to influence the handshake exchange to make the 3604 parties select different encryption algorithms than they would 3605 normally chooses. 3607 For this attack, an attacker must actively change one or more 3608 handshake messages. If this occurs, the client and server will 3609 compute different values for the handshake message hashes. As a 3610 result, the parties will not accept each others' finished messages. 3611 Without the master_secret, the attacker cannot repair the finished 3612 messages, so the attack will be discovered. 3614 F.1.4. Resuming sessions 3616 When a connection is established by resuming a session, new 3617 ClientHello.random and ServerHello.random values are hashed with the 3618 session's master_secret. Provided that the master_secret has not been 3619 compromised and that the secure hash operations used to produce the 3620 encryption keys and MAC secrets are secure, the connection should be 3621 secure and effectively independent from previous connections. 3622 Attackers cannot use known encryption keys or MAC secrets to 3623 compromise the master_secret without breaking the secure hash 3624 operations (which use both SHA and MD5). 3626 Sessions cannot be resumed unless both the client and server agree. 3627 If either party suspects that the session may have been compromised, 3628 or that certificates may have expired or been revoked, it should 3629 force a full handshake. An upper limit of 24 hours is suggested for 3630 session ID lifetimes, since an attacker who obtains a master_secret 3631 may be able to impersonate the compromised party until the 3632 corresponding session ID is retired. Applications that may be run in 3633 relatively insecure environments should not write session IDs to 3634 stable storage. 3636 F.1.5. MD5 and SHA 3638 TLS uses hash functions very conservatively. Where possible, both MD5 3639 and SHA are used in tandem to ensure that non-catastrophic flaws in 3640 one algorithm will not break the overall protocol. 3642 F.2. Protecting application data 3644 The master_secret is hashed with the ClientHello.random and 3645 ServerHello.random to produce unique data encryption keys and MAC 3646 secrets for each connection. 3648 Outgoing data is protected with a MAC before transmission. To prevent 3649 message replay or modification attacks, the MAC is computed from the 3650 MAC secret, the sequence number, the message length, the message 3651 contents, and two fixed character strings. The message type field is 3652 necessary to ensure that messages intended for one TLS Record Layer 3653 client are not redirected to another. The sequence number ensures 3654 that attempts to delete or reorder messages will be detected. Since 3655 sequence numbers are 64-bits long, they should never overflow. 3656 Messages from one party cannot be inserted into the other's output, 3657 since they use independent MAC secrets. Similarly, the server-write 3658 and client-write keys are independent so stream cipher keys are used 3659 only once. 3661 If an attacker does break an encryption key, all messages encrypted 3662 with it can be read. Similarly, compromise of a MAC key can make 3663 message modification attacks possible. Because MACs are also 3664 encrypted, message-alteration attacks generally require breaking the 3665 encryption algorithm as well as the MAC. 3667 Note: MAC secrets may be larger than encryption keys, so messages can 3668 remain tamper resistant even if encryption keys are broken. 3670 F.3. Explicit IVs 3672 [CBCATT] describes a chosen plaintext attack on TLS that depends 3673 on knowing the IV for a record. Previous versions of TLS [TLS1.0] 3674 used the CBC residue of the previous record as the IV and 3675 therefore enabled this attack. This version uses an explicit IV 3676 in order to protect against this attack. 3678 F.4 Security of Composite Cipher Modes 3680 TLS secures transmitted application data via the use of symmetric 3681 encryption and authentication functions defined in the negotiated 3682 ciphersuite. The objective is to protect both the integrity and 3683 confidentiality of the transmitted data from malicious actions by 3684 active attackers in the network. It turns out that the order in 3685 which encryption and authentication functions are applied to the 3686 data plays an important role for achieving this goal [ENCAUTH]. 3688 The most robust method, called encrypt-then-authenticate, first 3689 applies encryption to the data and then applies a MAC to the 3690 ciphertext. This method ensures that the integrity and 3691 confidentiality goals are obtained with ANY pair of encryption 3692 and MAC functions provided that the former is secure against 3693 chosen plaintext attacks and the MAC is secure against chosen- 3694 message attacks. TLS uses another method, called authenticate- 3695 then-encrypt, in which first a MAC is computed on the plaintext 3696 and then the concatenation of plaintext and MAC is encrypted. 3697 This method has been proven secure for CERTAIN combinations of 3698 encryption functions and MAC functions, but is not guaranteed to 3699 be secure in general. In particular, it has been shown that there 3700 exist perfectly secure encryption functions (secure even in the 3701 information theoretic sense) that combined with any secure MAC 3702 function fail to provide the confidentiality goal against an 3703 active attack. Therefore, new ciphersuites and operation modes 3704 adopted into TLS need to be analyzed under the authenticate-then- 3705 encrypt method to verify that they achieve the stated integrity 3706 and confidentiality goals. 3708 Currently, the security of the authenticate-then-encrypt method 3709 has been proven for some important cases. One is the case of 3710 stream ciphers in which a computationally unpredictable pad of 3711 the length of the message plus the length of the MAC tag is 3712 produced using a pseudo-random generator and this pad is xor-ed 3713 with the concatenation of plaintext and MAC tag. The other is 3714 the case of CBC mode using a secure block cipher. In this case, 3715 security can be shown if one applies one CBC encryption pass to 3716 the concatenation of plaintext and MAC and uses a new, 3717 independent and unpredictable, IV for each new pair of plaintext 3718 and MAC. In previous versions of SSL, CBC mode was used properly 3719 EXCEPT that it used a predictable IV in the form of the last 3720 block of the previous ciphertext. This made TLS open to chosen 3721 plaintext attacks. This verson of the protocol is immune to 3722 those attacks. For exact details in the encryption modes proven 3723 secure see [ENCAUTH]. 3725 F.5 Denial of Service 3727 TLS is susceptible to a number of denial of service (DoS) 3728 attacks. In particular, an attacker who initiates a large number 3729 of TCP connections can cause a server to consume large amounts of 3730 CPU doing RSA decryption. However, because TLS is generally used 3731 over TCP, it is difficult for the attacker to hide his point of 3732 origin if proper TCP SYN randomization is used [SEQNUM] by the 3733 TCP stack. 3735 Because TLS runs over TCP, it is also susceptible to a number of 3736 denial of service attacks on individual connections. In 3737 particular, attackers can forge RSTs, terminating connections, or 3738 forge partial TLS records, causing the connection to stall. 3739 These attacks cannot in general be defended against by a TCP- 3740 using protocol. Implementors or users who are concerned with this 3741 class of attack should use IPsec AH [AH] or ESP [ESP]. 3743 F.6. Final notes 3745 For TLS to be able to provide a secure connection, both the client 3746 and server systems, keys, and applications must be secure. In 3747 addition, the implementation must be free of security errors. 3749 The system is only as strong as the weakest key exchange and 3750 authentication algorithm supported, and only trustworthy 3751 cryptographic functions should be used. Short public keys, 40-bit 3752 bulk encryption keys, and anonymous servers should be used with great 3753 caution. Implementations and users must be careful when deciding 3754 which certificates and certificate authorities are acceptable; a 3755 dishonest certificate authority can do tremendous damage. 3757 Security Considerations 3759 Security issues are discussed throughout this memo, especially in 3760 Appendices D, E, and F. 3762 Normative References 3763 [AES] National Institute of Standards and Technology, 3764 "Specification for the Advanced Encryption Standard (AES)" 3765 FIPS 197. November 26, 2001. 3767 [3DES] W. Tuchman, "Hellman Presents No Shortcut Solutions To DES," 3768 IEEE Spectrum, v. 16, n. 7, July 1979, pp40-41. 3770 [DES] ANSI X3.106, "American National Standard for Information 3771 Systems-Data Link Encryption," American National Standards 3772 Institute, 1983. 3774 [DSS] NIST FIPS PUB 186-2, "Digital Signature Standard," National 3775 Institute of Standards and Technology, U.S. Department of 3776 Commerce, 2000. 3778 [HMAC] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 3779 Hashing for Message Authentication," RFC 2104, February 3780 1997. 3782 [IDEA] X. Lai, "On the Design and Security of Block Ciphers," ETH 3783 Series in Information Processing, v. 1, Konstanz: Hartung- 3784 Gorre Verlag, 1992. 3786 [MD5] Rivest, R., "The MD5 Message Digest Algorithm", RFC 1321, 3787 April 1992. 3789 [PKCS1A] B. Kaliski, "Public-Key Cryptography Standards (PKCS) #1: 3790 RSA Cryptography Specifications Version 1.5", RFC 2313, 3791 March 1998. 3793 [PKCS1B] J. Jonsson, B. Kaliski, "Public-Key Cryptography Standards 3794 (PKCS) #1: RSA Cryptography Specifications Version 2.1", RFC 3795 3447, February 2003. 3797 [PKIX] Housley, R., Ford, W., Polk, W. and D. Solo, "Internet 3798 Public Key Infrastructure: Part I: X.509 Certificate and CRL 3799 Profile", RFC 3280, April 2002. 3801 [RC2] Rivest, R., "A Description of the RC2(r) Encryption 3802 Algorithm", RFC 2268, January 1998. 3804 [SCH] B. Schneier. "Applied Cryptography: Protocols, Algorithms, 3805 and Source Code in C, 2ed", Published by John Wiley & Sons, 3806 Inc. 1996. 3808 [SHA] NIST FIPS PUB 180-2, "Secure Hash Standard," National 3809 Institute of Standards and Technology, U.S. Department of 3810 Commerce., August 2001. 3812 [REQ] Bradner, S., "Key words for use in RFCs to Indicate 3813 Requirement Levels", BCP 14, RFC 2119, March 1997. 3815 [RFC2434] T. Narten, H. Alvestrand, "Guidelines for Writing an IANA 3816 Considerations Section in RFCs", RFC 3434, October 1998. 3818 [TLSAES] Chown, P. "Advanced Encryption Standard (AES) Ciphersuites 3819 for Transport Layer Security (TLS)", RFC 3268, June 2002. 3821 [TLSEXT] Blake-Wilson, S., Nystrom, M, Hopwood, D., Mikkelsen, J., 3822 Wright, T., "Transport Layer Security (TLS) Extensions", RFC 3823 3546, June 2003. 3824 [TLSKRB] A. Medvinsky, M. Hur, "Addition of Kerberos Cipher Suites to 3825 Transport Layer Security (TLS)", RFC 2712, October 1999. 3827 Informative References 3829 [AH] Kent, S., and Atkinson, R., "IP Authentication Header", RFC 3830 2402, November 1998. 3832 [BLEI] Bleichenbacher D., "Chosen Ciphertext Attacks against 3833 Protocols Based on RSA Encryption Standard PKCS #1" in 3834 Advances in Cryptology -- CRYPTO'98, LNCS vol. 1462, pages: 3835 1-12, 1998. 3837 [CBCATT] Moeller, B., "Security of CBC Ciphersuites in SSL/TLS: 3838 Problems and Countermeasures", 3839 http://www.openssl.org/~bodo/tls-cbc.txt. 3841 [CBCTIME] Canvel, B., "Password Interception in a SSL/TLS Channel", 3842 http://lasecwww.epfl.ch/memo_ssl.shtml, 2003. 3844 [ENCAUTH] Krawczyk, H., "The Order of Encryption and Authentication 3845 for Protecting Communications (Or: How Secure is SSL?)", 3846 Crypto 2001. 3848 [ESP] Kent, S., and Atkinson, R., "IP Encapsulating Security 3849 Payload (ESP)", RFC 2406, November 1998. 3851 [KPR03] Klima, V., Pokorny, O., Rosa, T., "Attacking RSA-based 3852 Sessions in SSL/TLS", http://eprint.iacr.org/2003/052/, 3853 March 2003. 3855 [PKCS6] RSA Laboratories, "PKCS #6: RSA Extended Certificate Syntax 3856 Standard," version 1.5, November 1993. 3858 [PKCS7] RSA Laboratories, "PKCS #7: RSA Cryptographic Message Syntax 3859 Standard," version 1.5, November 1993. 3861 [RANDOM] D. Eastlake 3rd, S. Crocker, J. Schiller. "Randomness 3862 Recommendations for Security", RFC 1750, December 1994. 3864 [RSA] R. Rivest, A. Shamir, and L. M. Adleman, "A Method for 3865 Obtaining Digital Signatures and Public-Key Cryptosystems," 3866 Communications of the ACM, v. 21, n. 2, Feb 1978, pp. 3867 120-126. 3869 [SEQNUM] Bellovin. S., "Defending Against Sequence Number Attacks", 3870 RFC 1948, May 1996. 3872 [SSL2] Hickman, Kipp, "The SSL Protocol", Netscape Communications 3873 Corp., Feb 9, 1995. 3875 [SSL3] A. Frier, P. Karlton, and P. Kocher, "The SSL 3.0 Protocol", 3876 Netscape Communications Corp., Nov 18, 1996. 3878 [SUBGROUP] R. Zuccherato, "Methods for Avoiding the Small-Subgroup 3879 Attacks on the Diffie-Hellman Key Agreement Method for 3880 S/MIME", RFC 2785, March 2000. 3882 [TCP] Postel, J., "Transmission Control Protocol," STD 7, RFC 793, 3883 September 1981. 3885 [TIMING] Boneh, D., Brumley, D., "Remote timing attacks are 3886 practical", USENIX Security Symposium 2003. 3888 [TLS1.0] Dierks, T., and Allen, C., "The TLS Protocol, Version 1.0", 3889 RFC 2246, January 1999. 3891 [X501] ITU-T Recommendation X.501: Information Technology - Open 3892 Systems Interconnection - The Directory: Models, 1993. 3894 [X509] ITU-T Recommendation X.509 (1997 E): Information Technology - 3895 Open Systems Interconnection - "The Directory - 3896 Authentication Framework". 1988. 3898 [XDR] R. Srinivansan, Sun Microsystems, "XDR: External Data 3899 Representation Standard", RFC 1832, August 1995. 3901 Credits 3903 Working Group Chairs 3904 Win Treese 3905 EMail: treese@acm.org 3907 Eric Rescorla 3908 EMail: ekr@rtfm.com 3910 Editors 3912 Tim Dierks Eric Rescorla 3913 Independent RTFM, Inc. 3915 EMail: tim@dierks.org EMail: ekr@rtfm.com 3917 Other contributors 3919 Christopher Allen (co-editor of TLS 1.0) 3920 Alacrity Ventures 3921 ChristopherA@AlacrityManagement.com 3923 Martin Abadi 3924 University of California, Santa Cruz 3925 abadi@cs.ucsc.edu 3927 Ran Canetti 3928 IBM 3929 canetti@watson.ibm.com 3931 Taher Elgamal 3932 taher@securify.com 3933 Securify 3935 Anil Gangolli 3936 anil@busybuddha.org 3938 Kipp Hickman 3940 Phil Karlton (co-author of SSLv3) 3942 Paul Kocher (co-author of SSLv3) 3943 Cryptography Research 3944 paul@cryptography.com 3945 Hugo Krawczyk 3946 Technion Israel Institute of Technology 3947 hugo@ee.technion.ac.il 3949 Robert Relyea 3950 Netscape Communications 3951 relyea@netscape.com 3953 Jim Roskind 3954 Netscape Communications 3955 jar@netscape.com 3957 Michael Sabin 3959 Dan Simon 3960 Microsoft, Inc. 3961 dansimon@microsoft.com 3963 Tom Weinstein 3965 Comments 3967 The discussion list for the IETF TLS working group is located at the 3968 e-mail address . Information on the 3969 group and information on how to subscribe to the list is at 3970 . 3972 Archives of the list can be found at: 3973 3974 Full Copyright Statement 3976 The IETF takes no position regarding the validity or scope of any 3977 Intellectual Property Rights or other rights that might be claimed to 3978 pertain to the implementation or use of the technology described in 3979 this document or the extent to which any license under such rights 3980 might or might not be available; nor does it represent that it has 3981 made any independent effort to identify any such rights. Information 3982 on the procedures with respect to rights in RFC documents can be 3983 found in BCP 78 and BCP 79. 3985 Copies of IPR disclosures made to the IETF Secretariat and any 3986 assurances of licenses to be made available, or the result of an 3987 attempt made to obtain a general license or permission for the use of 3988 such proprietary rights by implementers or users of this 3989 specification can be obtained from the IETF on-line IPR repository at 3990 http://www.ietf.org/ipr. 3992 The IETF invites any interested party to bring to its attention any 3993 copyrights, patents or patent applications, or other proprietary 3994 rights that may cover technology that may be required to implement 3995 this standard. Please address the information to the IETF at ietf- 3996 ipr@ietf.org. 3998 Copyright Notice 3999 Copyright (C) The Internet Society (2003). This document is subject 4000 to the rights, licenses and restrictions contained in BCP 78, and 4001 except as set forth therein, the authors retain all their rights. 4003 This document and the information contained herein are provided on an 4004 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS 4005 OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET 4006 ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, 4007 INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE 4008 INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED 4009 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.