OLD | NEW |
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 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 | 1312 |
1313 SECStatus | 1313 SECStatus |
1314 SSL_SetNextProtoCallback(PRFileDesc *fd, | 1314 SSL_SetNextProtoCallback(PRFileDesc *fd, |
1315 SSLNextProtoCallback callback, | 1315 SSLNextProtoCallback callback, |
1316 void *arg) { | 1316 void *arg) { |
1317 sslSocket *ss = ssl_FindSocket(fd); | 1317 sslSocket *ss = ssl_FindSocket(fd); |
1318 | 1318 |
1319 if (!ss) { | 1319 if (!ss) { |
1320 SSL_DBG(("%d: SSL[%d]: bad socket in SSL_SetNextProtoNego", SSL_GETPID()
, | 1320 SSL_DBG(("%d: SSL[%d]: bad socket in SSL_SetNextProtoNego", SSL_GETPID()
, |
1321 fd)); | 1321 fd)); |
| 1322 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
1322 return SECFailure; | 1323 return SECFailure; |
1323 } | 1324 } |
1324 | 1325 |
1325 ssl_GetSSL3HandshakeLock(ss); | 1326 ssl_GetSSL3HandshakeLock(ss); |
1326 ss->nextProtoCallback = callback; | 1327 ss->nextProtoCallback = callback; |
1327 ss->nextProtoArg = arg; | 1328 ss->nextProtoArg = arg; |
1328 ssl_ReleaseSSL3HandshakeLock(ss); | 1329 ssl_ReleaseSSL3HandshakeLock(ss); |
| 1330 return SECSuccess; |
1329 } | 1331 } |
1330 | 1332 |
1331 /* NextProtoStandardCallback is set as an NPN callback for the case when the | 1333 /* NextProtoStandardCallback is set as an NPN callback for the case when the |
1332 * user of the sockets wants the standard selection algorithm. */ | 1334 * user of the sockets wants the standard selection algorithm. */ |
1333 static SECStatus | 1335 static SECStatus |
1334 NextProtoStandardCallback(void *arg, | 1336 NextProtoStandardCallback(void *arg, |
1335 PRFileDesc *fd, | 1337 PRFileDesc *fd, |
1336 const unsigned char *protos, | 1338 const unsigned char *protos, |
1337 unsigned int protos_len, | 1339 unsigned int protos_len, |
1338 unsigned char *protoOut, | 1340 unsigned char *protoOut, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 SSL_SetNextProtoNego(PRFileDesc *fd, const unsigned char *data, | 1382 SSL_SetNextProtoNego(PRFileDesc *fd, const unsigned char *data, |
1381 unsigned int length) | 1383 unsigned int length) |
1382 { | 1384 { |
1383 SECStatus rv; | 1385 SECStatus rv; |
1384 | 1386 |
1385 sslSocket *ss = ssl_FindSocket(fd); | 1387 sslSocket *ss = ssl_FindSocket(fd); |
1386 | 1388 |
1387 if (!ss) { | 1389 if (!ss) { |
1388 SSL_DBG(("%d: SSL[%d]: bad socket in SSL_SetNextProtoNego", | 1390 SSL_DBG(("%d: SSL[%d]: bad socket in SSL_SetNextProtoNego", |
1389 SSL_GETPID(), fd)); | 1391 SSL_GETPID(), fd)); |
| 1392 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
1390 return SECFailure; | 1393 return SECFailure; |
1391 } | 1394 } |
1392 | 1395 |
1393 if (ssl3_ValidateNextProtoNego(data, length) != SECSuccess) | 1396 if (ssl3_ValidateNextProtoNego(data, length) != SECSuccess) |
1394 return SECFailure; | 1397 return SECFailure; |
1395 | 1398 |
1396 ssl_GetSSL3HandshakeLock(ss); | 1399 ssl_GetSSL3HandshakeLock(ss); |
1397 if (ss->opt.nextProtoNego.data) | 1400 if (ss->opt.nextProtoNego.data) |
1398 PORT_Free(ss->opt.nextProtoNego.data); | 1401 PORT_Free(ss->opt.nextProtoNego.data); |
1399 ss->opt.nextProtoNego.data = PORT_Alloc(length); | 1402 ss->opt.nextProtoNego.data = PORT_Alloc(length); |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2617 loser: | 2620 loser: |
2618 ssl_DestroySocketContents(ss); | 2621 ssl_DestroySocketContents(ss); |
2619 ssl_DestroyLocks(ss); | 2622 ssl_DestroyLocks(ss); |
2620 PORT_Free(ss); | 2623 PORT_Free(ss); |
2621 ss = NULL; | 2624 ss = NULL; |
2622 } | 2625 } |
2623 } | 2626 } |
2624 return ss; | 2627 return ss; |
2625 } | 2628 } |
2626 | 2629 |
OLD | NEW |