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

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

Issue 11275240: Update net/third_party/nss/ssl to NSS 3.14. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Upload before commit Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/third_party/nss/ssl/sslsecur.c ('k') | net/third_party/nss/ssl/sslsock.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This file implements the SERVER Session ID cache. 1 /* This file implements the SERVER Session ID cache.
2 * NOTE: The contents of this file are NOT used by the client. 2 * NOTE: The contents of this file are NOT used by the client.
3 * 3 *
4 * ***** BEGIN LICENSE BLOCK ***** 4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * The contents of this file are subject to the Mozilla Public License Version 7 /* $Id: sslsnce.c,v 1.63 2012/06/14 19:04:59 wtc%google.com Exp $ */
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
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
16 *
17 * The Original Code is the Netscape security libraries.
18 *
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1994-2000
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39 /* $Id: sslsnce.c,v 1.59 2011/10/22 16:45:40 emaldona%redhat.com Exp $ */
40 8
41 /* Note: ssl_FreeSID() in sslnonce.c gets used for both client and server 9 /* Note: ssl_FreeSID() in sslnonce.c gets used for both client and server
42 * cache sids! 10 * cache sids!
43 * 11 *
44 * About record locking among different server processes: 12 * About record locking among different server processes:
45 * 13 *
46 * All processes that are part of the same conceptual server (serving on 14 * All processes that are part of the same conceptual server (serving on
47 * the same address and port) MUST share a common SSL session cache. 15 * the same address and port) MUST share a common SSL session cache.
48 * This code makes the content of the shared cache accessible to all 16 * This code makes the content of the shared cache accessible to all
49 * processes on the same "server". This code works on Unix and Win32 only. 17 * processes on the same "server". This code works on Unix and Win32 only.
(...skipping 29 matching lines...) Expand all
79 47
80 #if defined(XP_UNIX) || defined(XP_WIN32) || defined (XP_OS2) || defined(XP_BEOS ) 48 #if defined(XP_UNIX) || defined(XP_WIN32) || defined (XP_OS2) || defined(XP_BEOS )
81 49
82 #include "cert.h" 50 #include "cert.h"
83 #include "ssl.h" 51 #include "ssl.h"
84 #include "sslimpl.h" 52 #include "sslimpl.h"
85 #include "sslproto.h" 53 #include "sslproto.h"
86 #include "pk11func.h" 54 #include "pk11func.h"
87 #include "base64.h" 55 #include "base64.h"
88 #include "keyhi.h" 56 #include "keyhi.h"
57 #ifdef NO_PKCS11_BYPASS
58 #include "blapit.h"
59 #include "sechash.h"
60 #else
89 #include "blapi.h" 61 #include "blapi.h"
62 #endif
90 63
91 #include <stdio.h> 64 #include <stdio.h>
92 65
93 #if defined(XP_UNIX) || defined(XP_BEOS) 66 #if defined(XP_UNIX) || defined(XP_BEOS)
94 67
95 #include <syslog.h> 68 #include <syslog.h>
96 #include <fcntl.h> 69 #include <fcntl.h>
97 #include <unistd.h> 70 #include <unistd.h>
98 #include <errno.h> 71 #include <errno.h>
99 #include <signal.h> 72 #include <signal.h>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 /* 1 */ PRUint8 masterKeyLen; 114 /* 1 */ PRUint8 masterKeyLen;
142 /* 1 */ PRUint8 keyBits; 115 /* 1 */ PRUint8 keyBits;
143 /* 1 */ PRUint8 secretKeyBits; 116 /* 1 */ PRUint8 secretKeyBits;
144 /* 1 */ PRUint8 cipherArgLen; 117 /* 1 */ PRUint8 cipherArgLen;
145 /*101 */} ssl2; 118 /*101 */} ssl2;
146 119
147 struct { 120 struct {
148 /* 2 */ ssl3CipherSuite cipherSuite; 121 /* 2 */ ssl3CipherSuite cipherSuite;
149 /* 2 */ PRUint16 compression; /* SSLCompressionMethod */ 122 /* 2 */ PRUint16 compression; /* SSLCompressionMethod */
150 123
151 /*100 */ ssl3SidKeys keys;» /* keys and ivs, wrapped as needed. */ 124 /* 52 */ ssl3SidKeys keys;» /* keys, wrapped as needed. */
152 125
153 /* 4 */ PRUint32 masterWrapMech; 126 /* 4 */ PRUint32 masterWrapMech;
154 /* 4 */ SSL3KEAType exchKeyType; 127 /* 4 */ SSL3KEAType exchKeyType;
155 /* 4 */ PRInt32 certIndex; 128 /* 4 */ PRInt32 certIndex;
156 /* 4 */ PRInt32 srvNameIndex; 129 /* 4 */ PRInt32 srvNameIndex;
157 /* 32 */ PRUint8 srvNameHash[SHA256_LENGTH]; /* SHA256 name hash */ 130 /* 32 */ PRUint8 srvNameHash[SHA256_LENGTH]; /* SHA256 name hash */
158 /*152 */} ssl3; 131 /*104 */} ssl3;
159 /* force sizeof(sidCacheEntry) to be a multiple of cache line size */ 132 /* force sizeof(sidCacheEntry) to be a multiple of cache line size */
160 struct { 133 struct {
161 /*152 */ PRUint8 filler[120]; /* 72+152==224, a multiple of 16 */ 134 /*120 */ PRUint8 filler[120]; /* 72+120==192, a multiple of 16 */
162 } forceSize; 135 } forceSize;
163 } u; 136 } u;
164 }; 137 };
165 typedef struct sidCacheEntryStr sidCacheEntry; 138 typedef struct sidCacheEntryStr sidCacheEntry;
166 139
167 /* The length of this struct is supposed to be a power of 2, e.g. 4KB */ 140 /* The length of this struct is supposed to be a power of 2, e.g. 4KB */
168 struct certCacheEntryStr { 141 struct certCacheEntryStr {
169 PRUint16 certLength; /* 2 */ 142 PRUint16 certLength; /* 2 */
170 PRUint16 sessionIDLength; /* 2 */ 143 PRUint16 sessionIDLength; /* 2 */
171 PRUint8 sessionID[SSL3_SESSIONID_BYTES]; /* 32 */ 144 PRUint8 sessionID[SSL3_SESSIONID_BYTES]; /* 32 */
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 414
442 if (!name || name->len <= 0 || 415 if (!name || name->len <= 0 ||
443 name->len > SSL_MAX_DNS_HOST_NAME) { 416 name->len > SSL_MAX_DNS_HOST_NAME) {
444 PORT_SetError(SEC_ERROR_INVALID_ARGS); 417 PORT_SetError(SEC_ERROR_INVALID_ARGS);
445 return 0; 418 return 0;
446 } 419 }
447 420
448 snce.type = name->type; 421 snce.type = name->type;
449 snce.nameLen = name->len; 422 snce.nameLen = name->len;
450 PORT_Memcpy(snce.name, name->data, snce.nameLen); 423 PORT_Memcpy(snce.name, name->data, snce.nameLen);
424 #ifdef NO_PKCS11_BYPASS
425 HASH_HashBuf(HASH_AlgSHA256, snce.nameHash, name->data, name->len);
426 #else
451 SHA256_HashBuf(snce.nameHash, (unsigned char*)name->data, 427 SHA256_HashBuf(snce.nameHash, (unsigned char*)name->data,
452 name->len); 428 name->len);
429 #endif
453 /* get index of the next name */ 430 /* get index of the next name */
454 ndx = Get32BitNameHash(name); 431 ndx = Get32BitNameHash(name);
455 /* get lock on cert cache */ 432 /* get lock on cert cache */
456 now = LockSidCacheLock(cache->srvNameCacheLock, 0); 433 now = LockSidCacheLock(cache->srvNameCacheLock, 0);
457 if (now) { 434 if (now) {
458 if (cache->numSrvNameCacheEntries > 0) { 435 if (cache->numSrvNameCacheEntries > 0) {
459 /* Fit the index into array */ 436 /* Fit the index into array */
460 ndx %= cache->numSrvNameCacheEntries; 437 ndx %= cache->numSrvNameCacheEntries;
461 /* write the entry */ 438 /* write the entry */
462 cache->srvNameCacheData[ndx] = snce; 439 cache->srvNameCacheData[ndx] = snce;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 */ 527 */
551 static sslSessionID * 528 static sslSessionID *
552 ConvertToSID(sidCacheEntry * from, 529 ConvertToSID(sidCacheEntry * from,
553 certCacheEntry * pcce, 530 certCacheEntry * pcce,
554 srvNameCacheEntry *psnce, 531 srvNameCacheEntry *psnce,
555 CERTCertDBHandle * dbHandle) 532 CERTCertDBHandle * dbHandle)
556 { 533 {
557 sslSessionID *to; 534 sslSessionID *to;
558 uint16 version = from->version; 535 uint16 version = from->version;
559 536
560 to = (sslSessionID*) PORT_ZAlloc(sizeof(sslSessionID)); 537 to = PORT_ZNew(sslSessionID);
561 if (!to) { 538 if (!to) {
562 return 0; 539 return 0;
563 } 540 }
564 541
565 if (version < SSL_LIBRARY_VERSION_3_0) { 542 if (version < SSL_LIBRARY_VERSION_3_0) {
566 /* This is an SSL v2 session */ 543 /* This is an SSL v2 session */
567 to->u.ssl2.masterKey.data = 544 to->u.ssl2.masterKey.data =
568 (unsigned char*) PORT_Alloc(from->u.ssl2.masterKeyLen); 545 (unsigned char*) PORT_Alloc(from->u.ssl2.masterKeyLen);
569 if (!to->u.ssl2.masterKey.data) { 546 if (!to->u.ssl2.masterKey.data) {
570 goto loser; 547 goto loser;
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 PRUint32 ssl2_timeout, 1298 PRUint32 ssl2_timeout,
1322 PRUint32 ssl3_timeout, 1299 PRUint32 ssl3_timeout,
1323 const char * directory, 1300 const char * directory,
1324 PRBool shared, 1301 PRBool shared,
1325 int maxCacheEntries, 1302 int maxCacheEntries,
1326 int maxCertCacheEntries, 1303 int maxCertCacheEntries,
1327 int maxSrvNameCacheEntries) 1304 int maxSrvNameCacheEntries)
1328 { 1305 {
1329 SECStatus rv; 1306 SECStatus rv;
1330 1307
1331 PORT_Assert(sizeof(sidCacheEntry) == 224); 1308 PORT_Assert(sizeof(sidCacheEntry) == 192);
1332 PORT_Assert(sizeof(certCacheEntry) == 4096); 1309 PORT_Assert(sizeof(certCacheEntry) == 4096);
1333 PORT_Assert(sizeof(srvNameCacheEntry) == 1072); 1310 PORT_Assert(sizeof(srvNameCacheEntry) == 1072);
1334 1311
1335 rv = ssl_Init(); 1312 rv = ssl_Init();
1336 if (rv != SECSuccess) { 1313 if (rv != SECSuccess) {
1337 return rv; 1314 return rv;
1338 } 1315 }
1339 1316
1340 myPid = SSL_GETPID(); 1317 myPid = SSL_GETPID();
1341 if (!directory) { 1318 if (!directory) {
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 } 2205 }
2229 2206
2230 SECStatus 2207 SECStatus
2231 SSL_SetMaxServerCacheLocks(PRUint32 maxLocks) 2208 SSL_SetMaxServerCacheLocks(PRUint32 maxLocks)
2232 { 2209 {
2233 PR_ASSERT(!"SSL servers are not supported on this platform. (SSL_SetMaxServe rCacheLocks)"); 2210 PR_ASSERT(!"SSL servers are not supported on this platform. (SSL_SetMaxServe rCacheLocks)");
2234 return SECFailure; 2211 return SECFailure;
2235 } 2212 }
2236 2213
2237 #endif /* XP_UNIX || XP_WIN32 */ 2214 #endif /* XP_UNIX || XP_WIN32 */
OLDNEW
« no previous file with comments | « net/third_party/nss/ssl/sslsecur.c ('k') | net/third_party/nss/ssl/sslsock.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698