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

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

Issue 8156001: net: rework the NPN patch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * vtables (and methods that call through them) for the 4 types of 2 * vtables (and methods that call through them) for the 4 types of
3 * SSLSockets supported. Only one type is still supported. 3 * SSLSockets supported. Only one type is still supported.
4 * Various other functions. 4 * Various other functions.
5 * 5 *
6 * ***** BEGIN LICENSE BLOCK ***** 6 * ***** BEGIN LICENSE BLOCK *****
7 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 7 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8 * 8 *
9 * The contents of this file are subject to the Mozilla Public License Version 9 * The contents of this file are subject to the Mozilla Public License Version
10 * 1.1 (the "License"); you may not use this file except in compliance with 10 * 1.1 (the "License"); you may not use this file except in compliance with
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ssl_SecureRead, 156 ssl_SecureRead,
157 ssl_SecureWrite, 157 ssl_SecureWrite,
158 ssl_DefGetpeername, 158 ssl_DefGetpeername,
159 ssl_DefGetsockname 159 ssl_DefGetsockname
160 }; 160 };
161 161
162 /* 162 /*
163 ** default settings for socket enables 163 ** default settings for socket enables
164 */ 164 */
165 static sslOptions ssl_defaults = { 165 static sslOptions ssl_defaults = {
166 { siBuffer, NULL, 0 }, /* nextProtoNego */
167 PR_TRUE, /* useSecurity */ 166 PR_TRUE, /* useSecurity */
168 PR_FALSE, /* useSocks */ 167 PR_FALSE, /* useSocks */
169 PR_FALSE, /* requestCertificate */ 168 PR_FALSE, /* requestCertificate */
170 2, /* requireCertificate */ 169 2, /* requireCertificate */
171 PR_FALSE, /* handshakeAsClient */ 170 PR_FALSE, /* handshakeAsClient */
172 PR_FALSE, /* handshakeAsServer */ 171 PR_FALSE, /* handshakeAsServer */
173 PR_TRUE, /* enableSSL2 */ 172 PR_TRUE, /* enableSSL2 */
174 PR_TRUE, /* enableSSL3 */ 173 PR_TRUE, /* enableSSL3 */
175 PR_TRUE, /* enableTLS */ /* now defaults to on in NSS 3.0 */ 174 PR_TRUE, /* enableTLS */ /* now defaults to on in NSS 3.0 */
176 PR_FALSE, /* noCache */ 175 PR_FALSE, /* noCache */
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 ssl3_FreeKeyPair(sc->serverKeyPair); 438 ssl3_FreeKeyPair(sc->serverKeyPair);
440 } 439 }
441 if (ss->stepDownKeyPair) { 440 if (ss->stepDownKeyPair) {
442 ssl3_FreeKeyPair(ss->stepDownKeyPair); 441 ssl3_FreeKeyPair(ss->stepDownKeyPair);
443 ss->stepDownKeyPair = NULL; 442 ss->stepDownKeyPair = NULL;
444 } 443 }
445 if (ss->ephemeralECDHKeyPair) { 444 if (ss->ephemeralECDHKeyPair) {
446 ssl3_FreeKeyPair(ss->ephemeralECDHKeyPair); 445 ssl3_FreeKeyPair(ss->ephemeralECDHKeyPair);
447 ss->ephemeralECDHKeyPair = NULL; 446 ss->ephemeralECDHKeyPair = NULL;
448 } 447 }
449 if (ss->opt.nextProtoNego.data) {
450 PORT_Free(ss->opt.nextProtoNego.data);
451 ss->opt.nextProtoNego.data = NULL;
452 }
453 PORT_Assert(!ss->xtnData.sniNameArr); 448 PORT_Assert(!ss->xtnData.sniNameArr);
454 if (ss->xtnData.sniNameArr) { 449 if (ss->xtnData.sniNameArr) {
455 PORT_Free(ss->xtnData.sniNameArr); 450 PORT_Free(ss->xtnData.sniNameArr);
456 ss->xtnData.sniNameArr = NULL; 451 ss->xtnData.sniNameArr = NULL;
457 } 452 }
458 } 453 }
459 454
460 /* 455 /*
461 * free an sslSocket struct, and all the stuff that hangs off of it 456 * free an sslSocket struct, and all the stuff that hangs off of it
462 */ 457 */
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 #ifdef _WIN32 1298 #ifdef _WIN32
1304 PR_Sleep(PR_INTERVAL_NO_WAIT); /* workaround NT winsock connect bug. */ 1299 PR_Sleep(PR_INTERVAL_NO_WAIT); /* workaround NT winsock connect bug. */
1305 #endif 1300 #endif
1306 ns = ssl_FindSocket(fd); 1301 ns = ssl_FindSocket(fd);
1307 PORT_Assert(ns); 1302 PORT_Assert(ns);
1308 if (ns) 1303 if (ns)
1309 ns->TCPconnected = (PR_SUCCESS == ssl_DefGetpeername(ns, &addr)); 1304 ns->TCPconnected = (PR_SUCCESS == ssl_DefGetpeername(ns, &addr));
1310 return fd; 1305 return fd;
1311 } 1306 }
1312 1307
1313 /* SSL_SetNextProtoNego sets the list of supported protocols for the given
1314 * socket. The list is a series of 8-bit, length prefixed strings. */
1315 SECStatus 1308 SECStatus
1316 SSL_SetNextProtoNego(PRFileDesc *fd, const unsigned char *data, 1309 SSL_SetNextProtoCallback(PRFileDesc *fd,
1317 » » unsigned short length) 1310 SSLNextProtoCallback callback,
1318 { 1311 void *arg) {
1319 sslSocket *ss = ssl_FindSocket(fd); 1312 sslSocket *ss = ssl_FindSocket(fd);
1320 1313
1321 if (!ss) { 1314 if (!ss) {
1322 SSL_DBG(("%d: SSL[%d]: bad socket in SSL_SetNextProtoNego", SSL_GETPID() , 1315 SSL_DBG(("%d: SSL[%d]: bad socket in SSL_SetNextProtoNego", SSL_GETPID() ,
1323 fd)); 1316 fd));
1324 return SECFailure; 1317 return SECFailure;
1325 } 1318 }
1326 1319
1327 if (ssl3_ValidateNextProtoNego(data, length) != SECSuccess)
1328 return SECFailure;
1329
1330 ssl_GetSSL3HandshakeLock(ss); 1320 ssl_GetSSL3HandshakeLock(ss);
1331 if (ss->opt.nextProtoNego.data) 1321 ss->nextProtoCallback = callback;
1332 » PORT_Free(ss->opt.nextProtoNego.data); 1322 ss->nextProtoArg = arg;
1333 ss->opt.nextProtoNego.data = PORT_Alloc(length);
1334 if (!ss->opt.nextProtoNego.data) {
1335 » ssl_ReleaseSSL3HandshakeLock(ss);
1336 » return SECFailure;
1337 }
1338 memcpy(ss->opt.nextProtoNego.data, data, length);
1339 ss->opt.nextProtoNego.len = length;
1340 ss->opt.nextProtoNego.type = siBuffer;
1341 ssl_ReleaseSSL3HandshakeLock(ss); 1323 ssl_ReleaseSSL3HandshakeLock(ss);
1342
1343 return SECSuccess;
1344 }
1345
1346 /* SSL_GetNextProto reads the resulting Next Protocol Negotiation result for
1347 * the given socket. It's only valid to call this once the handshake has
1348 * completed.
1349 *
1350 * state is set to one of the SSL_NEXT_PROTO_* constants. The negotiated
1351 * protocol, if any, is written into buf, which must be at least buf_len
1352 * bytes long. If the negotiated protocol is longer than this, it is truncated.
1353 * The number of bytes copied is written into length.
1354 */
1355 SECStatus
1356 SSL_GetNextProto(PRFileDesc *fd, int *state, unsigned char *buf,
1357 unsigned int *length, unsigned int buf_len)
1358 {
1359 sslSocket *ss = ssl_FindSocket(fd);
1360
1361 if (!ss) {
1362 SSL_DBG(("%d: SSL[%d]: bad socket in SSL_GetNextProto", SSL_GETPID(),
1363 fd));
1364 return SECFailure;
1365 }
1366
1367 *state = ss->ssl3.nextProtoState;
1368
1369 if (ss->ssl3.nextProtoState != SSL_NEXT_PROTO_NO_SUPPORT &&
1370 ss->ssl3.nextProto.data) {
1371 *length = ss->ssl3.nextProto.len;
1372 if (*length > buf_len)
1373 *length = buf_len;
1374 PORT_Memcpy(buf, ss->ssl3.nextProto.data, *length);
1375 } else {
1376 *length = 0;
1377 }
1378
1379 return SECSuccess;
1380 } 1324 }
1381 1325
1382 PRFileDesc * 1326 PRFileDesc *
1383 SSL_ReconfigFD(PRFileDesc *model, PRFileDesc *fd) 1327 SSL_ReconfigFD(PRFileDesc *model, PRFileDesc *fd)
1384 { 1328 {
1385 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); 1329 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR);
1386 PR_NOT_REACHED("not implemented"); 1330 PR_NOT_REACHED("not implemented");
1387 return NULL; 1331 return NULL;
1388 1332
1389 #if 0 1333 #if 0
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 loser: 2504 loser:
2561 ssl_DestroySocketContents(ss); 2505 ssl_DestroySocketContents(ss);
2562 ssl_DestroyLocks(ss); 2506 ssl_DestroyLocks(ss);
2563 PORT_Free(ss); 2507 PORT_Free(ss);
2564 ss = NULL; 2508 ss = NULL;
2565 } 2509 }
2566 } 2510 }
2567 return ss; 2511 return ss;
2568 } 2512 }
2569 2513
OLDNEW
« net/third_party/nss/ssl/ssl.h ('K') | « net/third_party/nss/ssl/sslimpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698