OLD | NEW |
1 Index: net/third_party/nss/ssl/sslimpl.h | 1 Index: mozilla/security/nss/lib/ssl/sslimpl.h |
2 =================================================================== | 2 =================================================================== |
3 --- net/third_party/nss/ssl/sslimpl.h» (revision 146623) | 3 RCS file: /cvsroot/mozilla/security/nss/lib/ssl/sslimpl.h,v |
4 +++ net/third_party/nss/ssl/sslimpl.h» (working copy) | 4 retrieving revision 1.106 |
5 @@ -294,6 +294,8 @@ | 5 diff -u -p -r1.106 sslimpl.h |
| 6 --- mozilla/security/nss/lib/ssl/sslimpl.h» 14 Jun 2012 19:03:29 -0000»
1.106 |
| 7 +++ mozilla/security/nss/lib/ssl/sslimpl.h» 17 Aug 2012 02:10:02 -0000 |
| 8 @@ -251,6 +251,8 @@ struct sslSocketOpsStr { |
6 #define ssl_SEND_FLAG_NO_BUFFER 0x20000000 | 9 #define ssl_SEND_FLAG_NO_BUFFER 0x20000000 |
7 #define ssl_SEND_FLAG_USE_EPOCH 0x10000000 /* DTLS only */ | 10 #define ssl_SEND_FLAG_USE_EPOCH 0x10000000 /* DTLS only */ |
8 #define ssl_SEND_FLAG_NO_RETRANSMIT 0x08000000 /* DTLS only */ | 11 #define ssl_SEND_FLAG_NO_RETRANSMIT 0x08000000 /* DTLS only */ |
9 +#define ssl_SEND_FLAG_CAP_RECORD_VERSION \ | 12 +#define ssl_SEND_FLAG_CAP_RECORD_VERSION \ |
10 + 0x04000000 /* TLS only */ | 13 + 0x04000000 /* TLS only */ |
11 #define ssl_SEND_FLAG_MASK 0x7f000000 | 14 #define ssl_SEND_FLAG_MASK 0x7f000000 |
12 | 15 |
13 /* | 16 /* |
14 @@ -1414,6 +1416,7 @@ | 17 @@ -1327,6 +1329,7 @@ extern SECStatus |
15 ssl3_CompressMACEncryptRecord(ssl3CipherSpec * cwSpec, | 18 ssl3_CompressMACEncryptRecord(ssl3CipherSpec * cwSpec, |
16 PRBool isServer, | 19 PRBool isServer, |
17 PRBool isDTLS, | 20 PRBool isDTLS, |
18 + PRBool capRecordVersion, | 21 + PRBool capRecordVersion, |
19 SSL3ContentType type, | 22 SSL3ContentType type, |
20 const SSL3Opaque * pIn, | 23 const SSL3Opaque * pIn, |
21 PRUint32 contentLen, | 24 PRUint32 contentLen, |
22 Index: net/third_party/nss/ssl/ssl3con.c | 25 Index: mozilla/security/nss/lib/ssl/ssl3con.c |
23 =================================================================== | 26 =================================================================== |
24 --- net/third_party/nss/ssl/ssl3con.c» (revision 146623) | 27 RCS file: /cvsroot/mozilla/security/nss/lib/ssl/ssl3con.c,v |
25 +++ net/third_party/nss/ssl/ssl3con.c» (working copy) | 28 retrieving revision 1.186 |
26 @@ -2057,6 +2057,7 @@ | 29 diff -u -p -r1.186 ssl3con.c |
| 30 --- mozilla/security/nss/lib/ssl/ssl3con.c» 30 Jul 2012 00:47:36 -0000»
1.186 |
| 31 +++ mozilla/security/nss/lib/ssl/ssl3con.c» 17 Aug 2012 02:10:02 -0000 |
| 32 @@ -2060,6 +2060,7 @@ SECStatus |
27 ssl3_CompressMACEncryptRecord(ssl3CipherSpec * cwSpec, | 33 ssl3_CompressMACEncryptRecord(ssl3CipherSpec * cwSpec, |
28 PRBool isServer, | 34 PRBool isServer, |
29 PRBool isDTLS, | 35 PRBool isDTLS, |
30 + PRBool capRecordVersion, | 36 + PRBool capRecordVersion, |
31 SSL3ContentType type, | 37 SSL3ContentType type, |
32 const SSL3Opaque * pIn, | 38 const SSL3Opaque * pIn, |
33 PRUint32 contentLen, | 39 PRUint32 contentLen, |
34 @@ -2216,8 +2217,13 @@ | 40 @@ -2219,8 +2220,13 @@ ssl3_CompressMACEncryptRecord(ssl3Cipher |
35 wrBuf->buf[11] = MSB(cipherBytes); | 41 wrBuf->buf[11] = MSB(cipherBytes); |
36 wrBuf->buf[12] = LSB(cipherBytes); | 42 wrBuf->buf[12] = LSB(cipherBytes); |
37 } else { | 43 } else { |
38 - wrBuf->buf[1] = MSB(cwSpec->version); | 44 - wrBuf->buf[1] = MSB(cwSpec->version); |
39 - wrBuf->buf[2] = LSB(cwSpec->version); | 45 - wrBuf->buf[2] = LSB(cwSpec->version); |
40 + SSL3ProtocolVersion version = cwSpec->version; | 46 + SSL3ProtocolVersion version = cwSpec->version; |
41 + | 47 + |
42 + if (capRecordVersion) { | 48 + if (capRecordVersion) { |
43 + version = PR_MIN(SSL_LIBRARY_VERSION_TLS_1_0, version); | 49 + version = PR_MIN(SSL_LIBRARY_VERSION_TLS_1_0, version); |
44 + } | 50 + } |
45 + wrBuf->buf[1] = MSB(version); | 51 + wrBuf->buf[1] = MSB(version); |
46 + wrBuf->buf[2] = LSB(version); | 52 + wrBuf->buf[2] = LSB(version); |
47 wrBuf->buf[3] = MSB(cipherBytes); | 53 wrBuf->buf[3] = MSB(cipherBytes); |
48 wrBuf->buf[4] = LSB(cipherBytes); | 54 wrBuf->buf[4] = LSB(cipherBytes); |
49 } | 55 } |
50 @@ -2247,7 +2253,14 @@ | 56 @@ -2250,7 +2256,14 @@ ssl3_CompressMACEncryptRecord(ssl3Cipher |
51 * all ciphertext into the pending ciphertext buffer. | 57 * all ciphertext into the pending ciphertext buffer. |
52 * ssl_SEND_FLAG_USE_EPOCH (for DTLS) | 58 * ssl_SEND_FLAG_USE_EPOCH (for DTLS) |
53 * Forces the use of the provided epoch | 59 * Forces the use of the provided epoch |
54 - * | 60 - * |
55 + * ssl_SEND_FLAG_CAP_RECORD_VERSION | 61 + * ssl_SEND_FLAG_CAP_RECORD_VERSION |
56 + * Caps the record layer version number of TLS ClientHello to { 3, 1 } | 62 + * Caps the record layer version number of TLS ClientHello to { 3, 1 } |
57 + * (TLS 1.0). Some TLS 1.0 servers (which seem to use F5 BIG-IP) ignore | 63 + * (TLS 1.0). Some TLS 1.0 servers (which seem to use F5 BIG-IP) ignore |
58 + * ClientHello.client_version and use the record layer version number | 64 + * ClientHello.client_version and use the record layer version number |
59 + * (TLSPlaintext.version) instead when negotiating protocol versions. In | 65 + * (TLSPlaintext.version) instead when negotiating protocol versions. In |
60 + * addition, if the record layer version number of ClientHello is { 3, 2 } | 66 + * addition, if the record layer version number of ClientHello is { 3, 2 } |
61 + * (TLS 1.1) or higher, these servers reset the TCP connections. Set this | 67 + * (TLS 1.1) or higher, these servers reset the TCP connections. Set this |
62 + * flag to work around such servers. | 68 + * flag to work around such servers. |
63 */ | 69 */ |
64 PRInt32 | 70 PRInt32 |
65 ssl3_SendRecord( sslSocket * ss, | 71 ssl3_SendRecord( sslSocket * ss, |
66 @@ -2260,6 +2273,7 @@ | 72 @@ -2263,6 +2276,7 @@ ssl3_SendRecord( sslSocket * ss |
67 sslBuffer * wrBuf = &ss->sec.writeBuf; | 73 sslBuffer * wrBuf = &ss->sec.writeBuf; |
68 SECStatus rv; | 74 SECStatus rv; |
69 PRInt32 totalSent = 0; | 75 PRInt32 totalSent = 0; |
70 + PRBool capRecordVersion; | 76 + PRBool capRecordVersion; |
71 | 77 |
72 SSL_TRC(3, ("%d: SSL3[%d] SendRecord type: %s nIn=%d", | 78 SSL_TRC(3, ("%d: SSL3[%d] SendRecord type: %s nIn=%d", |
73 SSL_GETPID(), ss->fd, ssl3_DecodeContentType(type), | 79 SSL_GETPID(), ss->fd, ssl3_DecodeContentType(type), |
74 @@ -2268,6 +2282,16 @@ | 80 @@ -2271,6 +2285,17 @@ ssl3_SendRecord( sslSocket * ss |
75 | 81 |
76 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) ); | 82 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) ); |
77 | 83 |
78 + capRecordVersion = ((flags & ssl_SEND_FLAG_CAP_RECORD_VERSION) != 0); | 84 + capRecordVersion = ((flags & ssl_SEND_FLAG_CAP_RECORD_VERSION) != 0); |
79 + | 85 + |
80 + if (capRecordVersion) { | 86 + if (capRecordVersion) { |
81 +» /* ssl_SEND_FLAG_CAP_RECORD_VERSION can only be used with | 87 +» /* ssl_SEND_FLAG_CAP_RECORD_VERSION can only be used with the |
82 +» * TLS ClientHello. */ | 88 +» * TLS initial ClientHello. */ |
83 + PORT_Assert(!IS_DTLS(ss)); | 89 + PORT_Assert(!IS_DTLS(ss)); |
| 90 + PORT_Assert(!ss->firstHsDone); |
84 + PORT_Assert(type == content_handshake); | 91 + PORT_Assert(type == content_handshake); |
85 + PORT_Assert(ss->ssl3.hs.ws == wait_server_hello); | 92 + PORT_Assert(ss->ssl3.hs.ws == wait_server_hello); |
86 + } | 93 + } |
87 + | 94 + |
88 if (ss->ssl3.initialized == PR_FALSE) { | 95 if (ss->ssl3.initialized == PR_FALSE) { |
89 /* This can happen on a server if the very first incoming record | 96 /* This can happen on a server if the very first incoming record |
90 ** looks like a defective ssl3 record (e.g. too long), and we're | 97 ** looks like a defective ssl3 record (e.g. too long), and we're |
91 @@ -2324,7 +2348,8 @@ | 98 @@ -2327,7 +2352,8 @@ ssl3_SendRecord( sslSocket * ss |
92 | 99 |
93 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, | 100 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, |
94 ss->sec.isServer, IS_DTLS(ss), | 101 ss->sec.isServer, IS_DTLS(ss), |
95 - type, pIn, 1, wrBuf); | 102 - type, pIn, 1, wrBuf); |
96 + capRecordVersion, type, pIn, | 103 + capRecordVersion, type, pIn, |
97 + 1, wrBuf); | 104 + 1, wrBuf); |
98 if (rv != SECSuccess) | 105 if (rv != SECSuccess) |
99 goto spec_locked_loser; | 106 goto spec_locked_loser; |
100 | 107 |
101 @@ -2337,7 +2362,8 @@ | 108 @@ -2340,7 +2366,8 @@ ssl3_SendRecord( sslSocket * ss |
102 | 109 |
103 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, | 110 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, |
104 ss->sec.isServer, IS_DTLS(ss), | 111 ss->sec.isServer, IS_DTLS(ss), |
105 - type, pIn + 1, contentLen - 1, | 112 - type, pIn + 1, contentLen - 1, |
106 + capRecordVersion, type, | 113 + capRecordVersion, type, |
107 + pIn + 1, contentLen - 1, | 114 + pIn + 1, contentLen - 1, |
108 &secondRecord); | 115 &secondRecord); |
109 if (rv == SECSuccess) { | 116 if (rv == SECSuccess) { |
110 PRINT_BUF(50, (ss, "send (encrypted) record data [2/2]:", | 117 PRINT_BUF(50, (ss, "send (encrypted) record data [2/2]:", |
111 @@ -2349,6 +2375,7 @@ | 118 @@ -2352,6 +2379,7 @@ ssl3_SendRecord( sslSocket * ss |
112 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, | 119 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, |
113 ss->sec.isServer, | 120 ss->sec.isServer, |
114 IS_DTLS(ss), | 121 IS_DTLS(ss), |
115 + capRecordVersion, | 122 + capRecordVersion, |
116 type, pIn, | 123 type, pIn, |
117 contentLen, wrBuf); | 124 contentLen, wrBuf); |
118 } else { | 125 } else { |
119 @@ -2560,6 +2587,8 @@ | 126 @@ -2563,6 +2591,8 @@ ssl3_FlushHandshake(sslSocket *ss, PRInt |
120 static SECStatus | 127 static SECStatus |
121 ssl3_FlushHandshakeMessages(sslSocket *ss, PRInt32 flags) | 128 ssl3_FlushHandshakeMessages(sslSocket *ss, PRInt32 flags) |
122 { | 129 { |
123 + static const PRInt32 allowedFlags = ssl_SEND_FLAG_FORCE_INTO_BUFFER | | 130 + static const PRInt32 allowedFlags = ssl_SEND_FLAG_FORCE_INTO_BUFFER | |
124 + ssl_SEND_FLAG_CAP_RECORD_VERSION; | 131 + ssl_SEND_FLAG_CAP_RECORD_VERSION; |
125 PRInt32 rv = SECSuccess; | 132 PRInt32 rv = SECSuccess; |
126 | 133 |
127 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); | 134 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); |
128 @@ -2568,9 +2597,9 @@ | 135 @@ -2571,9 +2601,9 @@ ssl3_FlushHandshakeMessages(sslSocket *s |
129 if (!ss->sec.ci.sendBuf.buf || !ss->sec.ci.sendBuf.len) | 136 if (!ss->sec.ci.sendBuf.buf || !ss->sec.ci.sendBuf.len) |
130 return rv; | 137 return rv; |
131 | 138 |
132 - /* only this flag is allowed */ | 139 - /* only this flag is allowed */ |
133 - PORT_Assert(!(flags & ~ssl_SEND_FLAG_FORCE_INTO_BUFFER)); | 140 - PORT_Assert(!(flags & ~ssl_SEND_FLAG_FORCE_INTO_BUFFER)); |
134 - if ((flags & ~ssl_SEND_FLAG_FORCE_INTO_BUFFER) != 0) { | 141 - if ((flags & ~ssl_SEND_FLAG_FORCE_INTO_BUFFER) != 0) { |
135 + /* only these flags are allowed */ | 142 + /* only these flags are allowed */ |
136 + PORT_Assert(!(flags & ~allowedFlags)); | 143 + PORT_Assert(!(flags & ~allowedFlags)); |
137 + if ((flags & ~allowedFlags) != 0) { | 144 + if ((flags & ~allowedFlags) != 0) { |
138 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 145 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
139 rv = SECFailure; | 146 rv = SECFailure; |
140 } else { | 147 } else { |
141 @@ -3981,8 +4010,10 @@ | 148 @@ -4000,8 +4030,10 @@ ssl3_SendClientHello(sslSocket *ss, PRBo |
142 int num_suites; | 149 int num_suites; |
143 int actual_count = 0; | 150 int actual_count = 0; |
144 PRBool isTLS = PR_FALSE; | 151 PRBool isTLS = PR_FALSE; |
145 + PRBool serverVersionKnown = PR_FALSE; | 152 + PRBool requestingResume = PR_FALSE; |
146 PRInt32 total_exten_len = 0; | 153 PRInt32 total_exten_len = 0; |
147 unsigned numCompressionMethods; | 154 unsigned numCompressionMethods; |
148 + PRInt32 flags; | 155 + PRInt32 flags; |
149 | 156 |
150 SSL_TRC(3, ("%d: SSL3[%d]: send client_hello handshake", SSL_GETPID(), | 157 SSL_TRC(3, ("%d: SSL3[%d]: send client_hello handshake", SSL_GETPID(), |
151 ss->fd)); | 158 ss->fd)); |
152 @@ -4070,6 +4101,7 @@ | 159 @@ -4090,6 +4122,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo |
153 } | 160 } |
154 | 161 |
155 if (sid) { | 162 if (sid) { |
156 +» serverVersionKnown = PR_TRUE; | 163 +» requestingResume = PR_TRUE; |
157 SSL_AtomicIncrementLong(& ssl3stats.sch_sid_cache_hits ); | 164 SSL_AtomicIncrementLong(& ssl3stats.sch_sid_cache_hits ); |
158 | 165 |
159 /* Are we attempting a stateless session resume? */ | 166 /* Are we attempting a stateless session resume? */ |
160 @@ -4305,7 +4337,11 @@ | 167 @@ -4325,7 +4358,11 @@ ssl3_SendClientHello(sslSocket *ss, PRBo |
161 ssl_renegotiation_info_xtn; | 168 ssl_renegotiation_info_xtn; |
162 } | 169 } |
163 | 170 |
164 - rv = ssl3_FlushHandshake(ss, 0); | 171 - rv = ssl3_FlushHandshake(ss, 0); |
165 + flags = 0; | 172 + flags = 0; |
166 + if (!serverVersionKnown && !IS_DTLS(ss)) { | 173 + if (!ss->firstHsDone && !requestingResume && !IS_DTLS(ss)) { |
167 + flags |= ssl_SEND_FLAG_CAP_RECORD_VERSION; | 174 + flags |= ssl_SEND_FLAG_CAP_RECORD_VERSION; |
168 + } | 175 + } |
169 + rv = ssl3_FlushHandshake(ss, flags); | 176 + rv = ssl3_FlushHandshake(ss, flags); |
170 if (rv != SECSuccess) { | 177 if (rv != SECSuccess) { |
171 return rv; /* error code set by ssl3_FlushHandshake */ | 178 return rv; /* error code set by ssl3_FlushHandshake */ |
172 } | 179 } |
173 Index: net/third_party/nss/ssl/dtls1con.c | 180 Index: mozilla/security/nss/lib/ssl/dtlscon.c |
174 =================================================================== | 181 =================================================================== |
175 --- net/third_party/nss/ssl/dtls1con.c» (revision 146623) | 182 RCS file: /cvsroot/mozilla/security/nss/lib/ssl/dtlscon.c,v |
176 +++ net/third_party/nss/ssl/dtls1con.c» (working copy) | 183 retrieving revision 1.3 |
177 @@ -834,7 +834,8 @@ | 184 diff -u -p -r1.3 dtlscon.c |
| 185 --- mozilla/security/nss/lib/ssl/dtlscon.c» 4 Jul 2012 15:21:47 -0000»
1.3 |
| 186 +++ mozilla/security/nss/lib/ssl/dtlscon.c» 17 Aug 2012 02:10:02 -0000 |
| 187 @@ -802,7 +802,8 @@ dtls_CompressMACEncryptRecord(sslSocket |
178 | 188 |
179 if (cwSpec) { | 189 if (cwSpec) { |
180 rv = ssl3_CompressMACEncryptRecord(cwSpec, ss->sec.isServer, PR_TRUE, | 190 rv = ssl3_CompressMACEncryptRecord(cwSpec, ss->sec.isServer, PR_TRUE, |
181 - type, pIn, contentLen, wrBuf); | 191 - type, pIn, contentLen, wrBuf); |
182 + PR_FALSE, type, pIn, contentLen, | 192 + PR_FALSE, type, pIn, contentLen, |
183 + wrBuf); | 193 + wrBuf); |
184 } else { | 194 } else { |
185 PR_NOT_REACHED("Couldn't find a cipher spec matching epoch"); | 195 PR_NOT_REACHED("Couldn't find a cipher spec matching epoch"); |
186 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); | 196 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); |
OLD | NEW |