OLD | NEW |
1 /* | 1 /* |
2 * Gather (Read) entire SSL3 records from socket into buffer. | 2 * Gather (Read) entire SSL3 records from socket into buffer. |
3 * | 3 * |
4 * ***** BEGIN LICENSE BLOCK ***** | 4 * ***** BEGIN LICENSE BLOCK ***** |
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
6 * | 6 * |
7 * The contents of this file are subject to the Mozilla Public License Version | 7 * The contents of this file are subject to the Mozilla Public License Version |
8 * 1.1 (the "License"); you may not use this file except in compliance with | 8 * 1.1 (the "License"); you may not use this file except in compliance with |
9 * the License. You may obtain a copy of the License at | 9 * the License. You may obtain a copy of the License at |
10 * http://www.mozilla.org/MPL/ | 10 * http://www.mozilla.org/MPL/ |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 * and from SSL_ForceHandshake in sslsecur.c | 181 * and from SSL_ForceHandshake in sslsecur.c |
182 * and from ssl3_GatherAppDataRecord below (<- DoRecv in sslsecur.c). | 182 * and from ssl3_GatherAppDataRecord below (<- DoRecv in sslsecur.c). |
183 * | 183 * |
184 * Caller must hold the recv buf lock. | 184 * Caller must hold the recv buf lock. |
185 */ | 185 */ |
186 int | 186 int |
187 ssl3_GatherCompleteHandshake(sslSocket *ss, int flags) | 187 ssl3_GatherCompleteHandshake(sslSocket *ss, int flags) |
188 { | 188 { |
189 SSL3Ciphertext cText; | 189 SSL3Ciphertext cText; |
190 int rv; | 190 int rv; |
| 191 PRBool canFalseStart = PR_FALSE; |
191 | 192 |
192 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); | 193 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); |
193 do { | 194 do { |
194 /* bring in the next sslv3 record. */ | 195 /* bring in the next sslv3 record. */ |
195 rv = ssl3_GatherData(ss, &ss->gs, flags); | 196 rv = ssl3_GatherData(ss, &ss->gs, flags); |
196 if (rv <= 0) { | 197 if (rv <= 0) { |
197 return rv; | 198 return rv; |
198 } | 199 } |
199 | 200 |
200 /* decipher it, and handle it if it's a handshake. | 201 /* decipher it, and handle it if it's a handshake. |
201 * If it's application data, ss->gs.buf will not be empty upon return. | 202 * If it's application data, ss->gs.buf will not be empty upon return. |
202 */ | 203 */ |
203 cText.type = (SSL3ContentType)ss->gs.hdr[0]; | 204 cText.type = (SSL3ContentType)ss->gs.hdr[0]; |
204 cText.version = (ss->gs.hdr[1] << 8) | ss->gs.hdr[2]; | 205 cText.version = (ss->gs.hdr[1] << 8) | ss->gs.hdr[2]; |
205 cText.buf = &ss->gs.inbuf; | 206 cText.buf = &ss->gs.inbuf; |
206 rv = ssl3_HandleRecord(ss, &cText, &ss->gs.buf); | 207 rv = ssl3_HandleRecord(ss, &cText, &ss->gs.buf); |
207 if (rv < 0) { | 208 if (rv < 0) { |
208 return ss->recvdCloseNotify ? 0 : rv; | 209 return ss->recvdCloseNotify ? 0 : rv; |
209 } | 210 } |
210 } while (ss->ssl3.hs.ws != idle_handshake && ss->gs.buf.len == 0); | 211 |
| 212 » if (ss->opt.enableFalseStart) { |
| 213 » ssl_GetSSL3HandshakeLock(ss); |
| 214 » canFalseStart = (ss->ssl3.hs.ws == wait_change_cipher || |
| 215 » » » ss->ssl3.hs.ws == wait_new_session_ticket) && |
| 216 » » ssl3_CanFalseStart(ss); |
| 217 » ssl_ReleaseSSL3HandshakeLock(ss); |
| 218 » } |
| 219 } while (ss->ssl3.hs.ws != idle_handshake && |
| 220 !canFalseStart && |
| 221 ss->gs.buf.len == 0); |
211 | 222 |
212 ss->gs.readOffset = 0; | 223 ss->gs.readOffset = 0; |
213 ss->gs.writeOffset = ss->gs.buf.len; | 224 ss->gs.writeOffset = ss->gs.buf.len; |
214 return 1; | 225 return 1; |
215 } | 226 } |
216 | 227 |
217 /* Repeatedly gather in a record and when complete, Handle that record. | 228 /* Repeatedly gather in a record and when complete, Handle that record. |
218 * Repeat this until some application data is received. | 229 * Repeat this until some application data is received. |
219 * | 230 * |
220 * Returns 1 when application data is available. | 231 * Returns 1 when application data is available. |
221 * Returns 0 if ssl3_GatherData hits EOF. | 232 * Returns 0 if ssl3_GatherData hits EOF. |
222 * Returns -1 on read error, or PR_WOULD_BLOCK_ERROR, or handleRecord error. | 233 * Returns -1 on read error, or PR_WOULD_BLOCK_ERROR, or handleRecord error. |
223 * Returns -2 on SECWouldBlock return from ssl3_HandleRecord. | 234 * Returns -2 on SECWouldBlock return from ssl3_HandleRecord. |
224 * | 235 * |
225 * Called from DoRecv in sslsecur.c | 236 * Called from DoRecv in sslsecur.c |
226 * Caller must hold the recv buf lock. | 237 * Caller must hold the recv buf lock. |
227 */ | 238 */ |
228 int | 239 int |
229 ssl3_GatherAppDataRecord(sslSocket *ss, int flags) | 240 ssl3_GatherAppDataRecord(sslSocket *ss, int flags) |
230 { | 241 { |
231 int rv; | 242 int rv; |
232 | 243 |
233 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); | 244 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); |
234 do { | 245 do { |
235 rv = ssl3_GatherCompleteHandshake(ss, flags); | 246 rv = ssl3_GatherCompleteHandshake(ss, flags); |
236 } while (rv > 0 && ss->gs.buf.len == 0); | 247 } while (rv > 0 && ss->gs.buf.len == 0); |
237 | 248 |
238 return rv; | 249 return rv; |
239 } | 250 } |
OLD | NEW |