Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: net/third_party/nss/ssl/ssl3con.c

Issue 27254004: Make SSL False Start work with asynchronous certificate validation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: New patch from Brian Smith on 2013-10-24 13:52 PDT Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* 2 /*
3 * SSL3 Protocol 3 * SSL3 Protocol
4 * 4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public 5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 8
9 /* TODO(ekr): Implement HelloVerifyRequest on server side. OK for now. */ 9 /* TODO(ekr): Implement HelloVerifyRequest on server side. OK for now. */
10 10
(...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after
2883 PRInt32 flags) 2883 PRInt32 flags)
2884 { 2884 {
2885 sslBuffer * wrBuf = &ss->sec.writeBuf; 2885 sslBuffer * wrBuf = &ss->sec.writeBuf;
2886 SECStatus rv; 2886 SECStatus rv;
2887 PRInt32 totalSent = 0; 2887 PRInt32 totalSent = 0;
2888 PRBool capRecordVersion; 2888 PRBool capRecordVersion;
2889 2889
2890 SSL_TRC(3, ("%d: SSL3[%d] SendRecord type: %s nIn=%d", 2890 SSL_TRC(3, ("%d: SSL3[%d] SendRecord type: %s nIn=%d",
2891 SSL_GETPID(), ss->fd, ssl3_DecodeContentType(type), 2891 SSL_GETPID(), ss->fd, ssl3_DecodeContentType(type),
2892 nIn)); 2892 nIn));
2893 PRINT_BUF(3, (ss, "Send record (plain text)", pIn, nIn)); 2893 PRINT_BUF(50, (ss, "Send record (plain text)", pIn, nIn));
2894 2894
2895 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) ); 2895 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) );
2896 2896
2897 capRecordVersion = ((flags & ssl_SEND_FLAG_CAP_RECORD_VERSION) != 0); 2897 capRecordVersion = ((flags & ssl_SEND_FLAG_CAP_RECORD_VERSION) != 0);
2898 2898
2899 if (capRecordVersion) { 2899 if (capRecordVersion) {
2900 /* ssl_SEND_FLAG_CAP_RECORD_VERSION can only be used with the 2900 /* ssl_SEND_FLAG_CAP_RECORD_VERSION can only be used with the
2901 * TLS initial ClientHello. */ 2901 * TLS initial ClientHello. */
2902 PORT_Assert(!IS_DTLS(ss)); 2902 PORT_Assert(!IS_DTLS(ss));
2903 PORT_Assert(!ss->firstHsDone); 2903 PORT_Assert(!ss->firstHsDone);
(...skipping 4433 matching lines...) Expand 10 before | Expand all | Expand 10 after
7337 } 7337 }
7338 if (certChain) { 7338 if (certChain) {
7339 CERT_DestroyCertificateList(certChain); 7339 CERT_DestroyCertificateList(certChain);
7340 } 7340 }
7341 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); 7341 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
7342 rv = SECFailure; 7342 rv = SECFailure;
7343 } 7343 }
7344 return rv; 7344 return rv;
7345 } 7345 }
7346 7346
7347 static SECStatus
7348 ssl3_CheckFalseStart(sslSocket *ss)
7349 {
7350 SECStatus rv;
7351 PRBool maybeFalseStart = PR_FALSE;
7352
7353 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) );
7354 PORT_Assert( !ss->ssl3.hs.authCertificatePending );
7355 PORT_Assert( !ss->ssl3.hs.canFalseStart );
7356
7357 if (!ss->canFalseStartCallback) {
7358 SSL_TRC(3, ("%d: SSL[%d]: no false start callback so no false start",
7359 SSL_GETPID(), ss->fd));
7360 } else {
7361 /* An attacker can control the selected ciphersuite so we only wish to
wtc 2013/10/29 01:21:51 Nit: you can still declare maybeFalseStart in this
briansmith 2013/10/29 21:00:13 Done. Also did the same for rv.
7362 * do False Start in the case that the selected ciphersuite is
7363 * sufficiently strong that the attack can gain no advantage.
7364 * Therefore we always require an 80-bit cipher. */
7365 ssl_GetSpecReadLock(ss);
7366 maybeFalseStart = ss->ssl3.cwSpec->cipher_def->secret_key_size >= 10;
7367 ssl_ReleaseSpecReadLock(ss);
7368
7369 if (!maybeFalseStart) {
7370 SSL_TRC(3, ("%d: SSL[%d]: no false start due to weak cipher",
7371 SSL_GETPID(), ss->fd));
7372 } else {
7373 rv = (ss->canFalseStartCallback)(ss->fd,
7374 ss->canFalseStartCallbackData,
7375 &ss->ssl3.hs.canFalseStart);
7376 if (rv == SECSuccess) {
7377 SSL_TRC(3, ("%d: SSL[%d]: false start callback returned %s",
7378 SSL_GETPID(), ss->fd,
7379 ss->ssl3.hs.canFalseStart ? "TRUE" : "FALSE"));
7380 } else {
7381 SSL_TRC(3, ("%d: SSL[%d]: false start callback failed (%s)",
7382 SSL_GETPID(), ss->fd,
7383 PR_ErrorToName(PR_GetError())));
7384 }
7385 return rv;
7386 }
7387 }
7388
7389 ss->ssl3.hs.canFalseStart = PR_FALSE;
7390 return SECSuccess;
7391 }
7392
7347 PRBool 7393 PRBool
7348 ssl3_CanFalseStart(sslSocket *ss) { 7394 ssl3_WaitingForStartOfServerSecondRound(sslSocket *ss)
7349 PRBool rv; 7395 {
7396 PRBool result = PR_FALSE;
7350 7397
7351 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); 7398 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) );
7352 7399
7353 /* XXX: does not take into account whether we are waiting for 7400 switch (ss->ssl3.hs.ws) {
7354 * SSL_AuthCertificateComplete or SSL_RestartHandshakeAfterCertReq. If/when 7401 case wait_new_session_ticket:
7355 * that is done, this function could return different results each time it 7402 result = PR_TRUE;
7356 * would be called. 7403 break;
7357 */ 7404 case wait_change_cipher:
7405 result = !ssl3_ExtensionNegotiated(ss, ssl_session_ticket_xtn);
7406 break;
7407 case wait_finished:
7408 break;
7409 default:
7410 PR_NOT_REACHED("ssl3_WaitingForStartOfServerSecondRound");
7411 }
7358 7412
7359 ssl_GetSpecReadLock(ss); 7413 return result;
7360 rv = ss->opt.enableFalseStart &&
7361 » !ss->sec.isServer &&
7362 » !ss->ssl3.hs.isResuming &&
7363 » ss->ssl3.cwSpec &&
7364
7365 » /* An attacker can control the selected ciphersuite so we only wish to
7366 » * do False Start in the case that the selected ciphersuite is
7367 » * sufficiently strong that the attack can gain no advantage.
7368 » * Therefore we require an 80-bit cipher and a forward-secret key
7369 » * exchange. */
7370 » ss->ssl3.cwSpec->cipher_def->secret_key_size >= 10 &&
7371 » (ss->ssl3.hs.kea_def->kea == kea_dhe_dss ||
7372 » ss->ssl3.hs.kea_def->kea == kea_dhe_rsa ||
7373 » ss->ssl3.hs.kea_def->kea == kea_ecdhe_ecdsa ||
7374 » ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa);
7375 ssl_ReleaseSpecReadLock(ss);
7376 return rv;
7377 } 7414 }
7378 7415
7379 static SECStatus ssl3_SendClientSecondRound(sslSocket *ss); 7416 static SECStatus ssl3_SendClientSecondRound(sslSocket *ss);
7380 7417
7381 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete 7418 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete
7382 * ssl3 Server Hello Done message. 7419 * ssl3 Server Hello Done message.
7383 * Caller must hold Handshake and RecvBuf locks. 7420 * Caller must hold Handshake and RecvBuf locks.
7384 */ 7421 */
7385 static SECStatus 7422 static SECStatus
7386 ssl3_HandleServerHelloDone(sslSocket *ss) 7423 ssl3_HandleServerHelloDone(sslSocket *ss)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
7456 * before using the cipher specs agreed upon for that handshake for 7493 * before using the cipher specs agreed upon for that handshake for
7457 * application data. 7494 * application data.
7458 */ 7495 */
7459 if (ss->ssl3.hs.restartTarget) { 7496 if (ss->ssl3.hs.restartTarget) {
7460 PR_NOT_REACHED("unexpected ss->ssl3.hs.restartTarget"); 7497 PR_NOT_REACHED("unexpected ss->ssl3.hs.restartTarget");
7461 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); 7498 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
7462 return SECFailure; 7499 return SECFailure;
7463 } 7500 }
7464 if (ss->ssl3.hs.authCertificatePending && 7501 if (ss->ssl3.hs.authCertificatePending &&
7465 (sendClientCert || ss->ssl3.sendEmptyCert || ss->firstHsDone)) { 7502 (sendClientCert || ss->ssl3.sendEmptyCert || ss->firstHsDone)) {
7503 SSL_TRC(3, ("%d: SSL3[%p]: deferring ssl3_SendClientSecondRound because"
7504 " certificate authentication is still pending.",
7505 SSL_GETPID(), ss->fd));
7466 ss->ssl3.hs.restartTarget = ssl3_SendClientSecondRound; 7506 ss->ssl3.hs.restartTarget = ssl3_SendClientSecondRound;
7467 return SECWouldBlock; 7507 return SECWouldBlock;
7468 } 7508 }
7469 7509
7470 ssl_GetXmitBufLock(ss); /*******************************/ 7510 ssl_GetXmitBufLock(ss); /*******************************/
7471 7511
7472 if (ss->ssl3.sendEmptyCert) { 7512 if (ss->ssl3.sendEmptyCert) {
7473 ss->ssl3.sendEmptyCert = PR_FALSE; 7513 ss->ssl3.sendEmptyCert = PR_FALSE;
7474 rv = ssl3_SendEmptyCertificate(ss); 7514 rv = ssl3_SendEmptyCertificate(ss);
7475 /* Don't send verify */ 7515 /* Don't send verify */
(...skipping 17 matching lines...) Expand all
7493 if (rv != SECSuccess) { 7533 if (rv != SECSuccess) {
7494 goto loser; /* err is set. */ 7534 goto loser; /* err is set. */
7495 } 7535 }
7496 } 7536 }
7497 7537
7498 rv = ssl3_SendChangeCipherSpecs(ss); 7538 rv = ssl3_SendChangeCipherSpecs(ss);
7499 if (rv != SECSuccess) { 7539 if (rv != SECSuccess) {
7500 goto loser; /* err code was set. */ 7540 goto loser; /* err code was set. */
7501 } 7541 }
7502 7542
7503 /* XXX: If the server's certificate hasn't been authenticated by this 7543 /* This must be done after we've set ss->ssl3.cwSpec in
7504 * point, then we may be leaking this NPN message to an attacker. 7544 * ssl3_SendChangeCipherSpecs because SSL_GetChannelInfo uses information
7545 * from cwSpec. This must be done before we call ssl3_CheckFalseStart
7546 * because the false start callback (if any) may need the information from
7547 * the functions that depend on this being set.
7505 */ 7548 */
7549 ss->enoughFirstHsDone = PR_TRUE;
7550
7506 if (!ss->firstHsDone) { 7551 if (!ss->firstHsDone) {
7552 /* XXX: If the server's certificate hasn't been authenticated by this
7553 * point, then we may be leaking this NPN message to an attacker.
7554 */
7507 rv = ssl3_SendNextProto(ss); 7555 rv = ssl3_SendNextProto(ss);
7508 if (rv != SECSuccess) { 7556 if (rv != SECSuccess) {
7509 goto loser; /* err code was set. */ 7557 goto loser; /* err code was set. */
7510 } 7558 }
7511 } 7559 }
7560
7512 rv = ssl3_SendEncryptedExtensions(ss); 7561 rv = ssl3_SendEncryptedExtensions(ss);
7513 if (rv != SECSuccess) { 7562 if (rv != SECSuccess) {
7514 goto loser; /* err code was set. */ 7563 goto loser; /* err code was set. */
7515 } 7564 }
7516 7565
7566 if (!ss->firstHsDone) {
7567 if (ss->opt.enableFalseStart) {
7568 if (!ss->ssl3.hs.authCertificatePending) {
7569 /* When we fix bug 589047, we will need to know whether we are
7570 * false starting before we try to flush the client second
7571 * round to the network. With that in mind, we purposefully
7572 * call ssl3_CheckFalseStart before calling ssl3_SendFinished,
7573 * which includes a call to ssl3_FlushHandshake, so that
7574 * no application develops a reliance on such flushing being
7575 * done before its false start callback is called.
7576 */
7577 ssl_ReleaseXmitBufLock(ss);
7578 rv = ssl3_CheckFalseStart(ss);
7579 ssl_GetXmitBufLock(ss);
7580 if (rv != SECSuccess) {
7581 goto loser;
7582 }
7583 } else {
7584 /* The certificate authentication and the server's Finished
7585 * message are racing each other. If the certificate
7586 * authentication wins, then we will try to false start in
7587 * ssl3_AuthCertificateComplete.
7588 */
7589 SSL_TRC(3, ("%d: SSL3[%p]: deferring false start check because"
7590 " certificate authentication is still pending.",
7591 SSL_GETPID(), ss->fd));
7592 }
7593 }
7594 }
7595
7517 rv = ssl3_SendFinished(ss, 0); 7596 rv = ssl3_SendFinished(ss, 0);
7518 if (rv != SECSuccess) { 7597 if (rv != SECSuccess) {
7519 goto loser; /* err code was set. */ 7598 goto loser; /* err code was set. */
7520 } 7599 }
7521 7600
7522 ssl_ReleaseXmitBufLock(ss); /*******************************/ 7601 ssl_ReleaseXmitBufLock(ss); /*******************************/
7523 7602
7524 if (ssl3_ExtensionNegotiated(ss, ssl_session_ticket_xtn)) 7603 if (ssl3_ExtensionNegotiated(ss, ssl_session_ticket_xtn))
7525 ss->ssl3.hs.ws = wait_new_session_ticket; 7604 ss->ssl3.hs.ws = wait_new_session_ticket;
7526 else 7605 else
7527 ss->ssl3.hs.ws = wait_change_cipher; 7606 ss->ssl3.hs.ws = wait_change_cipher;
7528 7607
7529 /* Do the handshake callback for sslv3 here, if we can false start. */ 7608 PORT_Assert(ssl3_WaitingForStartOfServerSecondRound(ss));
wtc 2013/10/29 01:21:51 Nit: this assertion will never fail.
briansmith 2013/10/29 21:00:13 Ideally no assertions will fail. This is mostly fo
7530 if (ss->handshakeCallback != NULL && ssl3_CanFalseStart(ss)) {
7531 » (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData);
7532 }
7533 7609
7534 return SECSuccess; 7610 return SECSuccess;
7535 7611
7536 loser: 7612 loser:
7537 ssl_ReleaseXmitBufLock(ss); 7613 ssl_ReleaseXmitBufLock(ss);
7538 return rv; 7614 return rv;
7539 } 7615 }
7540 7616
7541 /* 7617 /*
7542 * Routines used by servers 7618 * Routines used by servers
(...skipping 2597 matching lines...) Expand 10 before | Expand all | Expand 10 after
10140 10216
10141 if (rv == SECWouldBlock) { 10217 if (rv == SECWouldBlock) {
10142 if (ss->sec.isServer) { 10218 if (ss->sec.isServer) {
10143 errCode = SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SERVERS; 10219 errCode = SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SERVERS;
10144 rv = SECFailure; 10220 rv = SECFailure;
10145 goto loser; 10221 goto loser;
10146 } 10222 }
10147 10223
10148 ss->ssl3.hs.authCertificatePending = PR_TRUE; 10224 ss->ssl3.hs.authCertificatePending = PR_TRUE;
10149 rv = SECSuccess; 10225 rv = SECSuccess;
10150
10151 /* XXX: Async cert validation and False Start don't work together
10152 * safely yet; if we leave False Start enabled, we may end up false
10153 * starting (sending application data) before we
10154 * SSL_AuthCertificateComplete has been called.
10155 */
10156 ss->opt.enableFalseStart = PR_FALSE;
10157 } 10226 }
10158 10227
10159 if (rv != SECSuccess) { 10228 if (rv != SECSuccess) {
10160 ssl3_SendAlertForCertError(ss, errCode); 10229 ssl3_SendAlertForCertError(ss, errCode);
10161 goto loser; 10230 goto loser;
10162 } 10231 }
10163 } 10232 }
10164 10233
10165 ss->sec.ci.sid->peerCert = CERT_DupCertificate(ss->sec.peerCert); 10234 ss->sec.ci.sid->peerCert = CERT_DupCertificate(ss->sec.peerCert);
10166 ssl3_CopyPeerCertsToSID(ss->ssl3.peerCertChain, ss->sec.ci.sid); 10235 ssl3_CopyPeerCertsToSID(ss->ssl3.peerCertChain, ss->sec.ci.sid);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
10271 10340
10272 ss->ssl3.hs.authCertificatePending = PR_FALSE; 10341 ss->ssl3.hs.authCertificatePending = PR_FALSE;
10273 10342
10274 if (error != 0) { 10343 if (error != 0) {
10275 ss->ssl3.hs.restartTarget = ssl3_AlwaysFail; 10344 ss->ssl3.hs.restartTarget = ssl3_AlwaysFail;
10276 ssl3_SendAlertForCertError(ss, error); 10345 ssl3_SendAlertForCertError(ss, error);
10277 rv = SECSuccess; 10346 rv = SECSuccess;
10278 } else if (ss->ssl3.hs.restartTarget != NULL) { 10347 } else if (ss->ssl3.hs.restartTarget != NULL) {
10279 sslRestartTarget target = ss->ssl3.hs.restartTarget; 10348 sslRestartTarget target = ss->ssl3.hs.restartTarget;
10280 ss->ssl3.hs.restartTarget = NULL; 10349 ss->ssl3.hs.restartTarget = NULL;
10350
10351 if (target == ssl3_FinishHandshake) {
10352 SSL_TRC(3,("%d: SSL3[%p]: certificate authentication lost the race"
10353 " with peer's finished message", SSL_GETPID(), ss->fd));
10354 }
10355
10281 rv = target(ss); 10356 rv = target(ss);
10282 /* Even if we blocked here, we have accomplished enough to claim 10357 /* Even if we blocked here, we have accomplished enough to claim
10283 * success. Any remaining work will be taken care of by subsequent 10358 * success. Any remaining work will be taken care of by subsequent
10284 * calls to SSL_ForceHandshake/PR_Send/PR_Read/etc. 10359 * calls to SSL_ForceHandshake/PR_Send/PR_Read/etc.
10285 */ 10360 */
10286 if (rv == SECWouldBlock) { 10361 if (rv == SECWouldBlock) {
10287 rv = SECSuccess; 10362 rv = SECSuccess;
10288 } 10363 }
10289 } else { 10364 } else {
10290 » rv = SECSuccess; 10365 » SSL_TRC(3, ("%d: SSL3[%p]: certificate authentication won the race with"
10366 » " peer's finished message", SSL_GETPID(), ss->fd));
10367
10368 » PORT_Assert(!ss->firstHsDone);
10369 » PORT_Assert(!ss->sec.isServer);
10370 » PORT_Assert(!ss->ssl3.hs.isResuming);
10371 » PORT_Assert(ss->ssl3.hs.ws == wait_new_session_ticket ||
10372 » » ss->ssl3.hs.ws == wait_change_cipher ||
10373 » » ss->ssl3.hs.ws == wait_finished);
briansmith 2013/10/25 19:17:14 This change is just putting the states in chronolo
10374
10375 » /* ssl3_SendClientSecondRound deferred the false start check because
10376 » * certificate authentication was pending, so we have to do it now.
10377 » *
10378 » * If we've received any part of the server's second round then don't
10379 » * bother false starting. See the false-start-ws comment in
wtc 2013/10/29 19:54:22 Nit: "false-start-ws" should be clarified.
10380 » * ssl3_GatherCompleteHandshake , since it is almost always the case tha t the
10381 » * NewSessionTicket,
10382 » * ChangeCipherSoec, and Finished mesage were sent in the same packet
wtc 2013/10/29 01:21:51 Nit: these three lines of comments should be refor
briansmith 2013/10/29 21:00:13 I removed this part of the comment since it is red
10383 » * and we want to process them all at the same time.
briansmith 2013/10/25 19:17:14 This comment addition is redundant with the docume
10384 » */
10385 » if (ss->opt.enableFalseStart &&
10386 » !ss->firstHsDone &&
10387 » !ss->sec.isServer &&
10388 » !ss->ssl3.hs.isResuming &&
10389 » ssl3_WaitingForStartOfServerSecondRound(ss)) {
10390 » rv = ssl3_CheckFalseStart(ss);
10391 » } else {
10392 » rv = SECSuccess;
10393 » }
10291 } 10394 }
10292 10395
10293 done: 10396 done:
10294 ssl_ReleaseSSL3HandshakeLock(ss); 10397 ssl_ReleaseSSL3HandshakeLock(ss);
10295 ssl_ReleaseRecvBufLock(ss); 10398 ssl_ReleaseRecvBufLock(ss);
10296 10399
10297 return rv; 10400 return rv;
10298 } 10401 }
10299 10402
10300 static SECStatus 10403 static SECStatus
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
10906 goto xmit_loser; /* err is set. */ 11009 goto xmit_loser; /* err is set. */
10907 } 11010 }
10908 } 11011 }
10909 11012
10910 xmit_loser: 11013 xmit_loser:
10911 ssl_ReleaseXmitBufLock(ss); /*************************************/ 11014 ssl_ReleaseXmitBufLock(ss); /*************************************/
10912 if (rv != SECSuccess) { 11015 if (rv != SECSuccess) {
10913 return rv; 11016 return rv;
10914 } 11017 }
10915 11018
10916 ss->gs.writeOffset = 0;
10917 ss->gs.readOffset = 0;
10918
10919 if (ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa) { 11019 if (ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa) {
10920 effectiveExchKeyType = kt_rsa; 11020 effectiveExchKeyType = kt_rsa;
10921 } else { 11021 } else {
10922 effectiveExchKeyType = ss->ssl3.hs.kea_def->exchKeyType; 11022 effectiveExchKeyType = ss->ssl3.hs.kea_def->exchKeyType;
10923 } 11023 }
10924 11024
10925 if (sid->cached == never_cached && !ss->opt.noCache && ss->sec.cache) { 11025 if (sid->cached == never_cached && !ss->opt.noCache && ss->sec.cache) {
10926 /* fill in the sid */ 11026 /* fill in the sid */
10927 sid->u.ssl3.cipherSuite = ss->ssl3.hs.cipher_suite; 11027 sid->u.ssl3.cipherSuite = ss->ssl3.hs.cipher_suite;
10928 sid->u.ssl3.compression = ss->ssl3.hs.compression; 11028 sid->u.ssl3.compression = ss->ssl3.hs.compression;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
10973 } 11073 }
10974 11074
10975 ss->ssl3.hs.restartTarget = ssl3_FinishHandshake; 11075 ss->ssl3.hs.restartTarget = ssl3_FinishHandshake;
10976 return SECWouldBlock; 11076 return SECWouldBlock;
10977 } 11077 }
10978 11078
10979 rv = ssl3_FinishHandshake(ss); 11079 rv = ssl3_FinishHandshake(ss);
10980 return rv; 11080 return rv;
10981 } 11081 }
10982 11082
11083 /* The return type is SECStatus instead of void because this function needs
11084 * to have type sslRestartTarget.
11085 */
10983 SECStatus 11086 SECStatus
10984 ssl3_FinishHandshake(sslSocket * ss) 11087 ssl3_FinishHandshake(sslSocket * ss)
10985 { 11088 {
10986 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); 11089 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) );
10987 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); 11090 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) );
10988 PORT_Assert( ss->ssl3.hs.restartTarget == NULL ); 11091 PORT_Assert( ss->ssl3.hs.restartTarget == NULL );
10989 11092
10990 /* The first handshake is now completed. */ 11093 /* The first handshake is now completed. */
10991 ss->handshake = NULL; 11094 ss->handshake = NULL;
10992 ss->firstHsDone = PR_TRUE;
10993 11095
10994 if (ss->ssl3.hs.cacheSID) { 11096 if (ss->ssl3.hs.cacheSID) {
10995 (*ss->sec.cache)(ss->sec.ci.sid); 11097 (*ss->sec.cache)(ss->sec.ci.sid);
10996 ss->ssl3.hs.cacheSID = PR_FALSE; 11098 ss->ssl3.hs.cacheSID = PR_FALSE;
10997 } 11099 }
10998 11100
11101 ss->ssl3.hs.canFalseStart = PR_FALSE; /* False Start phase is complete */
10999 ss->ssl3.hs.ws = idle_handshake; 11102 ss->ssl3.hs.ws = idle_handshake;
11000 11103
11001 /* Do the handshake callback for sslv3 here, if we cannot false start. */ 11104 ssl_FinishHandshake(ss);
11002 if (ss->handshakeCallback != NULL && !ssl3_CanFalseStart(ss)) {
11003 » (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData);
11004 }
11005 11105
11006 return SECSuccess; 11106 return SECSuccess;
11007 } 11107 }
11008 11108
11009 /* Called from ssl3_HandleHandshake() when it has gathered a complete ssl3 11109 /* Called from ssl3_HandleHandshake() when it has gathered a complete ssl3
11010 * hanshake message. 11110 * hanshake message.
11011 * Caller must hold Handshake and RecvBuf locks. 11111 * Caller must hold Handshake and RecvBuf locks.
11012 */ 11112 */
11013 SECStatus 11113 SECStatus
11014 ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length) 11114 ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
11566 unsigned int good; 11666 unsigned int good;
11567 unsigned int minLength; 11667 unsigned int minLength;
11568 unsigned char header[13]; 11668 unsigned char header[13];
11569 unsigned int headerLen; 11669 unsigned int headerLen;
11570 11670
11571 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); 11671 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) );
11572 11672
11573 if (!ss->ssl3.initialized) { 11673 if (!ss->ssl3.initialized) {
11574 ssl_GetSSL3HandshakeLock(ss); 11674 ssl_GetSSL3HandshakeLock(ss);
11575 rv = ssl3_InitState(ss); 11675 rv = ssl3_InitState(ss);
11576 ssl_ReleaseSSL3HandshakeLock(ss); 11676 ssl_ReleaseSSL3HandshakeLock(ss);
briansmith 2013/10/25 19:17:14 This function was reverted to the way it was befor
11577 if (rv != SECSuccess) { 11677 if (rv != SECSuccess) {
11578 return rv; /* ssl3_InitState has set the error code. */ 11678 return rv; /* ssl3_InitState has set the error code. */
11579 } 11679 }
11580 } 11680 }
11581 11681
11582 /* check for Token Presence */ 11682 /* check for Token Presence */
11583 if (!ssl3_ClientAuthTokenPresent(ss->sec.ci.sid)) { 11683 if (!ssl3_ClientAuthTokenPresent(ss->sec.ci.sid)) {
11584 PORT_SetError(SSL_ERROR_TOKEN_INSERTION_REMOVAL); 11684 PORT_SetError(SSL_ERROR_TOKEN_INSERTION_REMOVAL);
11585 return SECFailure; 11685 return SECFailure;
11586 } 11686 }
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
11959 SSL_DBG(("%d: SSL3[%d]: bogus content type=%d", 12059 SSL_DBG(("%d: SSL3[%d]: bogus content type=%d",
11960 SSL_GETPID(), ss->fd, cText->type)); 12060 SSL_GETPID(), ss->fd, cText->type));
11961 /* XXX Send an alert ??? */ 12061 /* XXX Send an alert ??? */
11962 PORT_SetError(SSL_ERROR_RX_UNKNOWN_RECORD_TYPE); 12062 PORT_SetError(SSL_ERROR_RX_UNKNOWN_RECORD_TYPE);
11963 rv = SECFailure; 12063 rv = SECFailure;
11964 break; 12064 break;
11965 } 12065 }
11966 12066
11967 ssl_ReleaseSSL3HandshakeLock(ss); 12067 ssl_ReleaseSSL3HandshakeLock(ss);
11968 return rv; 12068 return rv;
11969 12069
wtc 2013/10/29 01:21:51 Delete this blank line.
briansmith 2013/10/29 21:00:13 Done.
11970 } 12070 }
11971 12071
11972 /* 12072 /*
11973 * Initialization functions 12073 * Initialization functions
11974 */ 12074 */
11975 12075
11976 /* Called from ssl3_InitState, immediately below. */ 12076 /* Called from ssl3_InitState, immediately below. */
11977 /* Caller must hold the SpecWriteLock. */ 12077 /* Caller must hold the SpecWriteLock. */
11978 static void 12078 static void
11979 ssl3_InitCipherSpec(sslSocket *ss, ssl3CipherSpec *spec) 12079 ssl3_InitCipherSpec(sslSocket *ss, ssl3CipherSpec *spec)
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
12470 PORT_Free(ss->ssl3.hs.recvdFragments.buf); 12570 PORT_Free(ss->ssl3.hs.recvdFragments.buf);
12471 } 12571 }
12472 } 12572 }
12473 12573
12474 ss->ssl3.initialized = PR_FALSE; 12574 ss->ssl3.initialized = PR_FALSE;
12475 12575
12476 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); 12576 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE);
12477 } 12577 }
12478 12578
12479 /* End of ssl3con.c */ 12579 /* End of ssl3con.c */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698