Chromium Code Reviews| 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 /* $Id: ssl3con.c,v 1.192 2012/09/28 05:10:25 wtc%google.com Exp $ */ | 8 /* $Id$ */ |
| 9 | 9 |
| 10 /* TODO(ekr): Implement HelloVerifyRequest on server side. OK for now. */ | 10 /* TODO(ekr): Implement HelloVerifyRequest on server side. OK for now. */ |
| 11 | 11 |
| 12 #include "cert.h" | 12 #include "cert.h" |
| 13 #include "ssl.h" | 13 #include "ssl.h" |
| 14 #include "cryptohi.h" /* for DSAU_ stuff */ | 14 #include "cryptohi.h" /* for DSAU_ stuff */ |
| 15 #include "keyhi.h" | 15 #include "keyhi.h" |
| 16 #include "secder.h" | 16 #include "secder.h" |
| 17 #include "secitem.h" | 17 #include "secitem.h" |
| 18 | 18 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 43 | 43 |
| 44 static void ssl3_CleanupPeerCerts(sslSocket *ss); | 44 static void ssl3_CleanupPeerCerts(sslSocket *ss); |
| 45 static void ssl3_CopyPeerCertsFromSID(sslSocket *ss, sslSessionID *sid); | 45 static void ssl3_CopyPeerCertsFromSID(sslSocket *ss, sslSessionID *sid); |
| 46 static PK11SymKey *ssl3_GenerateRSAPMS(sslSocket *ss, ssl3CipherSpec *spec, | 46 static PK11SymKey *ssl3_GenerateRSAPMS(sslSocket *ss, ssl3CipherSpec *spec, |
| 47 PK11SlotInfo * serverKeySlot); | 47 PK11SlotInfo * serverKeySlot); |
| 48 static SECStatus ssl3_DeriveMasterSecret(sslSocket *ss, PK11SymKey *pms); | 48 static SECStatus ssl3_DeriveMasterSecret(sslSocket *ss, PK11SymKey *pms); |
| 49 static SECStatus ssl3_DeriveConnectionKeysPKCS11(sslSocket *ss); | 49 static SECStatus ssl3_DeriveConnectionKeysPKCS11(sslSocket *ss); |
| 50 static SECStatus ssl3_HandshakeFailure( sslSocket *ss); | 50 static SECStatus ssl3_HandshakeFailure( sslSocket *ss); |
| 51 static SECStatus ssl3_InitState( sslSocket *ss); | 51 static SECStatus ssl3_InitState( sslSocket *ss); |
| 52 static SECStatus ssl3_SendCertificate( sslSocket *ss); | 52 static SECStatus ssl3_SendCertificate( sslSocket *ss); |
| 53 static SECStatus ssl3_SendCertificateStatus( sslSocket *ss); | |
| 53 static SECStatus ssl3_SendEmptyCertificate( sslSocket *ss); | 54 static SECStatus ssl3_SendEmptyCertificate( sslSocket *ss); |
| 54 static SECStatus ssl3_SendCertificateRequest(sslSocket *ss); | 55 static SECStatus ssl3_SendCertificateRequest(sslSocket *ss); |
| 55 static SECStatus ssl3_SendNextProto( sslSocket *ss); | 56 static SECStatus ssl3_SendNextProto( sslSocket *ss); |
| 56 static SECStatus ssl3_SendEncryptedExtensions(sslSocket *ss); | 57 static SECStatus ssl3_SendEncryptedExtensions(sslSocket *ss); |
| 57 static SECStatus ssl3_SendFinished( sslSocket *ss, PRInt32 flags); | 58 static SECStatus ssl3_SendFinished( sslSocket *ss, PRInt32 flags); |
| 58 static SECStatus ssl3_SendServerHello( sslSocket *ss); | 59 static SECStatus ssl3_SendServerHello( sslSocket *ss); |
| 59 static SECStatus ssl3_SendServerHelloDone( sslSocket *ss); | 60 static SECStatus ssl3_SendServerHelloDone( sslSocket *ss); |
| 60 static SECStatus ssl3_SendServerKeyExchange( sslSocket *ss); | 61 static SECStatus ssl3_SendServerKeyExchange( sslSocket *ss); |
| 61 static SECStatus ssl3_NewHandshakeHashes( sslSocket *ss); | 62 static SECStatus ssl3_NewHandshakeHashes( sslSocket *ss); |
| 62 static SECStatus ssl3_UpdateHandshakeHashes( sslSocket *ss, | 63 static SECStatus ssl3_UpdateHandshakeHashes( sslSocket *ss, |
| (...skipping 4114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4177 if (rv != SECSuccess) { | 4178 if (rv != SECSuccess) { |
| 4178 return rv; /* ssl3_InitState has set the error code. */ | 4179 return rv; /* ssl3_InitState has set the error code. */ |
| 4179 } | 4180 } |
| 4180 ss->ssl3.hs.sendingSCSV = PR_FALSE; /* Must be reset every handshake */ | 4181 ss->ssl3.hs.sendingSCSV = PR_FALSE; /* Must be reset every handshake */ |
| 4181 PORT_Assert(IS_DTLS(ss) || !resending); | 4182 PORT_Assert(IS_DTLS(ss) || !resending); |
| 4182 | 4183 |
| 4183 /* We might be starting a session renegotiation in which case we should | 4184 /* We might be starting a session renegotiation in which case we should |
| 4184 * clear previous state. | 4185 * clear previous state. |
| 4185 */ | 4186 */ |
| 4186 PORT_Memset(&ss->xtnData, 0, sizeof(TLSExtensionData)); | 4187 PORT_Memset(&ss->xtnData, 0, sizeof(TLSExtensionData)); |
| 4187 ss->ssl3.hs.may_get_cert_status = PR_FALSE; | |
| 4188 if (ss->ssl3.hs.cert_status.data) { | |
| 4189 SECITEM_FreeItem(&ss->ssl3.hs.cert_status, PR_FALSE); | |
| 4190 } | |
| 4191 | 4188 |
| 4192 SSL_TRC(30,("%d: SSL3[%d]: reset handshake hashes", | 4189 SSL_TRC(30,("%d: SSL3[%d]: reset handshake hashes", |
| 4193 SSL_GETPID(), ss->fd )); | 4190 SSL_GETPID(), ss->fd )); |
| 4194 rv = ssl3_RestartHandshakeHashes(ss); | 4191 rv = ssl3_RestartHandshakeHashes(ss); |
| 4195 if (rv != SECSuccess) { | 4192 if (rv != SECSuccess) { |
| 4196 return rv; | 4193 return rv; |
| 4197 } | 4194 } |
| 4198 | 4195 |
| 4199 /* | 4196 /* |
| 4200 * During a renegotiation, ss->clientHelloVersion will be used again to | 4197 * During a renegotiation, ss->clientHelloVersion will be used again to |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4391 if (extLen < 0) { | 4388 if (extLen < 0) { |
| 4392 return SECFailure; | 4389 return SECFailure; |
| 4393 } | 4390 } |
| 4394 maxBytes -= extLen; | 4391 maxBytes -= extLen; |
| 4395 total_exten_len += extLen; | 4392 total_exten_len += extLen; |
| 4396 | 4393 |
| 4397 if (total_exten_len > 0) | 4394 if (total_exten_len > 0) |
| 4398 total_exten_len += 2; | 4395 total_exten_len += 2; |
| 4399 } | 4396 } |
| 4400 | 4397 |
| 4401 #if defined(NSS_ENABLE_ECC) && !defined(NSS_ECC_MORE_THAN_SUITE_B) | 4398 #if defined(NSS_ENABLE_ECC) |
| 4402 if (!total_exten_len || !isTLS) { | 4399 if (!total_exten_len || !isTLS) { |
| 4403 /* not sending the elliptic_curves and ec_point_formats extensions */ | 4400 /* not sending the elliptic_curves and ec_point_formats extensions */ |
| 4404 ssl3_DisableECCSuites(ss, NULL); /* disable all ECC suites */ | 4401 ssl3_DisableECCSuites(ss, NULL); /* disable all ECC suites */ |
| 4405 } | 4402 } |
| 4406 #endif | 4403 #endif |
| 4407 | 4404 |
| 4408 if (IS_DTLS(ss)) { | 4405 if (IS_DTLS(ss)) { |
| 4409 ssl3_DisableNonDTLSSuites(ss); | 4406 ssl3_DisableNonDTLSSuites(ss); |
| 4410 } | 4407 } |
| 4411 | 4408 |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5359 rv = ssl3_ComputeHandshakeHashes(ss, ss->ssl3.pwSpec, &hashes, 0); | 5356 rv = ssl3_ComputeHandshakeHashes(ss, ss->ssl3.pwSpec, &hashes, 0); |
| 5360 ssl_ReleaseSpecReadLock(ss); | 5357 ssl_ReleaseSpecReadLock(ss); |
| 5361 if (rv != SECSuccess) { | 5358 if (rv != SECSuccess) { |
| 5362 goto done; /* err code was set by ssl3_ComputeHandshakeHashes */ | 5359 goto done; /* err code was set by ssl3_ComputeHandshakeHashes */ |
| 5363 } | 5360 } |
| 5364 | 5361 |
| 5365 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0); | 5362 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0); |
| 5366 if (ss->ssl3.platformClientKey) { | 5363 if (ss->ssl3.platformClientKey) { |
| 5367 #ifdef NSS_PLATFORM_CLIENT_AUTH | 5364 #ifdef NSS_PLATFORM_CLIENT_AUTH |
| 5368 rv = ssl3_PlatformSignHashes( | 5365 rv = ssl3_PlatformSignHashes( |
| 5369 » &hashes, ss->ssl3.platformClientKey, &buf, isTLS, | 5366 » &hashes, ss->ssl3.platformClientKey, &buf, isTLS, |
| 5370 » CERT_GetCertKeyType(&ss->ssl3.clientCertificate->subjectPublicKeyInf o)); | 5367 » CERT_GetCertKeyType( |
| 5368 » » &ss->ssl3.clientCertificate->subjectPublicKeyInfo)); | |
| 5371 ssl_FreePlatformKey(ss->ssl3.platformClientKey); | 5369 ssl_FreePlatformKey(ss->ssl3.platformClientKey); |
| 5372 ss->ssl3.platformClientKey = (PlatformKey)NULL; | 5370 ss->ssl3.platformClientKey = (PlatformKey)NULL; |
| 5373 #endif /* NSS_PLATFORM_CLIENT_AUTH */ | 5371 #endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 5374 } else { | 5372 } else { |
| 5375 rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS); | 5373 rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS); |
| 5376 if (rv == SECSuccess) { | 5374 if (rv == SECSuccess) { |
| 5377 PK11SlotInfo * slot; | 5375 PK11SlotInfo * slot; |
| 5378 sslSessionID * sid = ss->sec.ci.sid; | 5376 sslSessionID * sid = ss->sec.ci.sid; |
| 5379 | 5377 |
| 5380 /* Remember the info about the slot that did the signing. | 5378 /* Remember the info about the slot that did the signing. |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5734 ss->ssl3.hs.ws = wait_change_cipher; | 5732 ss->ssl3.hs.ws = wait_change_cipher; |
| 5735 | 5733 |
| 5736 ss->ssl3.hs.isResuming = PR_TRUE; | 5734 ss->ssl3.hs.isResuming = PR_TRUE; |
| 5737 | 5735 |
| 5738 /* copy the peer cert from the SID */ | 5736 /* copy the peer cert from the SID */ |
| 5739 if (sid->peerCert != NULL) { | 5737 if (sid->peerCert != NULL) { |
| 5740 ss->sec.peerCert = CERT_DupCertificate(sid->peerCert); | 5738 ss->sec.peerCert = CERT_DupCertificate(sid->peerCert); |
| 5741 ssl3_CopyPeerCertsFromSID(ss, sid); | 5739 ssl3_CopyPeerCertsFromSID(ss, sid); |
| 5742 } | 5740 } |
| 5743 | 5741 |
| 5744 | |
| 5745 /* NULL value for PMS signifies re-use of the old MS */ | 5742 /* NULL value for PMS signifies re-use of the old MS */ |
| 5746 rv = ssl3_InitPendingCipherSpec(ss, NULL); | 5743 rv = ssl3_InitPendingCipherSpec(ss, NULL); |
| 5747 if (rv != SECSuccess) { | 5744 if (rv != SECSuccess) { |
| 5748 goto alert_loser; /* err code was set */ | 5745 goto alert_loser; /* err code was set */ |
| 5749 } | 5746 } |
| 5750 goto winner; | 5747 goto winner; |
| 5751 } while (0); | 5748 } while (0); |
| 5752 | 5749 |
| 5753 if (sid_match) | 5750 if (sid_match) |
| 5754 SSL_AtomicIncrementLong(& ssl3stats.hsh_sid_cache_not_ok ); | 5751 SSL_AtomicIncrementLong(& ssl3stats.hsh_sid_cache_not_ok ); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6179 /* XXX Should pass cert_types in this call!! */ | 6176 /* XXX Should pass cert_types in this call!! */ |
| 6180 rv = (SECStatus)(*ss->getPlatformClientAuthData)( | 6177 rv = (SECStatus)(*ss->getPlatformClientAuthData)( |
| 6181 ss->getPlatformClientAuthDataArg, | 6178 ss->getPlatformClientAuthDataArg, |
| 6182 ss->fd, &ca_list, | 6179 ss->fd, &ca_list, |
| 6183 &platform_cert_list, | 6180 &platform_cert_list, |
| 6184 (void**)&ss->ssl3.platformClientKey, | 6181 (void**)&ss->ssl3.platformClientKey, |
| 6185 &ss->ssl3.clientCertificate, | 6182 &ss->ssl3.clientCertificate, |
| 6186 &ss->ssl3.clientPrivateKey); | 6183 &ss->ssl3.clientPrivateKey); |
| 6187 } else | 6184 } else |
| 6188 #endif | 6185 #endif |
| 6189 if (ss->getClientAuthData == NULL) { | 6186 if (ss->getClientAuthData != NULL) { |
| 6190 » rv = SECFailure; /* force it to send a no_certificate alert */ | |
| 6191 } else { | |
| 6192 /* XXX Should pass cert_types in this call!! */ | 6187 /* XXX Should pass cert_types in this call!! */ |
| 6193 rv = (SECStatus)(*ss->getClientAuthData)(ss->getClientAuthDataArg, | 6188 rv = (SECStatus)(*ss->getClientAuthData)(ss->getClientAuthDataArg, |
| 6194 ss->fd, &ca_list, | 6189 ss->fd, &ca_list, |
| 6195 &ss->ssl3.clientCertificate, | 6190 &ss->ssl3.clientCertificate, |
| 6196 &ss->ssl3.clientPrivateKey); | 6191 &ss->ssl3.clientPrivateKey); |
| 6192 } else { | |
| 6193 rv = SECFailure; /* force it to send a no_certificate alert */ | |
| 6197 } | 6194 } |
| 6198 | 6195 |
| 6199 switch (rv) { | 6196 switch (rv) { |
| 6200 case SECWouldBlock: /* getClientAuthData has put up a dialog box. */ | 6197 case SECWouldBlock: /* getClientAuthData has put up a dialog box. */ |
| 6201 ssl3_SetAlwaysBlock(ss); | 6198 ssl3_SetAlwaysBlock(ss); |
| 6202 break; /* not an error */ | 6199 break; /* not an error */ |
| 6203 | 6200 |
| 6204 case SECSuccess: | 6201 case SECSuccess: |
| 6205 #ifdef NSS_PLATFORM_CLIENT_AUTH | 6202 #ifdef NSS_PLATFORM_CLIENT_AUTH |
| 6206 if (!platform_cert_list || CERT_LIST_EMPTY(platform_cert_list) || | 6203 if (!platform_cert_list || CERT_LIST_EMPTY(platform_cert_list) || |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6698 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) ); | 6695 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) ); |
| 6699 | 6696 |
| 6700 rv = ssl3_SendServerHello(ss); | 6697 rv = ssl3_SendServerHello(ss); |
| 6701 if (rv != SECSuccess) { | 6698 if (rv != SECSuccess) { |
| 6702 return rv; /* err code is set. */ | 6699 return rv; /* err code is set. */ |
| 6703 } | 6700 } |
| 6704 rv = ssl3_SendCertificate(ss); | 6701 rv = ssl3_SendCertificate(ss); |
| 6705 if (rv != SECSuccess) { | 6702 if (rv != SECSuccess) { |
| 6706 return rv; /* error code is set. */ | 6703 return rv; /* error code is set. */ |
| 6707 } | 6704 } |
| 6705 rv = ssl3_SendCertificateStatus(ss); | |
| 6706 if (rv != SECSuccess) { | |
| 6707 return rv; /* error code is set. */ | |
| 6708 } | |
| 6708 /* We have to do this after the call to ssl3_SendServerHello, | 6709 /* We have to do this after the call to ssl3_SendServerHello, |
| 6709 * because kea_def is set up by ssl3_SendServerHello(). | 6710 * because kea_def is set up by ssl3_SendServerHello(). |
| 6710 */ | 6711 */ |
| 6711 kea_def = ss->ssl3.hs.kea_def; | 6712 kea_def = ss->ssl3.hs.kea_def; |
| 6712 ss->ssl3.hs.usedStepDownKey = PR_FALSE; | 6713 ss->ssl3.hs.usedStepDownKey = PR_FALSE; |
| 6713 | 6714 |
| 6714 if (kea_def->is_limited && kea_def->exchKeyType == kt_rsa) { | 6715 if (kea_def->is_limited && kea_def->exchKeyType == kt_rsa) { |
| 6715 /* see if we can legally use the key in the cert. */ | 6716 /* see if we can legally use the key in the cert. */ |
| 6716 int keyLen; /* bytes */ | 6717 int keyLen; /* bytes */ |
| 6717 | 6718 |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8641 #endif | 8642 #endif |
| 8642 if (rv != SECSuccess) { | 8643 if (rv != SECSuccess) { |
| 8643 return rv; /* err set by AppendHandshake. */ | 8644 return rv; /* err set by AppendHandshake. */ |
| 8644 } | 8645 } |
| 8645 } | 8646 } |
| 8646 } | 8647 } |
| 8647 | 8648 |
| 8648 return SECSuccess; | 8649 return SECSuccess; |
| 8649 } | 8650 } |
| 8650 | 8651 |
| 8652 /* | |
| 8653 * Used by server only. | |
| 8654 * single-stapling, send only a single cert status | |
| 8655 */ | |
| 8656 static SECStatus | |
| 8657 ssl3_SendCertificateStatus(sslSocket *ss) | |
| 8658 { | |
| 8659 SECStatus rv; | |
| 8660 int len = 0; | |
| 8661 | |
| 8662 SSL_TRC(3, ("%d: SSL3[%d]: send certificate status handshake", | |
| 8663 SSL_GETPID(), ss->fd)); | |
| 8664 | |
| 8665 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss)); | |
| 8666 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); | |
| 8667 | |
| 8668 if (!ssl3_ExtensionNegotiated(ss, ssl_cert_status_xtn)) | |
| 8669 return SECSuccess; | |
| 8670 | |
| 8671 if (!ss->certStatusArray) | |
|
Ryan Sleevi
2013/05/01 19:06:08
nit: It seems to me that ss->certStatusArray->len
wtc
2013/05/01 21:52:16
I can fix this problem in the NSS upstream.
| |
| 8672 return SECSuccess; | |
| 8673 | |
| 8674 /* Use the array's first item only (single stapling) */ | |
| 8675 len = 1 + ss->certStatusArray->items[0].len + 3; | |
| 8676 | |
| 8677 rv = ssl3_AppendHandshakeHeader(ss, certificate_status, len); | |
| 8678 if (rv != SECSuccess) { | |
| 8679 return rv; /* err set by AppendHandshake. */ | |
| 8680 } | |
| 8681 rv = ssl3_AppendHandshakeNumber(ss, 1 /*ocsp*/, 1); | |
| 8682 if (rv != SECSuccess) | |
| 8683 return rv; /* err set by AppendHandshake. */ | |
| 8684 | |
| 8685 rv = ssl3_AppendHandshakeVariable(ss, | |
| 8686 ss->certStatusArray->items[0].data, | |
| 8687 ss->certStatusArray->items[0].len, | |
| 8688 3); | |
| 8689 if (rv != SECSuccess) | |
| 8690 return rv; /* err set by AppendHandshake. */ | |
| 8691 | |
| 8692 return SECSuccess; | |
| 8693 } | |
| 8694 | |
| 8651 /* This is used to delete the CA certificates in the peer certificate chain | 8695 /* This is used to delete the CA certificates in the peer certificate chain |
| 8652 * from the cert database after they've been validated. | 8696 * from the cert database after they've been validated. |
| 8653 */ | 8697 */ |
| 8654 static void | 8698 static void |
| 8655 ssl3_CleanupPeerCerts(sslSocket *ss) | 8699 ssl3_CleanupPeerCerts(sslSocket *ss) |
| 8656 { | 8700 { |
| 8657 PRArenaPool * arena = ss->ssl3.peerCertArena; | 8701 PRArenaPool * arena = ss->ssl3.peerCertArena; |
| 8658 ssl3CertNode *certs = (ssl3CertNode *)ss->ssl3.peerCertChain; | 8702 ssl3CertNode *certs = (ssl3CertNode *)ss->ssl3.peerCertChain; |
| 8659 | 8703 |
| 8660 for (; certs; certs = certs->next) { | 8704 for (; certs; certs = certs->next) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8706 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete | 8750 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete |
| 8707 * ssl3 CertificateStatus message. | 8751 * ssl3 CertificateStatus message. |
| 8708 * Caller must hold Handshake and RecvBuf locks. | 8752 * Caller must hold Handshake and RecvBuf locks. |
| 8709 * This is always called before ssl3_HandleCertificate, even if the Certificate | 8753 * This is always called before ssl3_HandleCertificate, even if the Certificate |
| 8710 * message is sent first. | 8754 * message is sent first. |
| 8711 */ | 8755 */ |
| 8712 static SECStatus | 8756 static SECStatus |
| 8713 ssl3_HandleCertificateStatus(sslSocket *ss, SSL3Opaque *b, PRUint32 length) | 8757 ssl3_HandleCertificateStatus(sslSocket *ss, SSL3Opaque *b, PRUint32 length) |
| 8714 { | 8758 { |
| 8715 PRInt32 status, len; | 8759 PRInt32 status, len; |
| 8716 int errCode; | 8760 PORT_Assert(ss->ssl3.hs.ws == wait_certificate_status); |
| 8717 SSL3AlertDescription desc; | |
| 8718 | |
| 8719 if (!ss->ssl3.hs.may_get_cert_status || | |
| 8720 » ss->ssl3.hs.ws != wait_server_cert || | |
| 8721 » !ss->ssl3.hs.pending_cert_msg.data || | |
| 8722 » ss->ssl3.hs.cert_status.data) { | |
| 8723 » errCode = SSL_ERROR_RX_UNEXPECTED_CERT_STATUS; | |
| 8724 » desc = unexpected_message; | |
| 8725 » goto alert_loser; | |
| 8726 } | |
| 8727 | 8761 |
| 8728 /* Consume the CertificateStatusType enum */ | 8762 /* Consume the CertificateStatusType enum */ |
| 8729 status = ssl3_ConsumeHandshakeNumber(ss, 1, &b, &length); | 8763 status = ssl3_ConsumeHandshakeNumber(ss, 1, &b, &length); |
| 8730 if (status != 1 /* ocsp */) { | 8764 if (status != 1 /* ocsp */) { |
| 8731 » goto format_loser; | 8765 goto format_loser; |
| 8732 } | 8766 } |
| 8733 | 8767 |
| 8734 len = ssl3_ConsumeHandshakeNumber(ss, 3, &b, &length); | 8768 len = ssl3_ConsumeHandshakeNumber(ss, 3, &b, &length); |
| 8735 if (len != length) { | 8769 if (len != length) { |
| 8736 » goto format_loser; | 8770 goto format_loser; |
| 8737 } | 8771 } |
| 8738 | 8772 |
| 8739 if (SECITEM_AllocItem(NULL, &ss->ssl3.hs.cert_status, length) == NULL) { | 8773 #define MAX_CERTSTATUS_LEN 0x1ffff /* 128k - 1 */ |
| 8774 if (length > MAX_CERTSTATUS_LEN) | |
| 8775 goto format_loser; | |
| 8776 #undef MAX_CERTSTATUS_LEN | |
|
Ryan Sleevi
2013/05/01 19:06:08
rant: I have no idea why Kai did this.
The NSS co
wtc
2013/05/01 21:52:16
I looked into this. bsmith suggested using a small
Ryan Sleevi
2013/05/01 23:22:57
I'm not sure I agree. |b| (SSL3Opaque) already con
| |
| 8777 | |
| 8778 /* Array size 1, because we currently implement single-stapling only*/ | |
| 8779 SECITEM_AllocArray(NULL, &ss->sec.ci.sid->peerCertStatus, 1); | |
| 8780 if (!ss->sec.ci.sid->peerCertStatus.items) | |
| 8781 return SECFailure; | |
| 8782 | |
| 8783 ss->sec.ci.sid->peerCertStatus.items[0].data = PORT_Alloc(length); | |
| 8784 | |
| 8785 if (!ss->sec.ci.sid->peerCertStatus.items[0].data) { | |
| 8786 SECITEM_FreeArray(&ss->sec.ci.sid->peerCertStatus, PR_FALSE); | |
|
Ryan Sleevi
2013/05/01 19:06:08
See how this does not zero-out peerCertStatus, but
| |
| 8740 return SECFailure; | 8787 return SECFailure; |
| 8741 } | 8788 } |
| 8742 ss->ssl3.hs.cert_status.type = siBuffer; | |
| 8743 PORT_Memcpy(ss->ssl3.hs.cert_status.data, b, length); | |
| 8744 | 8789 |
| 8790 PORT_Memcpy(ss->sec.ci.sid->peerCertStatus.items[0].data, b, length); | |
| 8791 ss->sec.ci.sid->peerCertStatus.items[0].len = length; | |
| 8792 ss->sec.ci.sid->peerCertStatus.items[0].type = siBuffer; | |
| 8745 return SECSuccess; | 8793 return SECSuccess; |
| 8746 | 8794 |
| 8747 format_loser: | 8795 format_loser: |
| 8748 errCode = SSL_ERROR_BAD_CERT_STATUS_RESPONSE_ALERT; | 8796 return ssl3_DecodeError(ss); |
| 8749 desc = bad_certificate_status_response; | 8797 } |
| 8750 | 8798 |
| 8751 alert_loser: | 8799 static SECStatus ssl3_AuthCertificate(sslSocket *ss); |
| 8752 (void)SSL3_SendAlert(ss, alert_fatal, desc); | |
| 8753 (void)ssl_MapLowLevelError(errCode); | |
| 8754 return SECFailure; | |
| 8755 } | |
| 8756 | 8800 |
| 8757 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete | 8801 /* Called from ssl3_HandleHandshakeMessage() when it has deciphered a complete |
| 8758 * ssl3 Certificate message. | 8802 * ssl3 Certificate message. |
| 8759 * Caller must hold Handshake and RecvBuf locks. | 8803 * Caller must hold Handshake and RecvBuf locks. |
| 8760 */ | 8804 */ |
| 8761 static SECStatus | 8805 static SECStatus |
| 8762 ssl3_HandleCertificate(sslSocket *ss, SSL3Opaque *b, PRUint32 length) | 8806 ssl3_HandleCertificate(sslSocket *ss, SSL3Opaque *b, PRUint32 length) |
| 8763 { | 8807 { |
| 8764 ssl3CertNode * c; | 8808 ssl3CertNode * c; |
| 8765 ssl3CertNode * lastCert = NULL; | 8809 ssl3CertNode * lastCert = NULL; |
| 8766 PRInt32 remaining = 0; | 8810 PRInt32 remaining = 0; |
| 8767 PRInt32 size; | 8811 PRInt32 size; |
| 8768 SECStatus rv; | 8812 SECStatus rv; |
| 8769 PRBool isServer = (PRBool)(!!ss->sec.isServer); | 8813 PRBool isServer = (PRBool)(!!ss->sec.isServer); |
| 8770 PRBool trusted = PR_FALSE; | |
| 8771 PRBool isTLS; | 8814 PRBool isTLS; |
| 8772 SSL3AlertDescription desc; | 8815 SSL3AlertDescription desc; |
| 8773 int errCode = SSL_ERROR_RX_MALFORMED_CERTIFICATE; | 8816 int errCode = SSL_ERROR_RX_MALFORMED_CERTIFICATE; |
| 8774 SECItem certItem; | 8817 SECItem certItem; |
| 8775 | 8818 |
| 8776 SSL_TRC(3, ("%d: SSL3[%d]: handle certificate handshake", | 8819 SSL_TRC(3, ("%d: SSL3[%d]: handle certificate handshake", |
| 8777 SSL_GETPID(), ss->fd)); | 8820 SSL_GETPID(), ss->fd)); |
| 8778 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); | 8821 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); |
| 8779 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); | 8822 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); |
| 8780 | 8823 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 8803 */ | 8846 */ |
| 8804 if (length) { | 8847 if (length) { |
| 8805 remaining = ssl3_ConsumeHandshakeNumber(ss, 3, &b, &length); | 8848 remaining = ssl3_ConsumeHandshakeNumber(ss, 3, &b, &length); |
| 8806 if (remaining < 0) | 8849 if (remaining < 0) |
| 8807 goto loser; /* fatal alert already sent by ConsumeHandshake. */ | 8850 goto loser; /* fatal alert already sent by ConsumeHandshake. */ |
| 8808 if ((PRUint32)remaining > length) | 8851 if ((PRUint32)remaining > length) |
| 8809 goto decode_loser; | 8852 goto decode_loser; |
| 8810 } | 8853 } |
| 8811 | 8854 |
| 8812 if (!remaining) { | 8855 if (!remaining) { |
| 8813 » if (!(isTLS && isServer)) | 8856 » if (!(isTLS && isServer)) { |
| 8857 » desc = bad_certificate; | |
| 8814 goto alert_loser; | 8858 goto alert_loser; |
| 8859 } | |
| 8815 /* This is TLS's version of a no_certificate alert. */ | 8860 /* This is TLS's version of a no_certificate alert. */ |
| 8816 /* I'm a server. I've requested a client cert. He hasn't got one. */ | 8861 /* I'm a server. I've requested a client cert. He hasn't got one. */ |
| 8817 rv = ssl3_HandleNoCertificate(ss); | 8862 rv = ssl3_HandleNoCertificate(ss); |
| 8818 if (rv != SECSuccess) { | 8863 if (rv != SECSuccess) { |
| 8819 errCode = PORT_GetError(); | 8864 errCode = PORT_GetError(); |
| 8820 goto loser; | 8865 goto loser; |
| 8821 } | 8866 } |
| 8822 » goto server_no_cert; | 8867 ss->ssl3.hs.ws = wait_client_key; |
| 8868 return SECSuccess; | |
| 8823 } | 8869 } |
| 8824 | 8870 |
| 8825 ss->ssl3.peerCertArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 8871 ss->ssl3.peerCertArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
| 8826 if (ss->ssl3.peerCertArena == NULL) { | 8872 if (ss->ssl3.peerCertArena == NULL) { |
| 8827 goto loser; /* don't send alerts on memory errors */ | 8873 goto loser; /* don't send alerts on memory errors */ |
| 8828 } | 8874 } |
| 8829 | 8875 |
| 8830 /* First get the peer cert. */ | 8876 /* First get the peer cert. */ |
| 8831 remaining -= 3; | 8877 remaining -= 3; |
| 8832 if (remaining < 0) | 8878 if (remaining < 0) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8877 if (c == NULL) { | 8923 if (c == NULL) { |
| 8878 goto loser; /* don't send alerts on memory errors */ | 8924 goto loser; /* don't send alerts on memory errors */ |
| 8879 } | 8925 } |
| 8880 | 8926 |
| 8881 c->cert = CERT_NewTempCertificate(ss->dbHandle, &certItem, NULL, | 8927 c->cert = CERT_NewTempCertificate(ss->dbHandle, &certItem, NULL, |
| 8882 PR_FALSE, PR_TRUE); | 8928 PR_FALSE, PR_TRUE); |
| 8883 if (c->cert == NULL) { | 8929 if (c->cert == NULL) { |
| 8884 goto ambiguous_err; | 8930 goto ambiguous_err; |
| 8885 } | 8931 } |
| 8886 | 8932 |
| 8887 if (c->cert->trust) | |
| 8888 trusted = PR_TRUE; | |
| 8889 | |
| 8890 c->next = NULL; | 8933 c->next = NULL; |
| 8891 if (lastCert) { | 8934 if (lastCert) { |
| 8892 lastCert->next = c; | 8935 lastCert->next = c; |
| 8893 } else { | 8936 } else { |
| 8894 ss->ssl3.peerCertChain = c; | 8937 ss->ssl3.peerCertChain = c; |
| 8895 } | 8938 } |
| 8896 lastCert = c; | 8939 lastCert = c; |
| 8897 } | 8940 } |
| 8898 | 8941 |
| 8899 if (remaining != 0) | 8942 if (remaining != 0) |
| 8900 goto decode_loser; | 8943 goto decode_loser; |
| 8901 | 8944 |
| 8902 SECKEY_UpdateCertPQG(ss->sec.peerCert); | 8945 SECKEY_UpdateCertPQG(ss->sec.peerCert); |
| 8903 | 8946 |
| 8947 if (!isServer && ssl3_ExtensionNegotiated(ss, ssl_cert_status_xtn)) { | |
| 8948 ss->ssl3.hs.ws = wait_certificate_status; | |
| 8949 rv = SECSuccess; | |
| 8950 } else { | |
| 8951 rv = ssl3_AuthCertificate(ss); /* sets ss->ssl3.hs.ws */ | |
| 8952 } | |
| 8953 | |
| 8954 return rv; | |
| 8955 | |
| 8956 ambiguous_err: | |
| 8957 errCode = PORT_GetError(); | |
| 8958 switch (errCode) { | |
| 8959 case PR_OUT_OF_MEMORY_ERROR: | |
| 8960 case SEC_ERROR_BAD_DATABASE: | |
| 8961 case SEC_ERROR_NO_MEMORY: | |
| 8962 if (isTLS) { | |
| 8963 desc = internal_error; | |
| 8964 goto alert_loser; | |
| 8965 } | |
| 8966 goto loser; | |
| 8967 } | |
| 8968 ssl3_SendAlertForCertError(ss, errCode); | |
| 8969 goto loser; | |
| 8970 | |
| 8971 decode_loser: | |
| 8972 desc = isTLS ? decode_error : bad_certificate; | |
| 8973 | |
| 8974 alert_loser: | |
| 8975 (void)SSL3_SendAlert(ss, alert_fatal, desc); | |
| 8976 | |
| 8977 loser: | |
| 8978 (void)ssl_MapLowLevelError(errCode); | |
| 8979 return SECFailure; | |
| 8980 } | |
| 8981 | |
| 8982 static SECStatus | |
| 8983 ssl3_AuthCertificate(sslSocket *ss) | |
| 8984 { | |
| 8985 SECStatus rv; | |
| 8986 PRBool isServer = (PRBool)(!!ss->sec.isServer); | |
| 8987 int errCode; | |
| 8988 | |
| 8904 ss->ssl3.hs.authCertificatePending = PR_FALSE; | 8989 ss->ssl3.hs.authCertificatePending = PR_FALSE; |
| 8905 | 8990 |
| 8906 /* | 8991 /* |
| 8907 * Ask caller-supplied callback function to validate cert chain. | 8992 * Ask caller-supplied callback function to validate cert chain. |
| 8908 */ | 8993 */ |
| 8909 rv = (SECStatus)(*ss->authCertificate)(ss->authCertificateArg, ss->fd, | 8994 rv = (SECStatus)(*ss->authCertificate)(ss->authCertificateArg, ss->fd, |
| 8910 PR_TRUE, isServer); | 8995 PR_TRUE, isServer); |
| 8911 if (rv) { | 8996 if (rv) { |
| 8912 errCode = PORT_GetError(); | 8997 errCode = PORT_GetError(); |
| 8913 if (rv != SECWouldBlock) { | 8998 if (rv != SECWouldBlock) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8991 if (ss->ssl3.hs.kea_def->is_limited || | 9076 if (ss->ssl3.hs.kea_def->is_limited || |
| 8992 /* XXX OR server cert is signing only. */ | 9077 /* XXX OR server cert is signing only. */ |
| 8993 #ifdef NSS_ENABLE_ECC | 9078 #ifdef NSS_ENABLE_ECC |
| 8994 ss->ssl3.hs.kea_def->kea == kea_ecdhe_ecdsa || | 9079 ss->ssl3.hs.kea_def->kea == kea_ecdhe_ecdsa || |
| 8995 ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa || | 9080 ss->ssl3.hs.kea_def->kea == kea_ecdhe_rsa || |
| 8996 #endif /* NSS_ENABLE_ECC */ | 9081 #endif /* NSS_ENABLE_ECC */ |
| 8997 ss->ssl3.hs.kea_def->exchKeyType == kt_dh) { | 9082 ss->ssl3.hs.kea_def->exchKeyType == kt_dh) { |
| 8998 ss->ssl3.hs.ws = wait_server_key; /* allow server_key_exchange */ | 9083 ss->ssl3.hs.ws = wait_server_key; /* allow server_key_exchange */ |
| 8999 } | 9084 } |
| 9000 } else { | 9085 } else { |
| 9001 server_no_cert: | |
| 9002 ss->ssl3.hs.ws = wait_client_key; | 9086 ss->ssl3.hs.ws = wait_client_key; |
| 9003 } | 9087 } |
| 9004 | 9088 |
| 9005 PORT_Assert(rv == SECSuccess); | 9089 PORT_Assert(rv == SECSuccess); |
| 9006 if (rv != SECSuccess) { | 9090 if (rv != SECSuccess) { |
| 9007 errCode = SEC_ERROR_LIBRARY_FAILURE; | 9091 errCode = SEC_ERROR_LIBRARY_FAILURE; |
| 9008 rv = SECFailure; | 9092 rv = SECFailure; |
| 9009 goto loser; | 9093 goto loser; |
| 9010 } | 9094 } |
| 9011 | 9095 |
| 9012 return rv; | 9096 return rv; |
| 9013 | 9097 |
| 9014 ambiguous_err: | |
| 9015 errCode = PORT_GetError(); | |
| 9016 switch (errCode) { | |
| 9017 case PR_OUT_OF_MEMORY_ERROR: | |
| 9018 case SEC_ERROR_BAD_DATABASE: | |
| 9019 case SEC_ERROR_NO_MEMORY: | |
| 9020 if (isTLS) { | |
| 9021 desc = internal_error; | |
| 9022 goto alert_loser; | |
| 9023 } | |
| 9024 goto loser; | |
| 9025 } | |
| 9026 ssl3_SendAlertForCertError(ss, errCode); | |
| 9027 goto loser; | |
| 9028 | |
| 9029 decode_loser: | |
| 9030 desc = isTLS ? decode_error : bad_certificate; | |
| 9031 | |
| 9032 alert_loser: | |
| 9033 (void)SSL3_SendAlert(ss, alert_fatal, desc); | |
| 9034 | |
| 9035 loser: | 9098 loser: |
| 9036 ssl3_CleanupPeerCerts(ss); | |
| 9037 | |
| 9038 if (ss->sec.peerCert != NULL) { | |
| 9039 CERT_DestroyCertificate(ss->sec.peerCert); | |
| 9040 ss->sec.peerCert = NULL; | |
| 9041 } | |
| 9042 (void)ssl_MapLowLevelError(errCode); | 9099 (void)ssl_MapLowLevelError(errCode); |
| 9043 return SECFailure; | 9100 return SECFailure; |
| 9044 } | 9101 } |
| 9045 | 9102 |
| 9046 static SECStatus ssl3_FinishHandshake(sslSocket *ss); | 9103 static SECStatus ssl3_FinishHandshake(sslSocket *ss); |
| 9047 | 9104 |
| 9048 static SECStatus | 9105 static SECStatus |
| 9049 ssl3_AlwaysFail(sslSocket * ss) | 9106 ssl3_AlwaysFail(sslSocket * ss) |
| 9050 { | 9107 { |
| 9051 PORT_SetError(PR_INVALID_STATE_ERROR); | 9108 PORT_SetError(PR_INVALID_STATE_ERROR); |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9794 ss->ssl3.hs.ws = idle_handshake; | 9851 ss->ssl3.hs.ws = idle_handshake; |
| 9795 | 9852 |
| 9796 /* Do the handshake callback for sslv3 here, if we cannot false start. */ | 9853 /* Do the handshake callback for sslv3 here, if we cannot false start. */ |
| 9797 if (ss->handshakeCallback != NULL && !ssl3_CanFalseStart(ss)) { | 9854 if (ss->handshakeCallback != NULL && !ssl3_CanFalseStart(ss)) { |
| 9798 (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); | 9855 (ss->handshakeCallback)(ss->fd, ss->handshakeCallbackData); |
| 9799 } | 9856 } |
| 9800 | 9857 |
| 9801 return SECSuccess; | 9858 return SECSuccess; |
| 9802 } | 9859 } |
| 9803 | 9860 |
| 9804 /* This function handles any pending Certificate messages. Certificate messages | |
| 9805 * can be pending if we expect a possible CertificateStatus message to follow. | |
| 9806 * | |
| 9807 * This function must be called immediately after handling the | |
| 9808 * CertificateStatus message, and before handling any ServerKeyExchange or | |
| 9809 * CertificateRequest messages. | |
| 9810 */ | |
| 9811 static SECStatus | |
| 9812 ssl3_MaybeHandlePendingCertificateMessage(sslSocket *ss) | |
| 9813 { | |
| 9814 SECStatus rv = SECSuccess; | |
| 9815 | |
| 9816 if (ss->ssl3.hs.pending_cert_msg.data) { | |
| 9817 rv = ssl3_HandleCertificate(ss, ss->ssl3.hs.pending_cert_msg.data, | |
| 9818 ss->ssl3.hs.pending_cert_msg.len); | |
| 9819 SECITEM_FreeItem(&ss->ssl3.hs.pending_cert_msg, PR_FALSE); | |
| 9820 } | |
| 9821 return rv; | |
| 9822 } | |
| 9823 | |
| 9824 /* Called from ssl3_HandleHandshake() when it has gathered a complete ssl3 | 9861 /* Called from ssl3_HandleHandshake() when it has gathered a complete ssl3 |
| 9825 * hanshake message. | 9862 * hanshake message. |
| 9826 * Caller must hold Handshake and RecvBuf locks. | 9863 * Caller must hold Handshake and RecvBuf locks. |
| 9827 */ | 9864 */ |
| 9828 SECStatus | 9865 SECStatus |
| 9829 ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length) | 9866 ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length) |
| 9830 { | 9867 { |
| 9831 SECStatus rv = SECSuccess; | 9868 SECStatus rv = SECSuccess; |
| 9832 SSL3HandshakeType type = ss->ssl3.hs.msg_type; | 9869 SSL3HandshakeType type = ss->ssl3.hs.msg_type; |
| 9833 SSL3Hashes hashes; /* computed hashes are put here. */ | 9870 SSL3Hashes hashes; /* computed hashes are put here. */ |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9903 sizeof(dtlsData)); | 9940 sizeof(dtlsData)); |
| 9904 if (rv != SECSuccess) return rv; /* err code already set. */ | 9941 if (rv != SECSuccess) return rv; /* err code already set. */ |
| 9905 } | 9942 } |
| 9906 | 9943 |
| 9907 /* The message body */ | 9944 /* The message body */ |
| 9908 rv = ssl3_UpdateHandshakeHashes(ss, b, length); | 9945 rv = ssl3_UpdateHandshakeHashes(ss, b, length); |
| 9909 if (rv != SECSuccess) return rv; /* err code already set. */ | 9946 if (rv != SECSuccess) return rv; /* err code already set. */ |
| 9910 } | 9947 } |
| 9911 | 9948 |
| 9912 PORT_SetError(0); /* each message starts with no error. */ | 9949 PORT_SetError(0); /* each message starts with no error. */ |
| 9913 switch (ss->ssl3.hs.msg_type) { | 9950 |
| 9951 /* The CertificateStatus message is optional. We process the message if we | |
| 9952 * get one when it is allowed, but otherwise we just carry on. | |
| 9953 */ | |
| 9954 if (ss->ssl3.hs.ws == wait_certificate_status) { | |
| 9955 /* We must process any CertificateStatus message before we call | |
| 9956 * ssl3_AuthCertificate, as ssl3_AuthCertificate needs any stapled OCSP | |
| 9957 * response we get. | |
| 9958 */ | |
| 9959 if (ss->ssl3.hs.msg_type == certificate_status) { | |
| 9960 rv = ssl3_HandleCertificateStatus(ss, b, length); | |
| 9961 if (rv != SECSuccess) | |
| 9962 return rv; | |
| 9963 } | |
| 9964 | |
| 9965 /* Regardless of whether we got a CertificateStatus message, we must | |
| 9966 * authenticate the cert before we handle any more handshake messages. | |
| 9967 */ | |
| 9968 rv = ssl3_AuthCertificate(ss); /* sets ss->ssl3.hs.ws */ | |
| 9969 } else switch (ss->ssl3.hs.msg_type) { | |
|
Ryan Sleevi
2013/05/01 19:06:08
totally unnecessary rant: I really dislike this st
wtc
2013/05/01 21:52:16
I also hate this. I know why the author did this:
| |
| 9914 case hello_request: | 9970 case hello_request: |
| 9915 if (length != 0) { | 9971 if (length != 0) { |
| 9916 (void)ssl3_DecodeError(ss); | 9972 (void)ssl3_DecodeError(ss); |
| 9917 PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_REQUEST); | 9973 PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_REQUEST); |
| 9918 return SECFailure; | 9974 return SECFailure; |
| 9919 } | 9975 } |
| 9920 if (ss->sec.isServer) { | 9976 if (ss->sec.isServer) { |
| 9921 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); | 9977 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); |
| 9922 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_HELLO_REQUEST); | 9978 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_HELLO_REQUEST); |
| 9923 return SECFailure; | 9979 return SECFailure; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 9942 break; | 9998 break; |
| 9943 case hello_verify_request: | 9999 case hello_verify_request: |
| 9944 if (!IS_DTLS(ss) || ss->sec.isServer) { | 10000 if (!IS_DTLS(ss) || ss->sec.isServer) { |
| 9945 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); | 10001 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); |
| 9946 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST); | 10002 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST); |
| 9947 return SECFailure; | 10003 return SECFailure; |
| 9948 } | 10004 } |
| 9949 rv = dtls_HandleHelloVerifyRequest(ss, b, length); | 10005 rv = dtls_HandleHelloVerifyRequest(ss, b, length); |
| 9950 break; | 10006 break; |
| 9951 case certificate: | 10007 case certificate: |
| 9952 if (ss->ssl3.hs.may_get_cert_status) { | |
| 9953 /* If we might get a CertificateStatus then we want to postpone the | |
| 9954 * processing of the Certificate message until after we have | |
| 9955 * processed the CertificateStatus */ | |
| 9956 if (ss->ssl3.hs.pending_cert_msg.data || | |
| 9957 ss->ssl3.hs.ws != wait_server_cert) { | |
| 9958 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); | |
| 9959 (void)ssl_MapLowLevelError(SSL_ERROR_RX_UNEXPECTED_CERTIFICATE); | |
| 9960 return SECFailure; | |
| 9961 } | |
| 9962 if (SECITEM_AllocItem(NULL, &ss->ssl3.hs.pending_cert_msg, | |
| 9963 length) == NULL) { | |
| 9964 return SECFailure; | |
| 9965 } | |
| 9966 ss->ssl3.hs.pending_cert_msg.type = siBuffer; | |
| 9967 PORT_Memcpy(ss->ssl3.hs.pending_cert_msg.data, b, length); | |
| 9968 break; | |
| 9969 } | |
| 9970 rv = ssl3_HandleCertificate(ss, b, length); | 10008 rv = ssl3_HandleCertificate(ss, b, length); |
| 9971 break; | 10009 break; |
| 9972 case certificate_status: | 10010 case certificate_status: |
| 9973 » rv = ssl3_HandleCertificateStatus(ss, b, length); | 10011 /* The good case is handled above */ |
| 9974 » if (rv != SECSuccess) | 10012 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_CERT_STATUS); |
| 9975 » break; | 10013 rv = SECFailure; |
| 9976 » PORT_Assert(ss->ssl3.hs.pending_cert_msg.data); | 10014 break; |
| 9977 » rv = ssl3_MaybeHandlePendingCertificateMessage(ss); | |
| 9978 » break; | |
| 9979 case server_key_exchange: | 10015 case server_key_exchange: |
| 9980 if (ss->sec.isServer) { | 10016 if (ss->sec.isServer) { |
| 9981 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); | 10017 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); |
| 9982 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_SERVER_KEY_EXCH); | 10018 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_SERVER_KEY_EXCH); |
| 9983 return SECFailure; | 10019 return SECFailure; |
| 9984 } | 10020 } |
| 9985 rv = ssl3_MaybeHandlePendingCertificateMessage(ss); | |
| 9986 if (rv != SECSuccess) | |
| 9987 break; | |
| 9988 rv = ssl3_HandleServerKeyExchange(ss, b, length); | 10021 rv = ssl3_HandleServerKeyExchange(ss, b, length); |
| 9989 break; | 10022 break; |
| 9990 case certificate_request: | 10023 case certificate_request: |
| 9991 if (ss->sec.isServer) { | 10024 if (ss->sec.isServer) { |
| 9992 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); | 10025 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); |
| 9993 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_CERT_REQUEST); | 10026 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_CERT_REQUEST); |
| 9994 return SECFailure; | 10027 return SECFailure; |
| 9995 } | 10028 } |
| 9996 rv = ssl3_MaybeHandlePendingCertificateMessage(ss); | |
| 9997 if (rv != SECSuccess) | |
| 9998 break; | |
| 9999 rv = ssl3_HandleCertificateRequest(ss, b, length); | 10029 rv = ssl3_HandleCertificateRequest(ss, b, length); |
| 10000 break; | 10030 break; |
| 10001 case server_hello_done: | 10031 case server_hello_done: |
| 10002 if (length != 0) { | 10032 if (length != 0) { |
| 10003 (void)ssl3_DecodeError(ss); | 10033 (void)ssl3_DecodeError(ss); |
| 10004 PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_DONE); | 10034 PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_DONE); |
| 10005 return SECFailure; | 10035 return SECFailure; |
| 10006 } | 10036 } |
| 10007 if (ss->sec.isServer) { | 10037 if (ss->sec.isServer) { |
| 10008 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); | 10038 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); |
| 10009 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_HELLO_DONE); | 10039 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_HELLO_DONE); |
| 10010 return SECFailure; | 10040 return SECFailure; |
| 10011 } | 10041 } |
| 10012 rv = ssl3_MaybeHandlePendingCertificateMessage(ss); | |
| 10013 if (rv != SECSuccess) | |
| 10014 break; | |
| 10015 rv = ssl3_HandleServerHelloDone(ss); | 10042 rv = ssl3_HandleServerHelloDone(ss); |
| 10016 break; | 10043 break; |
| 10017 case certificate_verify: | 10044 case certificate_verify: |
| 10018 if (!ss->sec.isServer) { | 10045 if (!ss->sec.isServer) { |
| 10019 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); | 10046 (void)SSL3_SendAlert(ss, alert_fatal, unexpected_message); |
| 10020 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_CERT_VERIFY); | 10047 PORT_SetError(SSL_ERROR_RX_UNEXPECTED_CERT_VERIFY); |
| 10021 return SECFailure; | 10048 return SECFailure; |
| 10022 } | 10049 } |
| 10023 rv = ssl3_HandleCertificateVerify(ss, b, length, &hashes); | 10050 rv = ssl3_HandleCertificateVerify(ss, b, length, &hashes); |
| 10024 break; | 10051 break; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10179 return SECSuccess; | 10206 return SECSuccess; |
| 10180 } | 10207 } |
| 10181 | 10208 |
| 10182 /* These macros return the given value with the MSB copied to all the other | 10209 /* These macros return the given value with the MSB copied to all the other |
| 10183 * bits. They use the fact that arithmetic shift shifts-in the sign bit. | 10210 * bits. They use the fact that arithmetic shift shifts-in the sign bit. |
| 10184 * However, this is not ensured by the C standard so you may need to replace | 10211 * However, this is not ensured by the C standard so you may need to replace |
| 10185 * them with something else for odd compilers. */ | 10212 * them with something else for odd compilers. */ |
| 10186 #define DUPLICATE_MSB_TO_ALL(x) ( (unsigned)( (int)(x) >> (sizeof(int)*8-1) ) ) | 10213 #define DUPLICATE_MSB_TO_ALL(x) ( (unsigned)( (int)(x) >> (sizeof(int)*8-1) ) ) |
| 10187 #define DUPLICATE_MSB_TO_ALL_8(x) ((unsigned char)(DUPLICATE_MSB_TO_ALL(x))) | 10214 #define DUPLICATE_MSB_TO_ALL_8(x) ((unsigned char)(DUPLICATE_MSB_TO_ALL(x))) |
| 10188 | 10215 |
| 10189 /* SECStatusToMask returns, in constant time, a mask value of all ones if rv == | 10216 /* SECStatusToMask returns, in constant time, a mask value of all ones if |
| 10190 * SECSuccess. Otherwise it returns zero. */ | 10217 * rv == SECSuccess. Otherwise it returns zero. */ |
| 10191 static unsigned SECStatusToMask(SECStatus rv) | 10218 static unsigned int |
| 10219 SECStatusToMask(SECStatus rv) | |
| 10192 { | 10220 { |
| 10193 unsigned int good; | 10221 unsigned int good; |
| 10194 /* rv ^ SECSuccess is zero iff rv == SECSuccess. Subtracting one results in | 10222 /* rv ^ SECSuccess is zero iff rv == SECSuccess. Subtracting one results |
| 10195 * the MSB being set to one iff it was zero before. */ | 10223 * in the MSB being set to one iff it was zero before. */ |
| 10196 good = rv ^ SECSuccess; | 10224 good = rv ^ SECSuccess; |
| 10197 good--; | 10225 good--; |
| 10198 return DUPLICATE_MSB_TO_ALL(good); | 10226 return DUPLICATE_MSB_TO_ALL(good); |
| 10199 } | 10227 } |
| 10200 | 10228 |
| 10201 /* ssl_ConstantTimeGE returns 0xff if a>=b and 0x00 otherwise. */ | 10229 /* ssl_ConstantTimeGE returns 0xff if a>=b and 0x00 otherwise. */ |
| 10202 static unsigned char ssl_ConstantTimeGE(unsigned a, unsigned b) | 10230 static unsigned char |
| 10231 ssl_ConstantTimeGE(unsigned int a, unsigned int b) | |
| 10203 { | 10232 { |
| 10204 a -= b; | 10233 a -= b; |
| 10205 return DUPLICATE_MSB_TO_ALL(~a); | 10234 return DUPLICATE_MSB_TO_ALL(~a); |
| 10206 } | 10235 } |
| 10207 | 10236 |
| 10208 /* ssl_ConstantTimeEQ8 returns 0xff if a==b and 0x00 otherwise. */ | 10237 /* ssl_ConstantTimeEQ8 returns 0xff if a==b and 0x00 otherwise. */ |
| 10209 static unsigned char ssl_ConstantTimeEQ8(unsigned char a, unsigned char b) | 10238 static unsigned char |
| 10239 ssl_ConstantTimeEQ8(unsigned char a, unsigned char b) | |
| 10210 { | 10240 { |
| 10211 unsigned c = a ^ b; | 10241 unsigned int c = a ^ b; |
| 10212 c--; | 10242 c--; |
| 10213 return DUPLICATE_MSB_TO_ALL_8(c); | 10243 return DUPLICATE_MSB_TO_ALL_8(c); |
| 10214 } | 10244 } |
| 10215 | 10245 |
| 10216 static SECStatus ssl_RemoveSSLv3CBCPadding(sslBuffer *plaintext, | 10246 static SECStatus |
| 10217 » » » » » unsigned blockSize, | 10247 ssl_RemoveSSLv3CBCPadding(sslBuffer *plaintext, |
| 10218 » » » » » unsigned macSize) { | 10248 » » » unsigned int blockSize, |
| 10249 » » » unsigned int macSize) | |
| 10250 { | |
| 10219 unsigned int paddingLength, good, t; | 10251 unsigned int paddingLength, good, t; |
| 10220 const unsigned int overhead = 1 /* padding length byte */ + macSize; | 10252 const unsigned int overhead = 1 /* padding length byte */ + macSize; |
| 10221 | 10253 |
| 10222 /* These lengths are all public so we can test them in non-constant | 10254 /* These lengths are all public so we can test them in non-constant |
| 10223 * time. */ | 10255 * time. */ |
| 10224 if (overhead > plaintext->len) { | 10256 if (overhead > plaintext->len) { |
| 10225 return SECFailure; | 10257 return SECFailure; |
| 10226 } | 10258 } |
| 10227 | 10259 |
| 10228 paddingLength = plaintext->buf[plaintext->len-1]; | 10260 paddingLength = plaintext->buf[plaintext->len-1]; |
| 10229 /* SSLv3 padding bytes are random and cannot be checked. */ | 10261 /* SSLv3 padding bytes are random and cannot be checked. */ |
| 10230 t = plaintext->len; | 10262 t = plaintext->len; |
| 10231 t -= paddingLength+overhead; | 10263 t -= paddingLength+overhead; |
| 10232 /* If len >= padding_length+overhead then the MSB of t is zero. */ | 10264 /* If len >= padding_length+overhead then the MSB of t is zero. */ |
| 10233 good = DUPLICATE_MSB_TO_ALL(~t); | 10265 good = DUPLICATE_MSB_TO_ALL(~t); |
| 10234 /* SSLv3 requires that the padding is minimal. */ | 10266 /* SSLv3 requires that the padding is minimal. */ |
| 10235 t = blockSize - (paddingLength+1); | 10267 t = blockSize - (paddingLength+1); |
| 10236 good &= DUPLICATE_MSB_TO_ALL(~t); | 10268 good &= DUPLICATE_MSB_TO_ALL(~t); |
| 10237 plaintext->len -= good & (paddingLength+1); | 10269 plaintext->len -= good & (paddingLength+1); |
| 10238 return (good & SECSuccess) | (~good & SECFailure); | 10270 return (good & SECSuccess) | (~good & SECFailure); |
| 10239 } | 10271 } |
| 10240 | 10272 |
| 10241 | 10273 static SECStatus |
| 10242 static SECStatus ssl_RemoveTLSCBCPadding(sslBuffer *plaintext, | 10274 ssl_RemoveTLSCBCPadding(sslBuffer *plaintext, unsigned int macSize) |
| 10243 » » » » » unsigned macSize) { | 10275 { |
| 10244 unsigned int paddingLength, good, t, toCheck, i; | 10276 unsigned int paddingLength, good, t, toCheck, i; |
| 10245 const unsigned int overhead = 1 /* padding length byte */ + macSize; | 10277 const unsigned int overhead = 1 /* padding length byte */ + macSize; |
| 10246 | 10278 |
| 10247 /* These lengths are all public so we can test them in non-constant | 10279 /* These lengths are all public so we can test them in non-constant |
| 10248 * time. */ | 10280 * time. */ |
| 10249 if (overhead > plaintext->len) { | 10281 if (overhead > plaintext->len) { |
| 10250 return SECFailure; | 10282 return SECFailure; |
| 10251 } | 10283 } |
| 10252 | 10284 |
| 10253 paddingLength = plaintext->buf[plaintext->len-1]; | 10285 paddingLength = plaintext->buf[plaintext->len-1]; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10293 | 10325 |
| 10294 plaintext->len -= good & (paddingLength+1); | 10326 plaintext->len -= good & (paddingLength+1); |
| 10295 return (good & SECSuccess) | (~good & SECFailure); | 10327 return (good & SECSuccess) | (~good & SECFailure); |
| 10296 } | 10328 } |
| 10297 | 10329 |
| 10298 /* On entry: | 10330 /* On entry: |
| 10299 * originalLength >= macSize | 10331 * originalLength >= macSize |
| 10300 * macSize <= MAX_MAC_LENGTH | 10332 * macSize <= MAX_MAC_LENGTH |
| 10301 * plaintext->len >= macSize | 10333 * plaintext->len >= macSize |
| 10302 */ | 10334 */ |
| 10303 static void ssl_CBCExtractMAC(sslBuffer *plaintext, | 10335 static void |
| 10304 » » » unsigned int originalLength, | 10336 ssl_CBCExtractMAC(sslBuffer *plaintext, |
| 10305 » » » SSL3Opaque* out, | 10337 » » unsigned int originalLength, |
| 10306 » » » unsigned int macSize) { | 10338 » » SSL3Opaque* out, |
| 10339 » » unsigned int macSize) | |
| 10340 { | |
| 10307 unsigned char rotatedMac[MAX_MAC_LENGTH]; | 10341 unsigned char rotatedMac[MAX_MAC_LENGTH]; |
| 10308 /* macEnd is the index of |plaintext->buf| just after the end of the MAC. */ | 10342 /* macEnd is the index of |plaintext->buf| just after the end of the |
| 10343 * MAC. */ | |
| 10309 unsigned macEnd = plaintext->len; | 10344 unsigned macEnd = plaintext->len; |
| 10310 unsigned macStart = macEnd - macSize; | 10345 unsigned macStart = macEnd - macSize; |
| 10311 /* scanStart contains the number of bytes that we can ignore because | 10346 /* scanStart contains the number of bytes that we can ignore because |
| 10312 * the MAC's position can only vary by 255 bytes. */ | 10347 * the MAC's position can only vary by 255 bytes. */ |
| 10313 unsigned scanStart = 0; | 10348 unsigned scanStart = 0; |
| 10314 unsigned i, j, divSpoiler; | 10349 unsigned i, j, divSpoiler; |
| 10315 unsigned char rotateOffset; | 10350 unsigned char rotateOffset; |
| 10316 | 10351 |
| 10317 if (originalLength > macSize + 255 + 1) | 10352 if (originalLength > macSize + 255 + 1) |
| 10318 scanStart = originalLength - (macSize + 255 + 1); | 10353 scanStart = originalLength - (macSize + 255 + 1); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 10332 for (i = scanStart; i < originalLength;) { | 10367 for (i = scanStart; i < originalLength;) { |
| 10333 for (j = 0; j < macSize && i < originalLength; i++, j++) { | 10368 for (j = 0; j < macSize && i < originalLength; i++, j++) { |
| 10334 unsigned char macStarted = ssl_ConstantTimeGE(i, macStart); | 10369 unsigned char macStarted = ssl_ConstantTimeGE(i, macStart); |
| 10335 unsigned char macEnded = ssl_ConstantTimeGE(i, macEnd); | 10370 unsigned char macEnded = ssl_ConstantTimeGE(i, macEnd); |
| 10336 unsigned char b = 0; | 10371 unsigned char b = 0; |
| 10337 b = plaintext->buf[i]; | 10372 b = plaintext->buf[i]; |
| 10338 rotatedMac[j] |= b & macStarted & ~macEnded; | 10373 rotatedMac[j] |= b & macStarted & ~macEnded; |
| 10339 } | 10374 } |
| 10340 } | 10375 } |
| 10341 | 10376 |
| 10342 /* Now rotate the MAC. If we knew that the MAC fit into a CPU cache line we | 10377 /* Now rotate the MAC. If we knew that the MAC fit into a CPU cache line |
| 10343 * could line-align |rotatedMac| and rotate in place. */ | 10378 * we could line-align |rotatedMac| and rotate in place. */ |
| 10344 memset(out, 0, macSize); | 10379 memset(out, 0, macSize); |
| 10345 for (i = 0; i < macSize; i++) { | 10380 for (i = 0; i < macSize; i++) { |
| 10346 » unsigned char offset = (divSpoiler + macSize - rotateOffset + i) % macSi ze; | 10381 » unsigned char offset = |
| 10382 » (divSpoiler + macSize - rotateOffset + i) % macSize; | |
| 10347 for (j = 0; j < macSize; j++) { | 10383 for (j = 0; j < macSize; j++) { |
| 10348 out[j] |= rotatedMac[i] & ssl_ConstantTimeEQ8(j, offset); | 10384 out[j] |= rotatedMac[i] & ssl_ConstantTimeEQ8(j, offset); |
| 10349 } | 10385 } |
| 10350 } | 10386 } |
| 10351 } | 10387 } |
| 10352 | 10388 |
| 10353 /* if cText is non-null, then decipher, check MAC, and decompress the | 10389 /* if cText is non-null, then decipher, check MAC, and decompress the |
| 10354 * SSL record from cText->buf (typically gs->inbuf) | 10390 * SSL record from cText->buf (typically gs->inbuf) |
| 10355 * into databuf (typically gs->buf), and any previous contents of databuf | 10391 * into databuf (typically gs->buf), and any previous contents of databuf |
| 10356 * is lost. Then handle databuf according to its SSL record type, | 10392 * is lost. Then handle databuf according to its SSL record type, |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10836 | 10872 |
| 10837 ssl_GetSpecWriteLock(ss); | 10873 ssl_GetSpecWriteLock(ss); |
| 10838 ss->ssl3.crSpec = ss->ssl3.cwSpec = &ss->ssl3.specs[0]; | 10874 ss->ssl3.crSpec = ss->ssl3.cwSpec = &ss->ssl3.specs[0]; |
| 10839 ss->ssl3.prSpec = ss->ssl3.pwSpec = &ss->ssl3.specs[1]; | 10875 ss->ssl3.prSpec = ss->ssl3.pwSpec = &ss->ssl3.specs[1]; |
| 10840 ss->ssl3.hs.sendingSCSV = PR_FALSE; | 10876 ss->ssl3.hs.sendingSCSV = PR_FALSE; |
| 10841 ssl3_InitCipherSpec(ss, ss->ssl3.crSpec); | 10877 ssl3_InitCipherSpec(ss, ss->ssl3.crSpec); |
| 10842 ssl3_InitCipherSpec(ss, ss->ssl3.prSpec); | 10878 ssl3_InitCipherSpec(ss, ss->ssl3.prSpec); |
| 10843 | 10879 |
| 10844 ss->ssl3.hs.ws = (ss->sec.isServer) ? wait_client_hello : wait_server_hello; | 10880 ss->ssl3.hs.ws = (ss->sec.isServer) ? wait_client_hello : wait_server_hello; |
| 10845 #ifdef NSS_ENABLE_ECC | 10881 #ifdef NSS_ENABLE_ECC |
| 10846 ss->ssl3.hs.negotiatedECCurves = SSL3_SUPPORTED_CURVES_MASK; | 10882 ss->ssl3.hs.negotiatedECCurves = ssl3_GetSupportedECCCurveMask(ss); |
| 10847 #endif | 10883 #endif |
| 10848 ssl_ReleaseSpecWriteLock(ss); | 10884 ssl_ReleaseSpecWriteLock(ss); |
| 10849 | 10885 |
| 10850 PORT_Memset(&ss->xtnData, 0, sizeof(TLSExtensionData)); | 10886 PORT_Memset(&ss->xtnData, 0, sizeof(TLSExtensionData)); |
| 10851 | 10887 |
| 10852 if (IS_DTLS(ss)) { | 10888 if (IS_DTLS(ss)) { |
| 10853 ss->ssl3.hs.sendMessageSeq = 0; | 10889 ss->ssl3.hs.sendMessageSeq = 0; |
| 10854 ss->ssl3.hs.recvMessageSeq = 0; | 10890 ss->ssl3.hs.recvMessageSeq = 0; |
| 10855 ss->ssl3.hs.rtTimeoutMs = INITIAL_DTLS_TIMEOUT_MS; | 10891 ss->ssl3.hs.rtTimeoutMs = INITIAL_DTLS_TIMEOUT_MS; |
| 10856 ss->ssl3.hs.rtRetries = 0; | 10892 ss->ssl3.hs.rtRetries = 0; |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11239 } | 11275 } |
| 11240 if (ss->ssl3.hs.sha) { | 11276 if (ss->ssl3.hs.sha) { |
| 11241 PK11_DestroyContext(ss->ssl3.hs.sha,PR_TRUE); | 11277 PK11_DestroyContext(ss->ssl3.hs.sha,PR_TRUE); |
| 11242 } | 11278 } |
| 11243 if (ss->ssl3.hs.messages.buf) { | 11279 if (ss->ssl3.hs.messages.buf) { |
| 11244 PORT_Free(ss->ssl3.hs.messages.buf); | 11280 PORT_Free(ss->ssl3.hs.messages.buf); |
| 11245 ss->ssl3.hs.messages.buf = NULL; | 11281 ss->ssl3.hs.messages.buf = NULL; |
| 11246 ss->ssl3.hs.messages.len = 0; | 11282 ss->ssl3.hs.messages.len = 0; |
| 11247 ss->ssl3.hs.messages.space = 0; | 11283 ss->ssl3.hs.messages.space = 0; |
| 11248 } | 11284 } |
| 11249 if (ss->ssl3.hs.pending_cert_msg.data) { | |
| 11250 SECITEM_FreeItem(&ss->ssl3.hs.pending_cert_msg, PR_FALSE); | |
| 11251 } | |
| 11252 if (ss->ssl3.hs.cert_status.data) { | |
| 11253 SECITEM_FreeItem(&ss->ssl3.hs.cert_status, PR_FALSE); | |
| 11254 } | |
| 11255 | 11285 |
| 11256 /* free the SSL3Buffer (msg_body) */ | 11286 /* free the SSL3Buffer (msg_body) */ |
| 11257 PORT_Free(ss->ssl3.hs.msg_body.buf); | 11287 PORT_Free(ss->ssl3.hs.msg_body.buf); |
| 11258 | 11288 |
| 11259 /* free up the CipherSpecs */ | 11289 /* free up the CipherSpecs */ |
| 11260 ssl3_DestroyCipherSpec(&ss->ssl3.specs[0], PR_TRUE/*freeSrvName*/); | 11290 ssl3_DestroyCipherSpec(&ss->ssl3.specs[0], PR_TRUE/*freeSrvName*/); |
| 11261 ssl3_DestroyCipherSpec(&ss->ssl3.specs[1], PR_TRUE/*freeSrvName*/); | 11291 ssl3_DestroyCipherSpec(&ss->ssl3.specs[1], PR_TRUE/*freeSrvName*/); |
| 11262 | 11292 |
| 11263 /* Destroy the DTLS data */ | 11293 /* Destroy the DTLS data */ |
| 11264 if (IS_DTLS(ss)) { | 11294 if (IS_DTLS(ss)) { |
| 11265 dtls_FreeHandshakeMessages(&ss->ssl3.hs.lastMessageFlight); | 11295 dtls_FreeHandshakeMessages(&ss->ssl3.hs.lastMessageFlight); |
| 11266 if (ss->ssl3.hs.recvdFragments.buf) { | 11296 if (ss->ssl3.hs.recvdFragments.buf) { |
| 11267 PORT_Free(ss->ssl3.hs.recvdFragments.buf); | 11297 PORT_Free(ss->ssl3.hs.recvdFragments.buf); |
| 11268 } | 11298 } |
| 11269 } | 11299 } |
| 11270 | 11300 |
| 11271 ss->ssl3.initialized = PR_FALSE; | 11301 ss->ssl3.initialized = PR_FALSE; |
| 11272 | 11302 |
| 11273 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); | 11303 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); |
| 11274 } | 11304 } |
| 11275 | 11305 |
| 11276 /* End of ssl3con.c */ | 11306 /* End of ssl3con.c */ |
| OLD | NEW |