OLD | NEW |
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 Loading... |
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 Loading... |
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 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); |
| 7351 PORT_Assert( !ss->ssl3.hs.authCertificatePending ); |
| 7352 PORT_Assert( !ss->ssl3.hs.canFalseStart ); |
| 7353 |
| 7354 if (!ss->canFalseStartCallback) { |
| 7355 SSL_TRC(3, ("%d: SSL[%d]: no false start callback so no false start", |
| 7356 SSL_GETPID(), ss->fd)); |
| 7357 } else { |
| 7358 PRBool maybeFalseStart; |
| 7359 SECStatus rv; |
| 7360 |
| 7361 /* An attacker can control the selected ciphersuite so we only wish to |
| 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; |
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 default: |
| 7408 result = PR_FALSE; |
| 7409 break; |
| 7410 } |
7358 | 7411 |
7359 ssl_GetSpecReadLock(ss); | 7412 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 } | 7413 } |
7378 | 7414 |
7379 static SECStatus ssl3_SendClientSecondRound(sslSocket *ss); | 7415 static SECStatus ssl3_SendClientSecondRound(sslSocket *ss); |
7380 | 7416 |
7381 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete | 7417 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete |
7382 * ssl3 Server Hello Done message. | 7418 * ssl3 Server Hello Done message. |
7383 * Caller must hold Handshake and RecvBuf locks. | 7419 * Caller must hold Handshake and RecvBuf locks. |
7384 */ | 7420 */ |
7385 static SECStatus | 7421 static SECStatus |
7386 ssl3_HandleServerHelloDone(sslSocket *ss) | 7422 ssl3_HandleServerHelloDone(sslSocket *ss) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7456 * before using the cipher specs agreed upon for that handshake for | 7492 * before using the cipher specs agreed upon for that handshake for |
7457 * application data. | 7493 * application data. |
7458 */ | 7494 */ |
7459 if (ss->ssl3.hs.restartTarget) { | 7495 if (ss->ssl3.hs.restartTarget) { |
7460 PR_NOT_REACHED("unexpected ss->ssl3.hs.restartTarget"); | 7496 PR_NOT_REACHED("unexpected ss->ssl3.hs.restartTarget"); |
7461 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); | 7497 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); |
7462 return SECFailure; | 7498 return SECFailure; |
7463 } | 7499 } |
7464 if (ss->ssl3.hs.authCertificatePending && | 7500 if (ss->ssl3.hs.authCertificatePending && |
7465 (sendClientCert || ss->ssl3.sendEmptyCert || ss->firstHsDone)) { | 7501 (sendClientCert || ss->ssl3.sendEmptyCert || ss->firstHsDone)) { |
| 7502 SSL_TRC(3, ("%d: SSL3[%p]: deferring ssl3_SendClientSecondRound because" |
| 7503 " certificate authentication is still pending.", |
| 7504 SSL_GETPID(), ss->fd)); |
7466 ss->ssl3.hs.restartTarget = ssl3_SendClientSecondRound; | 7505 ss->ssl3.hs.restartTarget = ssl3_SendClientSecondRound; |
7467 return SECWouldBlock; | 7506 return SECWouldBlock; |
7468 } | 7507 } |
7469 | 7508 |
7470 ssl_GetXmitBufLock(ss); /*******************************/ | 7509 ssl_GetXmitBufLock(ss); /*******************************/ |
7471 | 7510 |
7472 if (ss->ssl3.sendEmptyCert) { | 7511 if (ss->ssl3.sendEmptyCert) { |
7473 ss->ssl3.sendEmptyCert = PR_FALSE; | 7512 ss->ssl3.sendEmptyCert = PR_FALSE; |
7474 rv = ssl3_SendEmptyCertificate(ss); | 7513 rv = ssl3_SendEmptyCertificate(ss); |
7475 /* Don't send verify */ | 7514 /* Don't send verify */ |
(...skipping 17 matching lines...) Expand all Loading... |
7493 if (rv != SECSuccess) { | 7532 if (rv != SECSuccess) { |
7494 goto loser; /* err is set. */ | 7533 goto loser; /* err is set. */ |
7495 } | 7534 } |
7496 } | 7535 } |
7497 | 7536 |
7498 rv = ssl3_SendChangeCipherSpecs(ss); | 7537 rv = ssl3_SendChangeCipherSpecs(ss); |
7499 if (rv != SECSuccess) { | 7538 if (rv != SECSuccess) { |
7500 goto loser; /* err code was set. */ | 7539 goto loser; /* err code was set. */ |
7501 } | 7540 } |
7502 | 7541 |
7503 /* XXX: If the server's certificate hasn't been authenticated by this | 7542 /* 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. | 7543 * ssl3_SendChangeCipherSpecs because SSL_GetChannelInfo uses information |
| 7544 * from cwSpec. This must be done before we call ssl3_CheckFalseStart |
| 7545 * because the false start callback (if any) may need the information from |
| 7546 * the functions that depend on this being set. |
7505 */ | 7547 */ |
| 7548 ss->enoughFirstHsDone = PR_TRUE; |
| 7549 |
7506 if (!ss->firstHsDone) { | 7550 if (!ss->firstHsDone) { |
| 7551 /* XXX: If the server's certificate hasn't been authenticated by this |
| 7552 * point, then we may be leaking this NPN message to an attacker. |
| 7553 */ |
7507 rv = ssl3_SendNextProto(ss); | 7554 rv = ssl3_SendNextProto(ss); |
7508 if (rv != SECSuccess) { | 7555 if (rv != SECSuccess) { |
7509 goto loser; /* err code was set. */ | 7556 goto loser; /* err code was set. */ |
7510 } | 7557 } |
7511 } | 7558 } |
| 7559 |
7512 rv = ssl3_SendEncryptedExtensions(ss); | 7560 rv = ssl3_SendEncryptedExtensions(ss); |
7513 if (rv != SECSuccess) { | 7561 if (rv != SECSuccess) { |
7514 goto loser; /* err code was set. */ | 7562 goto loser; /* err code was set. */ |
7515 } | 7563 } |
7516 | 7564 |
| 7565 if (!ss->firstHsDone) { |
| 7566 if (ss->opt.enableFalseStart) { |
| 7567 if (!ss->ssl3.hs.authCertificatePending) { |
| 7568 /* When we fix bug 589047, we will need to know whether we are |
| 7569 * false starting before we try to flush the client second |
| 7570 * round to the network. With that in mind, we purposefully |
| 7571 * call ssl3_CheckFalseStart before calling ssl3_SendFinished, |
| 7572 * which includes a call to ssl3_FlushHandshake, so that |
| 7573 * no application develops a reliance on such flushing being |
| 7574 * done before its false start callback is called. |
| 7575 */ |
| 7576 ssl_ReleaseXmitBufLock(ss); |
| 7577 rv = ssl3_CheckFalseStart(ss); |
| 7578 ssl_GetXmitBufLock(ss); |
| 7579 if (rv != SECSuccess) { |
| 7580 goto loser; |
| 7581 } |
| 7582 } else { |
| 7583 /* The certificate authentication and the server's Finished |
| 7584 * message are racing each other. If the certificate |
| 7585 * authentication wins, then we will try to false start in |
| 7586 * ssl3_AuthCertificateComplete. |
| 7587 */ |
| 7588 SSL_TRC(3, ("%d: SSL3[%p]: deferring false start check because" |
| 7589 " certificate authentication is still pending.", |
| 7590 SSL_GETPID(), ss->fd)); |
| 7591 } |
| 7592 } |
| 7593 } |
| 7594 |
7517 rv = ssl3_SendFinished(ss, 0); | 7595 rv = ssl3_SendFinished(ss, 0); |
7518 if (rv != SECSuccess) { | 7596 if (rv != SECSuccess) { |
7519 goto loser; /* err code was set. */ | 7597 goto loser; /* err code was set. */ |
7520 } | 7598 } |
7521 | 7599 |
7522 ssl_ReleaseXmitBufLock(ss); /*******************************/ | 7600 ssl_ReleaseXmitBufLock(ss); /*******************************/ |
7523 | 7601 |
7524 if (ssl3_ExtensionNegotiated(ss, ssl_session_ticket_xtn)) | 7602 if (ssl3_ExtensionNegotiated(ss, ssl_session_ticket_xtn)) |
7525 ss->ssl3.hs.ws = wait_new_session_ticket; | 7603 ss->ssl3.hs.ws = wait_new_session_ticket; |
7526 else | 7604 else |
7527 ss->ssl3.hs.ws = wait_change_cipher; | 7605 ss->ssl3.hs.ws = wait_change_cipher; |
7528 | 7606 |
7529 /* Do the handshake callback for sslv3 here, if we can false start. */ | 7607 PORT_Assert(ssl3_WaitingForStartOfServerSecondRound(ss)); |
7530 if (ss->handshakeCallback != NULL && ssl3_CanFalseStart(ss)) { | |
7531 » (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); | |
7532 } | |
7533 | 7608 |
7534 return SECSuccess; | 7609 return SECSuccess; |
7535 | 7610 |
7536 loser: | 7611 loser: |
7537 ssl_ReleaseXmitBufLock(ss); | 7612 ssl_ReleaseXmitBufLock(ss); |
7538 return rv; | 7613 return rv; |
7539 } | 7614 } |
7540 | 7615 |
7541 /* | 7616 /* |
7542 * Routines used by servers | 7617 * Routines used by servers |
(...skipping 2597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10140 | 10215 |
10141 if (rv == SECWouldBlock) { | 10216 if (rv == SECWouldBlock) { |
10142 if (ss->sec.isServer) { | 10217 if (ss->sec.isServer) { |
10143 errCode = SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SERVERS; | 10218 errCode = SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SERVERS; |
10144 rv = SECFailure; | 10219 rv = SECFailure; |
10145 goto loser; | 10220 goto loser; |
10146 } | 10221 } |
10147 | 10222 |
10148 ss->ssl3.hs.authCertificatePending = PR_TRUE; | 10223 ss->ssl3.hs.authCertificatePending = PR_TRUE; |
10149 rv = SECSuccess; | 10224 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 } | 10225 } |
10158 | 10226 |
10159 if (rv != SECSuccess) { | 10227 if (rv != SECSuccess) { |
10160 ssl3_SendAlertForCertError(ss, errCode); | 10228 ssl3_SendAlertForCertError(ss, errCode); |
10161 goto loser; | 10229 goto loser; |
10162 } | 10230 } |
10163 } | 10231 } |
10164 | 10232 |
10165 ss->sec.ci.sid->peerCert = CERT_DupCertificate(ss->sec.peerCert); | 10233 ss->sec.ci.sid->peerCert = CERT_DupCertificate(ss->sec.peerCert); |
10166 ssl3_CopyPeerCertsToSID(ss->ssl3.peerCertChain, ss->sec.ci.sid); | 10234 ssl3_CopyPeerCertsToSID(ss->ssl3.peerCertChain, ss->sec.ci.sid); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10271 | 10339 |
10272 ss->ssl3.hs.authCertificatePending = PR_FALSE; | 10340 ss->ssl3.hs.authCertificatePending = PR_FALSE; |
10273 | 10341 |
10274 if (error != 0) { | 10342 if (error != 0) { |
10275 ss->ssl3.hs.restartTarget = ssl3_AlwaysFail; | 10343 ss->ssl3.hs.restartTarget = ssl3_AlwaysFail; |
10276 ssl3_SendAlertForCertError(ss, error); | 10344 ssl3_SendAlertForCertError(ss, error); |
10277 rv = SECSuccess; | 10345 rv = SECSuccess; |
10278 } else if (ss->ssl3.hs.restartTarget != NULL) { | 10346 } else if (ss->ssl3.hs.restartTarget != NULL) { |
10279 sslRestartTarget target = ss->ssl3.hs.restartTarget; | 10347 sslRestartTarget target = ss->ssl3.hs.restartTarget; |
10280 ss->ssl3.hs.restartTarget = NULL; | 10348 ss->ssl3.hs.restartTarget = NULL; |
| 10349 |
| 10350 if (target == ssl3_FinishHandshake) { |
| 10351 SSL_TRC(3,("%d: SSL3[%p]: certificate authentication lost the race" |
| 10352 " with peer's finished message", SSL_GETPID(), ss->fd)); |
| 10353 } |
| 10354 |
10281 rv = target(ss); | 10355 rv = target(ss); |
10282 /* Even if we blocked here, we have accomplished enough to claim | 10356 /* Even if we blocked here, we have accomplished enough to claim |
10283 * success. Any remaining work will be taken care of by subsequent | 10357 * success. Any remaining work will be taken care of by subsequent |
10284 * calls to SSL_ForceHandshake/PR_Send/PR_Read/etc. | 10358 * calls to SSL_ForceHandshake/PR_Send/PR_Read/etc. |
10285 */ | 10359 */ |
10286 if (rv == SECWouldBlock) { | 10360 if (rv == SECWouldBlock) { |
10287 rv = SECSuccess; | 10361 rv = SECSuccess; |
10288 } | 10362 } |
10289 } else { | 10363 } else { |
10290 » rv = SECSuccess; | 10364 » SSL_TRC(3, ("%d: SSL3[%p]: certificate authentication won the race with" |
| 10365 » " peer's finished message", SSL_GETPID(), ss->fd)); |
| 10366 |
| 10367 » PORT_Assert(!ss->firstHsDone); |
| 10368 » PORT_Assert(!ss->sec.isServer); |
| 10369 » PORT_Assert(!ss->ssl3.hs.isResuming); |
| 10370 » PORT_Assert(ss->ssl3.hs.ws != idle_handshake); |
| 10371 |
| 10372 » if (ss->opt.enableFalseStart && |
| 10373 » !ss->firstHsDone && |
| 10374 » !ss->sec.isServer && |
| 10375 » !ss->ssl3.hs.isResuming && |
| 10376 » ssl3_WaitingForStartOfServerSecondRound(ss)) { |
| 10377 » /* ssl3_SendClientSecondRound deferred the false start check because |
| 10378 » * certificate authentication was pending, so we do it now if we sti
ll |
| 10379 » * haven't received any of the server's second round yet. |
| 10380 » */ |
| 10381 » rv = ssl3_CheckFalseStart(ss); |
| 10382 » } else { |
| 10383 » rv = SECSuccess; |
| 10384 » } |
10291 } | 10385 } |
10292 | 10386 |
10293 done: | 10387 done: |
10294 ssl_ReleaseSSL3HandshakeLock(ss); | 10388 ssl_ReleaseSSL3HandshakeLock(ss); |
10295 ssl_ReleaseRecvBufLock(ss); | 10389 ssl_ReleaseRecvBufLock(ss); |
10296 | 10390 |
10297 return rv; | 10391 return rv; |
10298 } | 10392 } |
10299 | 10393 |
10300 static SECStatus | 10394 static SECStatus |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10906 goto xmit_loser; /* err is set. */ | 11000 goto xmit_loser; /* err is set. */ |
10907 } | 11001 } |
10908 } | 11002 } |
10909 | 11003 |
10910 xmit_loser: | 11004 xmit_loser: |
10911 ssl_ReleaseXmitBufLock(ss); /*************************************/ | 11005 ssl_ReleaseXmitBufLock(ss); /*************************************/ |
10912 if (rv != SECSuccess) { | 11006 if (rv != SECSuccess) { |
10913 return rv; | 11007 return rv; |
10914 } | 11008 } |
10915 | 11009 |
10916 ss->gs.writeOffset = 0; | |
10917 ss->gs.readOffset = 0; | |
10918 | |
10919 if (ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa) { | 11010 if (ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa) { |
10920 effectiveExchKeyType = kt_rsa; | 11011 effectiveExchKeyType = kt_rsa; |
10921 } else { | 11012 } else { |
10922 effectiveExchKeyType = ss->ssl3.hs.kea_def->exchKeyType; | 11013 effectiveExchKeyType = ss->ssl3.hs.kea_def->exchKeyType; |
10923 } | 11014 } |
10924 | 11015 |
10925 if (sid->cached == never_cached && !ss->opt.noCache && ss->sec.cache) { | 11016 if (sid->cached == never_cached && !ss->opt.noCache && ss->sec.cache) { |
10926 /* fill in the sid */ | 11017 /* fill in the sid */ |
10927 sid->u.ssl3.cipherSuite = ss->ssl3.hs.cipher_suite; | 11018 sid->u.ssl3.cipherSuite = ss->ssl3.hs.cipher_suite; |
10928 sid->u.ssl3.compression = ss->ssl3.hs.compression; | 11019 sid->u.ssl3.compression = ss->ssl3.hs.compression; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10973 } | 11064 } |
10974 | 11065 |
10975 ss->ssl3.hs.restartTarget = ssl3_FinishHandshake; | 11066 ss->ssl3.hs.restartTarget = ssl3_FinishHandshake; |
10976 return SECWouldBlock; | 11067 return SECWouldBlock; |
10977 } | 11068 } |
10978 | 11069 |
10979 rv = ssl3_FinishHandshake(ss); | 11070 rv = ssl3_FinishHandshake(ss); |
10980 return rv; | 11071 return rv; |
10981 } | 11072 } |
10982 | 11073 |
| 11074 /* The return type is SECStatus instead of void because this function needs |
| 11075 * to have type sslRestartTarget. |
| 11076 */ |
10983 SECStatus | 11077 SECStatus |
10984 ssl3_FinishHandshake(sslSocket * ss) | 11078 ssl3_FinishHandshake(sslSocket * ss) |
10985 { | 11079 { |
10986 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); | 11080 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); |
10987 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); | 11081 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); |
10988 PORT_Assert( ss->ssl3.hs.restartTarget == NULL ); | 11082 PORT_Assert( ss->ssl3.hs.restartTarget == NULL ); |
10989 | 11083 |
10990 /* The first handshake is now completed. */ | 11084 /* The first handshake is now completed. */ |
10991 ss->handshake = NULL; | 11085 ss->handshake = NULL; |
10992 ss->firstHsDone = PR_TRUE; | |
10993 | 11086 |
10994 if (ss->ssl3.hs.cacheSID) { | 11087 if (ss->ssl3.hs.cacheSID) { |
10995 (*ss->sec.cache)(ss->sec.ci.sid); | 11088 (*ss->sec.cache)(ss->sec.ci.sid); |
10996 ss->ssl3.hs.cacheSID = PR_FALSE; | 11089 ss->ssl3.hs.cacheSID = PR_FALSE; |
10997 } | 11090 } |
10998 | 11091 |
| 11092 ss->ssl3.hs.canFalseStart = PR_FALSE; /* False Start phase is complete */ |
10999 ss->ssl3.hs.ws = idle_handshake; | 11093 ss->ssl3.hs.ws = idle_handshake; |
11000 | 11094 |
11001 /* Do the handshake callback for sslv3 here, if we cannot false start. */ | 11095 ssl_FinishHandshake(ss); |
11002 if (ss->handshakeCallback != NULL && !ssl3_CanFalseStart(ss)) { | |
11003 » (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); | |
11004 } | |
11005 | 11096 |
11006 return SECSuccess; | 11097 return SECSuccess; |
11007 } | 11098 } |
11008 | 11099 |
11009 /* Called from ssl3_HandleHandshake() when it has gathered a complete ssl3 | 11100 /* Called from ssl3_HandleHandshake() when it has gathered a complete ssl3 |
11010 * hanshake message. | 11101 * hanshake message. |
11011 * Caller must hold Handshake and RecvBuf locks. | 11102 * Caller must hold Handshake and RecvBuf locks. |
11012 */ | 11103 */ |
11013 SECStatus | 11104 SECStatus |
11014 ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length) | 11105 ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length) |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11959 SSL_DBG(("%d: SSL3[%d]: bogus content type=%d", | 12050 SSL_DBG(("%d: SSL3[%d]: bogus content type=%d", |
11960 SSL_GETPID(), ss->fd, cText->type)); | 12051 SSL_GETPID(), ss->fd, cText->type)); |
11961 /* XXX Send an alert ??? */ | 12052 /* XXX Send an alert ??? */ |
11962 PORT_SetError(SSL_ERROR_RX_UNKNOWN_RECORD_TYPE); | 12053 PORT_SetError(SSL_ERROR_RX_UNKNOWN_RECORD_TYPE); |
11963 rv = SECFailure; | 12054 rv = SECFailure; |
11964 break; | 12055 break; |
11965 } | 12056 } |
11966 | 12057 |
11967 ssl_ReleaseSSL3HandshakeLock(ss); | 12058 ssl_ReleaseSSL3HandshakeLock(ss); |
11968 return rv; | 12059 return rv; |
11969 | |
11970 } | 12060 } |
11971 | 12061 |
11972 /* | 12062 /* |
11973 * Initialization functions | 12063 * Initialization functions |
11974 */ | 12064 */ |
11975 | 12065 |
11976 /* Called from ssl3_InitState, immediately below. */ | 12066 /* Called from ssl3_InitState, immediately below. */ |
11977 /* Caller must hold the SpecWriteLock. */ | 12067 /* Caller must hold the SpecWriteLock. */ |
11978 static void | 12068 static void |
11979 ssl3_InitCipherSpec(sslSocket *ss, ssl3CipherSpec *spec) | 12069 ssl3_InitCipherSpec(sslSocket *ss, ssl3CipherSpec *spec) |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12470 PORT_Free(ss->ssl3.hs.recvdFragments.buf); | 12560 PORT_Free(ss->ssl3.hs.recvdFragments.buf); |
12471 } | 12561 } |
12472 } | 12562 } |
12473 | 12563 |
12474 ss->ssl3.initialized = PR_FALSE; | 12564 ss->ssl3.initialized = PR_FALSE; |
12475 | 12565 |
12476 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); | 12566 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); |
12477 } | 12567 } |
12478 | 12568 |
12479 /* End of ssl3con.c */ | 12569 /* End of ssl3con.c */ |
OLD | NEW |