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

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

Issue 5611005: Workaround a bug in NSS when using DHE+client authentication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 10 years 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
« no previous file with comments | « net/third_party/nss/patches/dheclientauth.patch ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * SSL3 Protocol 2 * SSL3 Protocol
3 * 3 *
4 * ***** BEGIN LICENSE BLOCK ***** 4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * 6 *
7 * The contents of this file are subject to the Mozilla Public License Version 7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with 8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at 9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/ 10 * http://www.mozilla.org/MPL/
(...skipping 4825 matching lines...) Expand 10 before | Expand all | Expand 10 after
4836 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0); 4836 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0);
4837 #ifdef NSS_PLATFORM_CLIENT_AUTH 4837 #ifdef NSS_PLATFORM_CLIENT_AUTH
4838 rv = ssl3_PlatformSignHashes(&hashes, ss->ssl3.platformClientKey, 4838 rv = ssl3_PlatformSignHashes(&hashes, ss->ssl3.platformClientKey,
4839 &buf, isTLS); 4839 &buf, isTLS);
4840 if (rv == SECSuccess) { 4840 if (rv == SECSuccess) {
4841 sslSessionID * sid = ss->sec.ci.sid; 4841 sslSessionID * sid = ss->sec.ci.sid;
4842 ssl_GetPlatformAuthInfoForKey(ss->ssl3.platformClientKey, 4842 ssl_GetPlatformAuthInfoForKey(ss->ssl3.platformClientKey,
4843 &sid->u.ssl3.clPlatformAuthInfo); 4843 &sid->u.ssl3.clPlatformAuthInfo);
4844 sid->u.ssl3.clPlatformAuthValid = PR_TRUE; 4844 sid->u.ssl3.clPlatformAuthValid = PR_TRUE;
4845 } 4845 }
4846 if (ss->ssl3.hs.kea_def->exchKeyType == kt_rsa) { 4846 ssl_FreePlatformKey(ss->ssl3.platformClientKey);
4847 ssl_FreePlatformKey(ss->ssl3.platformClientKey); 4847 ss->ssl3.platformClientKey = (PlatformKey)NULL;
4848 ss->ssl3.platformClientKey = (PlatformKey)NULL;
4849 }
4850 #else /* NSS_PLATFORM_CLIENT_AUTH */ 4848 #else /* NSS_PLATFORM_CLIENT_AUTH */
4851 rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS); 4849 rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS);
4852 if (rv == SECSuccess) { 4850 if (rv == SECSuccess) {
4853 PK11SlotInfo * slot; 4851 PK11SlotInfo * slot;
4854 sslSessionID * sid = ss->sec.ci.sid; 4852 sslSessionID * sid = ss->sec.ci.sid;
4855 4853
4856 /* Remember the info about the slot that did the signing. 4854 /* Remember the info about the slot that did the signing.
4857 ** Later, when doing an SSL restart handshake, verify this. 4855 ** Later, when doing an SSL restart handshake, verify this.
4858 ** These calls are mere accessors, and can't fail. 4856 ** These calls are mere accessors, and can't fail.
4859 */ 4857 */
4860 slot = PK11_GetSlotFromPrivateKey(ss->ssl3.clientPrivateKey); 4858 slot = PK11_GetSlotFromPrivateKey(ss->ssl3.clientPrivateKey);
4861 sid->u.ssl3.clAuthSeries = PK11_GetSlotSeries(slot); 4859 sid->u.ssl3.clAuthSeries = PK11_GetSlotSeries(slot);
4862 sid->u.ssl3.clAuthSlotID = PK11_GetSlotID(slot); 4860 sid->u.ssl3.clAuthSlotID = PK11_GetSlotID(slot);
4863 sid->u.ssl3.clAuthModuleID = PK11_GetModuleID(slot); 4861 sid->u.ssl3.clAuthModuleID = PK11_GetModuleID(slot);
4864 sid->u.ssl3.clAuthValid = PR_TRUE; 4862 sid->u.ssl3.clAuthValid = PR_TRUE;
4865 PK11_FreeSlot(slot); 4863 PK11_FreeSlot(slot);
4866 } 4864 }
4867 /* If we're doing RSA key exchange, we're all done with the private key 4865 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey);
4868 * here. Diffie-Hellman key exchanges need the client's 4866 ss->ssl3.clientPrivateKey = NULL;
4869 * private key for the key exchange.
4870 */
4871 if (ss->ssl3.hs.kea_def->exchKeyType == kt_rsa) {
4872 » SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey);
4873 » ss->ssl3.clientPrivateKey = NULL;
4874 }
4875 #endif /* NSS_PLATFORM_CLIENT_AUTH */ 4867 #endif /* NSS_PLATFORM_CLIENT_AUTH */
4876 if (rv != SECSuccess) { 4868 if (rv != SECSuccess) {
4877 goto done; /* err code was set by ssl3_SignHashes */ 4869 goto done; /* err code was set by ssl3_SignHashes */
4878 } 4870 }
4879 4871
4880 rv = ssl3_AppendHandshakeHeader(ss, certificate_verify, buf.len + 2); 4872 rv = ssl3_AppendHandshakeHeader(ss, certificate_verify, buf.len + 2);
4881 if (rv != SECSuccess) { 4873 if (rv != SECSuccess) {
4882 goto done; /* error code set by AppendHandshake */ 4874 goto done; /* error code set by AppendHandshake */
4883 } 4875 }
4884 rv = ssl3_AppendHandshakeVariable(ss, buf.data, buf.len, 2); 4876 rv = ssl3_AppendHandshakeVariable(ss, buf.data, buf.len, 2);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
5015 rv = ssl3_InitState(ss); 5007 rv = ssl3_InitState(ss);
5016 if (rv != SECSuccess) { 5008 if (rv != SECSuccess) {
5017 errCode = PORT_GetError(); /* ssl3_InitState has set the error code. */ 5009 errCode = PORT_GetError(); /* ssl3_InitState has set the error code. */
5018 goto alert_loser; 5010 goto alert_loser;
5019 } 5011 }
5020 if (ss->ssl3.hs.ws != wait_server_hello) { 5012 if (ss->ssl3.hs.ws != wait_server_hello) {
5021 errCode = SSL_ERROR_RX_UNEXPECTED_SERVER_HELLO; 5013 errCode = SSL_ERROR_RX_UNEXPECTED_SERVER_HELLO;
5022 desc = unexpected_message; 5014 desc = unexpected_message;
5023 goto alert_loser; 5015 goto alert_loser;
5024 } 5016 }
5017
5018 /* clean up anything left from previous handshake. */
5019 if (ss->ssl3.clientCertChain != NULL) {
5020 CERT_DestroyCertificateList(ss->ssl3.clientCertChain);
5021 ss->ssl3.clientCertChain = NULL;
5022 }
5023 if (ss->ssl3.clientCertificate != NULL) {
5024 CERT_DestroyCertificate(ss->ssl3.clientCertificate);
5025 ss->ssl3.clientCertificate = NULL;
5026 }
5027 if (ss->ssl3.clientPrivateKey != NULL) {
5028 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey);
5029 ss->ssl3.clientPrivateKey = NULL;
5030 }
5031 #ifdef NSS_PLATFORM_CLIENT_AUTH
5032 if (ss->ssl3.platformClientKey) {
5033 ssl_FreePlatformKey(ss->ssl3.platformClientKey);
5034 ss->ssl3.platformClientKey = (PlatformKey)NULL;
5035 }
5036 #endif /* NSS_PLATFORM_CLIENT_AUTH */
5025 5037
5026 if (ss->ssl3.serverHelloPredictionData.data) 5038 if (ss->ssl3.serverHelloPredictionData.data)
5027 SECITEM_FreeItem(&ss->ssl3.serverHelloPredictionData, PR_FALSE); 5039 SECITEM_FreeItem(&ss->ssl3.serverHelloPredictionData, PR_FALSE);
5028 5040
5029 /* If this allocation fails it will only stop the application from 5041 /* If this allocation fails it will only stop the application from
5030 * recording the ServerHello information and performing future Snap 5042 * recording the ServerHello information and performing future Snap
5031 * Starts. */ 5043 * Starts. */
5032 if (SECITEM_AllocItem(NULL, &ss->ssl3.serverHelloPredictionData, length)) 5044 if (SECITEM_AllocItem(NULL, &ss->ssl3.serverHelloPredictionData, length))
5033 memcpy(ss->ssl3.serverHelloPredictionData.data, b, length); 5045 memcpy(ss->ssl3.serverHelloPredictionData.data, b, length);
5034 /* ss->ssl3.serverHelloPredictionDataValid is still false at this 5046 /* ss->ssl3.serverHelloPredictionDataValid is still false at this
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
5512 SSL_GETPID(), ss->fd)); 5524 SSL_GETPID(), ss->fd));
5513 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); 5525 PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) );
5514 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); 5526 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) );
5515 5527
5516 if (ss->ssl3.hs.ws != wait_cert_request && 5528 if (ss->ssl3.hs.ws != wait_cert_request &&
5517 ss->ssl3.hs.ws != wait_server_key) { 5529 ss->ssl3.hs.ws != wait_server_key) {
5518 desc = unexpected_message; 5530 desc = unexpected_message;
5519 errCode = SSL_ERROR_RX_UNEXPECTED_CERT_REQUEST; 5531 errCode = SSL_ERROR_RX_UNEXPECTED_CERT_REQUEST;
5520 goto alert_loser; 5532 goto alert_loser;
5521 } 5533 }
5522 5534
5523 /* clean up anything left from previous handshake. */ 5535 PORT_Assert(ss->ssl3.clientCertChain == NULL);
5524 if (ss->ssl3.clientCertChain != NULL) { 5536 PORT_Assert(ss->ssl3.clientCertificate == NULL);
5525 CERT_DestroyCertificateList(ss->ssl3.clientCertChain); 5537 PORT_Assert(ss->ssl3.clientPrivateKey == NULL);
5526 ss->ssl3.clientCertChain = NULL;
5527 }
5528 if (ss->ssl3.clientCertificate != NULL) {
5529 CERT_DestroyCertificate(ss->ssl3.clientCertificate);
5530 ss->ssl3.clientCertificate = NULL;
5531 }
5532 if (ss->ssl3.clientPrivateKey != NULL) {
5533 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey);
5534 ss->ssl3.clientPrivateKey = NULL;
5535 }
5536 #ifdef NSS_PLATFORM_CLIENT_AUTH 5538 #ifdef NSS_PLATFORM_CLIENT_AUTH
5537 if (ss->ssl3.platformClientKey) { 5539 PORT_Assert(ss->ssl3.platformClientKey == NULL);
wtc 2010/12/08 19:24:42 We may need a (PlatformKey) cast for NULL here.
5538 ssl_FreePlatformKey(ss->ssl3.platformClientKey); 5540 #endif /* NSS_PLATFORM_CLIENT_AUTH */
5539 ss->ssl3.platformClientKey = (PlatformKey)NULL;
5540 }
5541 #endif /* NSS_PLATFORM_CLIENT_AUTH */
5542 5541
5543 isTLS = (PRBool)(ss->ssl3.prSpec->version > SSL_LIBRARY_VERSION_3_0); 5542 isTLS = (PRBool)(ss->ssl3.prSpec->version > SSL_LIBRARY_VERSION_3_0);
5544 rv = ssl3_ConsumeHandshakeVariable(ss, &cert_types, 1, &b, &length); 5543 rv = ssl3_ConsumeHandshakeVariable(ss, &cert_types, 1, &b, &length);
5545 if (rv != SECSuccess) 5544 if (rv != SECSuccess)
5546 goto loser; /* malformed, alert has been sent */ 5545 goto loser; /* malformed, alert has been sent */
5547 5546
5548 arena = ca_list.arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 5547 arena = ca_list.arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
5549 if (arena == NULL) 5548 if (arena == NULL)
5550 goto no_mem; 5549 goto no_mem;
5551 5550
(...skipping 4336 matching lines...) Expand 10 before | Expand all | Expand 10 after
9888 9887
9889 ss->ssl3.initialized = PR_FALSE; 9888 ss->ssl3.initialized = PR_FALSE;
9890 9889
9891 if (ss->ssl3.nextProto.data) { 9890 if (ss->ssl3.nextProto.data) {
9892 PORT_Free(ss->ssl3.nextProto.data); 9891 PORT_Free(ss->ssl3.nextProto.data);
9893 ss->ssl3.nextProto.data = NULL; 9892 ss->ssl3.nextProto.data = NULL;
9894 } 9893 }
9895 } 9894 }
9896 9895
9897 /* End of ssl3con.c */ 9896 /* End of ssl3con.c */
OLDNEW
« no previous file with comments | « net/third_party/nss/patches/dheclientauth.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698