| OLD | NEW |
| 1 /* | 1 /* |
| 2 * SSL v2 handshake functions, and functions common to SSL2 and SSL3. | 2 * SSL v2 handshake functions, and functions common to SSL2 and SSL3. |
| 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: sslcon.c,v 1.52 2012/07/17 14:43:11 kaie%kuix.de 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 * Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories | |
| 26 * | |
| 27 * Alternatively, the contents of this file may be used under the terms of | |
| 28 * either the GNU General Public License Version 2 or later (the "GPL"), or | |
| 29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
| 30 * in which case the provisions of the GPL or the LGPL are applicable instead | |
| 31 * of those above. If you wish to allow use of your version of this file only | |
| 32 * under the terms of either the GPL or the LGPL, and not to allow others to | |
| 33 * use your version of this file under the terms of the MPL, indicate your | |
| 34 * decision by deleting the provisions above and replace them with the notice | |
| 35 * and other provisions required by the GPL or the LGPL. If you do not delete | |
| 36 * the provisions above, a recipient may use your version of this file under | |
| 37 * the terms of any one of the MPL, the GPL or the LGPL. | |
| 38 * | |
| 39 * ***** END LICENSE BLOCK ***** */ | |
| 40 /* $Id: sslcon.c,v 1.48 2012/03/18 00:31:20 wtc%google.com Exp $ */ | |
| 41 | 8 |
| 42 #include "nssrenam.h" | 9 #include "nssrenam.h" |
| 43 #include "cert.h" | 10 #include "cert.h" |
| 44 #include "secitem.h" | 11 #include "secitem.h" |
| 45 #include "sechash.h" | 12 #include "sechash.h" |
| 46 #include "cryptohi.h" /* for SGN_ funcs */ | 13 #include "cryptohi.h" /* for SGN_ funcs */ |
| 47 #include "keyhi.h" /* for SECKEY_ high level functions. */ | 14 #include "keyhi.h" /* for SECKEY_ high level functions. */ |
| 48 #include "ssl.h" | 15 #include "ssl.h" |
| 49 #include "sslimpl.h" | 16 #include "sslimpl.h" |
| 50 #include "sslproto.h" | 17 #include "sslproto.h" |
| (...skipping 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2888 goto bad_server; | 2855 goto bad_server; |
| 2889 } | 2856 } |
| 2890 | 2857 |
| 2891 if (sid->cached != never_cached) { | 2858 if (sid->cached != never_cached) { |
| 2892 /* Forget our session-id - server didn't like it */ | 2859 /* Forget our session-id - server didn't like it */ |
| 2893 SSL_TRC(7, ("%d: SSL[%d]: server forgot me, uncaching session-id", | 2860 SSL_TRC(7, ("%d: SSL[%d]: server forgot me, uncaching session-id", |
| 2894 SSL_GETPID(), ss->fd)); | 2861 SSL_GETPID(), ss->fd)); |
| 2895 if (ss->sec.uncache) | 2862 if (ss->sec.uncache) |
| 2896 (*ss->sec.uncache)(sid); | 2863 (*ss->sec.uncache)(sid); |
| 2897 ssl_FreeSID(sid); | 2864 ssl_FreeSID(sid); |
| 2898 » ss->sec.ci.sid = sid = (sslSessionID*) PORT_ZAlloc(sizeof(sslSession
ID)); | 2865 » ss->sec.ci.sid = sid = PORT_ZNew(sslSessionID); |
| 2899 if (!sid) { | 2866 if (!sid) { |
| 2900 goto loser; | 2867 goto loser; |
| 2901 } | 2868 } |
| 2902 sid->references = 1; | 2869 sid->references = 1; |
| 2903 sid->addr = ss->sec.ci.peer; | 2870 sid->addr = ss->sec.ci.peer; |
| 2904 sid->port = ss->sec.ci.port; | 2871 sid->port = ss->sec.ci.port; |
| 2905 } | 2872 } |
| 2906 | 2873 |
| 2907 /* decode the server's certificate */ | 2874 /* decode the server's certificate */ |
| 2908 rv = ssl2_ClientHandleServerCert(ss, cert, certLen); | 2875 rv = ssl2_ClientHandleServerCert(ss, cert, certLen); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3093 ss->version = sid->version; | 3060 ss->version = sid->version; |
| 3094 PORT_Assert(!ss->sec.localCert); | 3061 PORT_Assert(!ss->sec.localCert); |
| 3095 if (ss->sec.localCert) { | 3062 if (ss->sec.localCert) { |
| 3096 CERT_DestroyCertificate(ss->sec.localCert); | 3063 CERT_DestroyCertificate(ss->sec.localCert); |
| 3097 } | 3064 } |
| 3098 ss->sec.localCert = CERT_DupCertificate(sid->localCert); | 3065 ss->sec.localCert = CERT_DupCertificate(sid->localCert); |
| 3099 break; /* this isn't really a loop */ | 3066 break; /* this isn't really a loop */ |
| 3100 } | 3067 } |
| 3101 if (!sid) { | 3068 if (!sid) { |
| 3102 sidLen = 0; | 3069 sidLen = 0; |
| 3103 » sid = (sslSessionID*) PORT_ZAlloc(sizeof(sslSessionID)); | 3070 » sid = PORT_ZNew(sslSessionID); |
| 3104 if (!sid) { | 3071 if (!sid) { |
| 3105 goto loser; | 3072 goto loser; |
| 3106 } | 3073 } |
| 3107 sid->references = 1; | 3074 sid->references = 1; |
| 3108 sid->cached = never_cached; | 3075 sid->cached = never_cached; |
| 3109 sid->addr = ss->sec.ci.peer; | 3076 sid->addr = ss->sec.ci.peer; |
| 3110 sid->port = ss->sec.ci.port; | 3077 sid->port = ss->sec.ci.port; |
| 3111 if (ss->peerID != NULL) { | 3078 if (ss->peerID != NULL) { |
| 3112 sid->peerID = PORT_Strdup(ss->peerID); | 3079 sid->peerID = PORT_Strdup(ss->peerID); |
| 3113 } | 3080 } |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3519 } else { | 3486 } else { |
| 3520 SECItem * derCert = &serverCert->derCert; | 3487 SECItem * derCert = &serverCert->derCert; |
| 3521 | 3488 |
| 3522 SSL_TRC(7, ("%d: SSL[%d]: server, lookup nonce missed", | 3489 SSL_TRC(7, ("%d: SSL[%d]: server, lookup nonce missed", |
| 3523 SSL_GETPID(), ss->fd)); | 3490 SSL_GETPID(), ss->fd)); |
| 3524 if (!serverCert) { | 3491 if (!serverCert) { |
| 3525 SET_ERROR_CODE | 3492 SET_ERROR_CODE |
| 3526 goto loser; | 3493 goto loser; |
| 3527 } | 3494 } |
| 3528 hit = 0; | 3495 hit = 0; |
| 3529 » sid = (sslSessionID*) PORT_ZAlloc(sizeof(sslSessionID)); | 3496 » sid = PORT_ZNew(sslSessionID); |
| 3530 if (!sid) { | 3497 if (!sid) { |
| 3531 goto loser; | 3498 goto loser; |
| 3532 } | 3499 } |
| 3533 sid->references = 1; | 3500 sid->references = 1; |
| 3534 sid->addr = ss->sec.ci.peer; | 3501 sid->addr = ss->sec.ci.peer; |
| 3535 sid->port = ss->sec.ci.port; | 3502 sid->port = ss->sec.ci.port; |
| 3536 | 3503 |
| 3537 /* Invent a session-id */ | 3504 /* Invent a session-id */ |
| 3538 ss->sec.ci.sid = sid; | 3505 ss->sec.ci.sid = sid; |
| 3539 PK11_GenerateRandom(sid->u.ssl2.sessionID+2, SSL2_SESSIONID_BYTES-2); | 3506 PK11_GenerateRandom(sid->u.ssl2.sessionID+2, SSL2_SESSIONID_BYTES-2); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3721 | 3688 |
| 3722 c = __nss_ssl_rcsid[0] + __nss_ssl_sccsid[0]; | 3689 c = __nss_ssl_rcsid[0] + __nss_ssl_sccsid[0]; |
| 3723 return NSS_VersionCheck(importedVersion); | 3690 return NSS_VersionCheck(importedVersion); |
| 3724 } | 3691 } |
| 3725 | 3692 |
| 3726 const char * | 3693 const char * |
| 3727 NSSSSL_GetVersion(void) | 3694 NSSSSL_GetVersion(void) |
| 3728 { | 3695 { |
| 3729 return NSS_VERSION; | 3696 return NSS_VERSION; |
| 3730 } | 3697 } |
| OLD | NEW |