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

Side by Side Diff: net/third_party/nss/ssl/ssl3ext.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/ssl3ecc.c ('k') | net/third_party/nss/ssl/ssl3gthr.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 /* 1 /*
2 * SSL3 Protocol 2 * SSL3 Protocol
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
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> and
26 * Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
27 * Nagendra Modadugu <ngm@google.com>, Google Inc.
28 *
29 * Alternatively, the contents of this file may be used under the terms of
30 * either the GNU General Public License Version 2 or later (the "GPL"), or
31 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 * in which case the provisions of the GPL or the LGPL are applicable instead
33 * of those above. If you wish to allow use of your version of this file only
34 * under the terms of either the GPL or the LGPL, and not to allow others to
35 * use your version of this file under the terms of the MPL, indicate your
36 * decision by deleting the provisions above and replace them with the notice
37 * and other provisions required by the GPL or the LGPL. If you do not delete
38 * the provisions above, a recipient may use your version of this file under
39 * the terms of any one of the MPL, the GPL or the LGPL.
40 *
41 * ***** END LICENSE BLOCK ***** */
42 7
43 /* TLS extension code moved here from ssl3ecc.c */ 8 /* TLS extension code moved here from ssl3ecc.c */
44 /* $Id: ssl3ext.c,v 1.22 2012/03/12 19:14:12 wtc%google.com Exp $ */ 9 /* $Id: ssl3ext.c,v 1.28 2012/09/21 00:28:05 wtc%google.com Exp $ */
45 10
46 #include "nssrenam.h" 11 #include "nssrenam.h"
47 #include "nss.h" 12 #include "nss.h"
48 #include "ssl.h" 13 #include "ssl.h"
49 #include "sslimpl.h" 14 #include "sslimpl.h"
50 #include "sslproto.h" 15 #include "sslproto.h"
51 #include "pk11pub.h" 16 #include "pk11pub.h"
17 #ifdef NO_PKCS11_BYPASS
18 #include "blapit.h"
19 #else
52 #include "blapi.h" 20 #include "blapi.h"
21 #endif
53 #include "prinit.h" 22 #include "prinit.h"
54 23
55 static unsigned char key_name[SESS_TICKET_KEY_NAME_LEN]; 24 static unsigned char key_name[SESS_TICKET_KEY_NAME_LEN];
56 static PK11SymKey *session_ticket_enc_key_pkcs11 = NULL; 25 static PK11SymKey *session_ticket_enc_key_pkcs11 = NULL;
57 static PK11SymKey *session_ticket_mac_key_pkcs11 = NULL; 26 static PK11SymKey *session_ticket_mac_key_pkcs11 = NULL;
58 27
28 #ifndef NO_PKCS11_BYPASS
59 static unsigned char session_ticket_enc_key[AES_256_KEY_LENGTH]; 29 static unsigned char session_ticket_enc_key[AES_256_KEY_LENGTH];
60 static unsigned char session_ticket_mac_key[SHA256_LENGTH]; 30 static unsigned char session_ticket_mac_key[SHA256_LENGTH];
61 31
62 static PRBool session_ticket_keys_initialized = PR_FALSE; 32 static PRBool session_ticket_keys_initialized = PR_FALSE;
33 #endif
63 static PRCallOnceType generate_session_keys_once; 34 static PRCallOnceType generate_session_keys_once;
64 35
65 /* forward static function declarations */ 36 /* forward static function declarations */
66 static SECStatus ssl3_ParseEncryptedSessionTicket(sslSocket *ss, 37 static SECStatus ssl3_ParseEncryptedSessionTicket(sslSocket *ss,
67 SECItem *data, EncryptedSessionTicket *enc_session_ticket); 38 SECItem *data, EncryptedSessionTicket *enc_session_ticket);
68 static SECStatus ssl3_AppendToItem(SECItem *item, const unsigned char *buf, 39 static SECStatus ssl3_AppendToItem(SECItem *item, const unsigned char *buf,
69 PRUint32 bytes); 40 PRUint32 bytes);
70 static SECStatus ssl3_AppendNumberToItem(SECItem *item, PRUint32 num, 41 static SECStatus ssl3_AppendNumberToItem(SECItem *item, PRUint32 num,
71 PRInt32 lenSize); 42 PRInt32 lenSize);
72 static SECStatus ssl3_GetSessionTicketKeysPKCS11(sslSocket *ss, 43 static SECStatus ssl3_GetSessionTicketKeysPKCS11(sslSocket *ss,
73 PK11SymKey **aes_key, PK11SymKey **mac_key); 44 PK11SymKey **aes_key, PK11SymKey **mac_key);
45 #ifndef NO_PKCS11_BYPASS
74 static SECStatus ssl3_GetSessionTicketKeys(const unsigned char **aes_key, 46 static SECStatus ssl3_GetSessionTicketKeys(const unsigned char **aes_key,
75 PRUint32 *aes_key_length, const unsigned char **mac_key, 47 PRUint32 *aes_key_length, const unsigned char **mac_key,
76 PRUint32 *mac_key_length); 48 PRUint32 *mac_key_length);
49 #endif
77 static PRInt32 ssl3_SendRenegotiationInfoXtn(sslSocket * ss, 50 static PRInt32 ssl3_SendRenegotiationInfoXtn(sslSocket * ss,
78 PRBool append, PRUint32 maxBytes); 51 PRBool append, PRUint32 maxBytes);
79 static SECStatus ssl3_HandleRenegotiationInfoXtn(sslSocket *ss, 52 static SECStatus ssl3_HandleRenegotiationInfoXtn(sslSocket *ss,
80 PRUint16 ex_type, SECItem *data); 53 PRUint16 ex_type, SECItem *data);
81 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, 54 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss,
82 PRUint16 ex_type, SECItem *data); 55 PRUint16 ex_type, SECItem *data);
83 static SECStatus ssl3_ClientHandleChannelIDXtn(sslSocket *ss,
84 PRUint16 ex_type, SECItem *data);
85 static SECStatus ssl3_ServerHandleNextProtoNegoXtn(sslSocket *ss, 56 static SECStatus ssl3_ServerHandleNextProtoNegoXtn(sslSocket *ss,
86 PRUint16 ex_type, SECItem *data); 57 PRUint16 ex_type, SECItem *data);
87 static PRInt32 ssl3_ClientSendNextProtoNegoXtn(sslSocket *ss, PRBool append, 58 static PRInt32 ssl3_ClientSendNextProtoNegoXtn(sslSocket *ss, PRBool append,
88 PRUint32 maxBytes); 59 PRUint32 maxBytes);
89 static PRInt32 ssl3_ClientSendChannelIDXtn(sslSocket *ss, PRBool append,
90 PRUint32 maxBytes);
91 static PRInt32 ssl3_SendUseSRTPXtn(sslSocket *ss, PRBool append, 60 static PRInt32 ssl3_SendUseSRTPXtn(sslSocket *ss, PRBool append,
92 PRUint32 maxBytes); 61 PRUint32 maxBytes);
93 static SECStatus ssl3_HandleUseSRTPXtn(sslSocket * ss, PRUint16 ex_type, 62 static SECStatus ssl3_HandleUseSRTPXtn(sslSocket * ss, PRUint16 ex_type,
94 SECItem *data); 63 SECItem *data);
64 static SECStatus ssl3_ClientHandleChannelIDXtn(sslSocket *ss,
65 PRUint16 ex_type, SECItem *data);
66 static PRInt32 ssl3_ClientSendChannelIDXtn(sslSocket *ss, PRBool append,
67 PRUint32 maxBytes);
95 68
96 /* 69 /*
97 * Write bytes. Using this function means the SECItem structure 70 * Write bytes. Using this function means the SECItem structure
98 * cannot be freed. The caller is expected to call this function 71 * cannot be freed. The caller is expected to call this function
99 * on a shallow copy of the structure. 72 * on a shallow copy of the structure.
100 */ 73 */
101 static SECStatus 74 static SECStatus
102 ssl3_AppendToItem(SECItem *item, const unsigned char *buf, PRUint32 bytes) 75 ssl3_AppendToItem(SECItem *item, const unsigned char *buf, PRUint32 bytes)
103 { 76 {
104 if (bytes > item->len) 77 if (bytes > item->len)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 168
196 if (session_ticket_enc_key_pkcs11 == NULL || 169 if (session_ticket_enc_key_pkcs11 == NULL ||
197 session_ticket_mac_key_pkcs11 == NULL) 170 session_ticket_mac_key_pkcs11 == NULL)
198 return SECFailure; 171 return SECFailure;
199 172
200 *aes_key = session_ticket_enc_key_pkcs11; 173 *aes_key = session_ticket_enc_key_pkcs11;
201 *mac_key = session_ticket_mac_key_pkcs11; 174 *mac_key = session_ticket_mac_key_pkcs11;
202 return SECSuccess; 175 return SECSuccess;
203 } 176 }
204 177
178 #ifndef NO_PKCS11_BYPASS
205 static PRStatus 179 static PRStatus
206 ssl3_GenerateSessionTicketKeys(void) 180 ssl3_GenerateSessionTicketKeys(void)
207 { 181 {
208 PORT_Memcpy(key_name, SESS_TICKET_KEY_NAME_PREFIX, 182 PORT_Memcpy(key_name, SESS_TICKET_KEY_NAME_PREFIX,
209 sizeof(SESS_TICKET_KEY_NAME_PREFIX)); 183 sizeof(SESS_TICKET_KEY_NAME_PREFIX));
210 184
211 if (!ssl_GetSessionTicketKeys(&key_name[SESS_TICKET_KEY_NAME_PREFIX_LEN], 185 if (!ssl_GetSessionTicketKeys(&key_name[SESS_TICKET_KEY_NAME_PREFIX_LEN],
212 session_ticket_enc_key, session_ticket_mac_key)) 186 session_ticket_enc_key, session_ticket_mac_key))
213 return PR_FAILURE; 187 return PR_FAILURE;
214 188
(...skipping 13 matching lines...) Expand all
228 if (!session_ticket_keys_initialized) 202 if (!session_ticket_keys_initialized)
229 return SECFailure; 203 return SECFailure;
230 204
231 *aes_key = session_ticket_enc_key; 205 *aes_key = session_ticket_enc_key;
232 *aes_key_length = sizeof(session_ticket_enc_key); 206 *aes_key_length = sizeof(session_ticket_enc_key);
233 *mac_key = session_ticket_mac_key; 207 *mac_key = session_ticket_mac_key;
234 *mac_key_length = sizeof(session_ticket_mac_key); 208 *mac_key_length = sizeof(session_ticket_mac_key);
235 209
236 return SECSuccess; 210 return SECSuccess;
237 } 211 }
212 #endif
238 213
239 /* Table of handlers for received TLS hello extensions, one per extension. 214 /* Table of handlers for received TLS hello extensions, one per extension.
240 * In the second generation, this table will be dynamic, and functions 215 * In the second generation, this table will be dynamic, and functions
241 * will be registered here. 216 * will be registered here.
242 */ 217 */
243 /* This table is used by the server, to handle client hello extensions. */ 218 /* This table is used by the server, to handle client hello extensions. */
244 static const ssl3HelloExtensionHandler clientHelloHandlers[] = { 219 static const ssl3HelloExtensionHandler clientHelloHandlers[] = {
245 { ssl_server_name_xtn, &ssl3_HandleServerNameXtn }, 220 { ssl_server_name_xtn, &ssl3_HandleServerNameXtn },
246 #ifdef NSS_ENABLE_ECC 221 #ifdef NSS_ENABLE_ECC
247 { ssl_elliptic_curves_xtn, &ssl3_HandleSupportedCurvesXtn }, 222 { ssl_elliptic_curves_xtn, &ssl3_HandleSupportedCurvesXtn },
248 { ssl_ec_point_formats_xtn, &ssl3_HandleSupportedPointFormatsXtn }, 223 { ssl_ec_point_formats_xtn, &ssl3_HandleSupportedPointFormatsXtn },
249 #endif 224 #endif
250 { ssl_session_ticket_xtn, &ssl3_ServerHandleSessionTicketXtn }, 225 { ssl_session_ticket_xtn, &ssl3_ServerHandleSessionTicketXtn },
251 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn }, 226 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn },
252 { ssl_next_proto_nego_xtn, &ssl3_ServerHandleNextProtoNegoXtn }, 227 { ssl_next_proto_nego_xtn, &ssl3_ServerHandleNextProtoNegoXtn },
253 { ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn }, 228 { ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn },
254 { -1, NULL } 229 { -1, NULL }
255 }; 230 };
256 231
257 /* These two tables are used by the client, to handle server hello 232 /* These two tables are used by the client, to handle server hello
258 * extensions. */ 233 * extensions. */
259 static const ssl3HelloExtensionHandler serverHelloHandlersTLS[] = { 234 static const ssl3HelloExtensionHandler serverHelloHandlersTLS[] = {
260 { ssl_server_name_xtn, &ssl3_HandleServerNameXtn }, 235 { ssl_server_name_xtn, &ssl3_HandleServerNameXtn },
261 /* TODO: add a handler for ssl_ec_point_formats_xtn */ 236 /* TODO: add a handler for ssl_ec_point_formats_xtn */
262 { ssl_session_ticket_xtn, &ssl3_ClientHandleSessionTicketXtn }, 237 { ssl_session_ticket_xtn, &ssl3_ClientHandleSessionTicketXtn },
263 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn }, 238 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn },
264 { ssl_next_proto_nego_xtn, &ssl3_ClientHandleNextProtoNegoXtn }, 239 { ssl_next_proto_nego_xtn, &ssl3_ClientHandleNextProtoNegoXtn },
265 { ssl_channel_id_xtn, &ssl3_ClientHandleChannelIDXtn }, 240 { ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn },
241 { ssl_channel_id_xtn, &ssl3_ClientHandleChannelIDXtn },
266 { ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn }, 242 { ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn },
267 { ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn},
268 { -1, NULL } 243 { -1, NULL }
269 }; 244 };
270 245
271 static const ssl3HelloExtensionHandler serverHelloHandlersSSL3[] = { 246 static const ssl3HelloExtensionHandler serverHelloHandlersSSL3[] = {
272 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn }, 247 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn },
273 { -1, NULL } 248 { -1, NULL }
274 }; 249 };
275 250
276 /* Tables of functions to format TLS hello extensions, one function per 251 /* Tables of functions to format TLS hello extensions, one function per
277 * extension. 252 * extension.
278 * These static tables are for the formatting of client hello extensions. 253 * These static tables are for the formatting of client hello extensions.
279 * The server's table of hello senders is dynamic, in the socket struct, 254 * The server's table of hello senders is dynamic, in the socket struct,
280 * and sender functions are registered there. 255 * and sender functions are registered there.
281 */ 256 */
282 static const 257 static const
283 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = { 258 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = {
284 { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, 259 { ssl_server_name_xtn, &ssl3_SendServerNameXtn },
285 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, 260 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn },
286 #ifdef NSS_ENABLE_ECC 261 #ifdef NSS_ENABLE_ECC
287 { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, 262 { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn },
288 { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, 263 { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn },
289 #endif 264 #endif
290 { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, 265 { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn },
291 { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn }, 266 { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn },
267 { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn },
292 { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn }, 268 { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn },
293 { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }, 269 { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }
294 { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }
295 /* any extra entries will appear as { 0, NULL } */ 270 /* any extra entries will appear as { 0, NULL } */
296 }; 271 };
297 272
298 static const 273 static const
299 ssl3HelloExtensionSender clientHelloSendersSSL3[SSL_MAX_EXTENSIONS] = { 274 ssl3HelloExtensionSender clientHelloSendersSSL3[SSL_MAX_EXTENSIONS] = {
300 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn } 275 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }
301 /* any extra entries will appear as { 0, NULL } */ 276 /* any extra entries will appear as { 0, NULL } */
302 }; 277 };
303 278
304 static PRBool 279 static PRBool
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 unsigned char wrapped_ms[SSL3_MASTER_SECRET_LENGTH]; 794 unsigned char wrapped_ms[SSL3_MASTER_SECRET_LENGTH];
820 SECItem ms_item = {0, NULL, 0}; 795 SECItem ms_item = {0, NULL, 0};
821 SSL3KEAType effectiveExchKeyType = ssl_kea_null; 796 SSL3KEAType effectiveExchKeyType = ssl_kea_null;
822 PRUint32 padding_length; 797 PRUint32 padding_length;
823 PRUint32 message_length; 798 PRUint32 message_length;
824 PRUint32 cert_length; 799 PRUint32 cert_length;
825 uint8 length_buf[4]; 800 uint8 length_buf[4];
826 PRUint32 now; 801 PRUint32 now;
827 PK11SymKey *aes_key_pkcs11; 802 PK11SymKey *aes_key_pkcs11;
828 PK11SymKey *mac_key_pkcs11; 803 PK11SymKey *mac_key_pkcs11;
804 #ifndef NO_PKCS11_BYPASS
829 const unsigned char *aes_key; 805 const unsigned char *aes_key;
830 const unsigned char *mac_key; 806 const unsigned char *mac_key;
831 PRUint32 aes_key_length; 807 PRUint32 aes_key_length;
832 PRUint32 mac_key_length; 808 PRUint32 mac_key_length;
833 PRUint64 aes_ctx_buf[MAX_CIPHER_CONTEXT_LLONGS]; 809 PRUint64 aes_ctx_buf[MAX_CIPHER_CONTEXT_LLONGS];
834 AESContext *aes_ctx; 810 AESContext *aes_ctx;
835 CK_MECHANISM_TYPE cipherMech = CKM_AES_CBC;
836 PK11Context *aes_ctx_pkcs11;
837 const SECHashObject *hashObj = NULL; 811 const SECHashObject *hashObj = NULL;
838 PRUint64 hmac_ctx_buf[MAX_MAC_CONTEXT_LLONGS]; 812 PRUint64 hmac_ctx_buf[MAX_MAC_CONTEXT_LLONGS];
839 HMACContext *hmac_ctx; 813 HMACContext *hmac_ctx;
814 #endif
815 CK_MECHANISM_TYPE cipherMech = CKM_AES_CBC;
816 PK11Context *aes_ctx_pkcs11;
840 CK_MECHANISM_TYPE macMech = CKM_SHA256_HMAC; 817 CK_MECHANISM_TYPE macMech = CKM_SHA256_HMAC;
841 PK11Context *hmac_ctx_pkcs11; 818 PK11Context *hmac_ctx_pkcs11;
842 unsigned char computed_mac[TLS_EX_SESS_TICKET_MAC_LENGTH]; 819 unsigned char computed_mac[TLS_EX_SESS_TICKET_MAC_LENGTH];
843 unsigned int computed_mac_length; 820 unsigned int computed_mac_length;
844 unsigned char iv[AES_BLOCK_SIZE]; 821 unsigned char iv[AES_BLOCK_SIZE];
845 SECItem ivItem; 822 SECItem ivItem;
846 SECItem *srvName = NULL; 823 SECItem *srvName = NULL;
847 PRUint32 srvNameLen = 0; 824 PRUint32 srvNameLen = 0;
848 CK_MECHANISM_TYPE msWrapMech = 0; /* dummy default value, 825 CK_MECHANISM_TYPE msWrapMech = 0; /* dummy default value,
849 * must be >= 0 */ 826 * must be >= 0 */
850 827
851 SSL_TRC(3, ("%d: SSL3[%d]: send session_ticket handshake", 828 SSL_TRC(3, ("%d: SSL3[%d]: send session_ticket handshake",
852 SSL_GETPID(), ss->fd)); 829 SSL_GETPID(), ss->fd));
853 830
854 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss)); 831 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss));
855 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); 832 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss));
856 833
857 ticket.ticket_lifetime_hint = TLS_EX_SESS_TICKET_LIFETIME_HINT; 834 ticket.ticket_lifetime_hint = TLS_EX_SESS_TICKET_LIFETIME_HINT;
858 cert_length = (ss->opt.requestCertificate && ss->sec.ci.sid->peerCert) ? 835 cert_length = (ss->opt.requestCertificate && ss->sec.ci.sid->peerCert) ?
859 3 + ss->sec.ci.sid->peerCert->derCert.len : 0; 836 3 + ss->sec.ci.sid->peerCert->derCert.len : 0;
860 837
861 /* Get IV and encryption keys */ 838 /* Get IV and encryption keys */
862 ivItem.data = iv; 839 ivItem.data = iv;
863 ivItem.len = sizeof(iv); 840 ivItem.len = sizeof(iv);
864 rv = PK11_GenerateRandom(iv, sizeof(iv)); 841 rv = PK11_GenerateRandom(iv, sizeof(iv));
865 if (rv != SECSuccess) goto loser; 842 if (rv != SECSuccess) goto loser;
866 843
844 #ifndef NO_PKCS11_BYPASS
867 if (ss->opt.bypassPKCS11) { 845 if (ss->opt.bypassPKCS11) {
868 rv = ssl3_GetSessionTicketKeys(&aes_key, &aes_key_length, 846 rv = ssl3_GetSessionTicketKeys(&aes_key, &aes_key_length,
869 &mac_key, &mac_key_length); 847 &mac_key, &mac_key_length);
870 } else { 848 } else
849 #endif
850 {
871 rv = ssl3_GetSessionTicketKeysPKCS11(ss, &aes_key_pkcs11, 851 rv = ssl3_GetSessionTicketKeysPKCS11(ss, &aes_key_pkcs11,
872 &mac_key_pkcs11); 852 &mac_key_pkcs11);
873 } 853 }
874 if (rv != SECSuccess) goto loser; 854 if (rv != SECSuccess) goto loser;
875 855
876 if (ss->ssl3.pwSpec->msItem.len && ss->ssl3.pwSpec->msItem.data) { 856 if (ss->ssl3.pwSpec->msItem.len && ss->ssl3.pwSpec->msItem.data) {
877 /* The master secret is available unwrapped. */ 857 /* The master secret is available unwrapped. */
878 ms_item.data = ss->ssl3.pwSpec->msItem.data; 858 ms_item.data = ss->ssl3.pwSpec->msItem.data;
879 ms_item.len = ss->ssl3.pwSpec->msItem.len; 859 ms_item.len = ss->ssl3.pwSpec->msItem.len;
880 ms_is_wrapped = PR_FALSE; 860 ms_is_wrapped = PR_FALSE;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 PORT_Assert(plaintext.len == padding_length); 1007 PORT_Assert(plaintext.len == padding_length);
1028 for (i = 0; i < padding_length; i++) 1008 for (i = 0; i < padding_length; i++)
1029 plaintext.data[i] = (unsigned char)padding_length; 1009 plaintext.data[i] = (unsigned char)padding_length;
1030 1010
1031 if (SECITEM_AllocItem(NULL, &ciphertext, ciphertext_length) == NULL) { 1011 if (SECITEM_AllocItem(NULL, &ciphertext, ciphertext_length) == NULL) {
1032 rv = SECFailure; 1012 rv = SECFailure;
1033 goto loser; 1013 goto loser;
1034 } 1014 }
1035 1015
1036 /* Generate encrypted portion of ticket. */ 1016 /* Generate encrypted portion of ticket. */
1017 #ifndef NO_PKCS11_BYPASS
1037 if (ss->opt.bypassPKCS11) { 1018 if (ss->opt.bypassPKCS11) {
1038 aes_ctx = (AESContext *)aes_ctx_buf; 1019 aes_ctx = (AESContext *)aes_ctx_buf;
1039 rv = AES_InitContext(aes_ctx, aes_key, aes_key_length, iv, 1020 rv = AES_InitContext(aes_ctx, aes_key, aes_key_length, iv,
1040 NSS_AES_CBC, 1, AES_BLOCK_SIZE); 1021 NSS_AES_CBC, 1, AES_BLOCK_SIZE);
1041 if (rv != SECSuccess) goto loser; 1022 if (rv != SECSuccess) goto loser;
1042 1023
1043 rv = AES_Encrypt(aes_ctx, ciphertext.data, &ciphertext.len, 1024 rv = AES_Encrypt(aes_ctx, ciphertext.data, &ciphertext.len,
1044 ciphertext.len, plaintext_item.data, 1025 ciphertext.len, plaintext_item.data,
1045 plaintext_item.len); 1026 plaintext_item.len);
1046 if (rv != SECSuccess) goto loser; 1027 if (rv != SECSuccess) goto loser;
1047 } else { 1028 } else
1029 #endif
1030 {
1048 aes_ctx_pkcs11 = PK11_CreateContextBySymKey(cipherMech, 1031 aes_ctx_pkcs11 = PK11_CreateContextBySymKey(cipherMech,
1049 CKA_ENCRYPT, aes_key_pkcs11, &ivItem); 1032 CKA_ENCRYPT, aes_key_pkcs11, &ivItem);
1050 if (!aes_ctx_pkcs11) 1033 if (!aes_ctx_pkcs11)
1051 goto loser; 1034 goto loser;
1052 1035
1053 rv = PK11_CipherOp(aes_ctx_pkcs11, ciphertext.data, 1036 rv = PK11_CipherOp(aes_ctx_pkcs11, ciphertext.data,
1054 (int *)&ciphertext.len, ciphertext.len, 1037 (int *)&ciphertext.len, ciphertext.len,
1055 plaintext_item.data, plaintext_item.len); 1038 plaintext_item.data, plaintext_item.len);
1056 PK11_Finalize(aes_ctx_pkcs11); 1039 PK11_Finalize(aes_ctx_pkcs11);
1057 PK11_DestroyContext(aes_ctx_pkcs11, PR_TRUE); 1040 PK11_DestroyContext(aes_ctx_pkcs11, PR_TRUE);
1058 if (rv != SECSuccess) goto loser; 1041 if (rv != SECSuccess) goto loser;
1059 } 1042 }
1060 1043
1061 /* Convert ciphertext length to network order. */ 1044 /* Convert ciphertext length to network order. */
1062 length_buf[0] = (ciphertext.len >> 8) & 0xff; 1045 length_buf[0] = (ciphertext.len >> 8) & 0xff;
1063 length_buf[1] = (ciphertext.len ) & 0xff; 1046 length_buf[1] = (ciphertext.len ) & 0xff;
1064 1047
1065 /* Compute MAC. */ 1048 /* Compute MAC. */
1049 #ifndef NO_PKCS11_BYPASS
1066 if (ss->opt.bypassPKCS11) { 1050 if (ss->opt.bypassPKCS11) {
1067 hmac_ctx = (HMACContext *)hmac_ctx_buf; 1051 hmac_ctx = (HMACContext *)hmac_ctx_buf;
1068 hashObj = HASH_GetRawHashObject(HASH_AlgSHA256); 1052 hashObj = HASH_GetRawHashObject(HASH_AlgSHA256);
1069 if (HMAC_Init(hmac_ctx, hashObj, mac_key, 1053 if (HMAC_Init(hmac_ctx, hashObj, mac_key,
1070 mac_key_length, PR_FALSE) != SECSuccess) 1054 mac_key_length, PR_FALSE) != SECSuccess)
1071 goto loser; 1055 goto loser;
1072 1056
1073 HMAC_Begin(hmac_ctx); 1057 HMAC_Begin(hmac_ctx);
1074 HMAC_Update(hmac_ctx, key_name, SESS_TICKET_KEY_NAME_LEN); 1058 HMAC_Update(hmac_ctx, key_name, SESS_TICKET_KEY_NAME_LEN);
1075 HMAC_Update(hmac_ctx, iv, sizeof(iv)); 1059 HMAC_Update(hmac_ctx, iv, sizeof(iv));
1076 HMAC_Update(hmac_ctx, (unsigned char *)length_buf, 2); 1060 HMAC_Update(hmac_ctx, (unsigned char *)length_buf, 2);
1077 HMAC_Update(hmac_ctx, ciphertext.data, ciphertext.len); 1061 HMAC_Update(hmac_ctx, ciphertext.data, ciphertext.len);
1078 HMAC_Finish(hmac_ctx, computed_mac, &computed_mac_length, 1062 HMAC_Finish(hmac_ctx, computed_mac, &computed_mac_length,
1079 sizeof(computed_mac)); 1063 sizeof(computed_mac));
1080 } else { 1064 } else
1065 #endif
1066 {
1081 SECItem macParam; 1067 SECItem macParam;
1082 macParam.data = NULL; 1068 macParam.data = NULL;
1083 macParam.len = 0; 1069 macParam.len = 0;
1084 hmac_ctx_pkcs11 = PK11_CreateContextBySymKey(macMech, 1070 hmac_ctx_pkcs11 = PK11_CreateContextBySymKey(macMech,
1085 CKA_SIGN, mac_key_pkcs11, &macParam); 1071 CKA_SIGN, mac_key_pkcs11, &macParam);
1086 if (!hmac_ctx_pkcs11) 1072 if (!hmac_ctx_pkcs11)
1087 goto loser; 1073 goto loser;
1088 1074
1089 rv = PK11_DigestBegin(hmac_ctx_pkcs11); 1075 rv = PK11_DigestBegin(hmac_ctx_pkcs11);
1090 rv = PK11_DigestOp(hmac_ctx_pkcs11, key_name, 1076 rv = PK11_DigestOp(hmac_ctx_pkcs11, key_name,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 * instead of terminating the current connection. 1154 * instead of terminating the current connection.
1169 */ 1155 */
1170 if (data->len == 0) { 1156 if (data->len == 0) {
1171 ss->xtnData.emptySessionTicket = PR_TRUE; 1157 ss->xtnData.emptySessionTicket = PR_TRUE;
1172 } else { 1158 } else {
1173 int i; 1159 int i;
1174 SECItem extension_data; 1160 SECItem extension_data;
1175 EncryptedSessionTicket enc_session_ticket; 1161 EncryptedSessionTicket enc_session_ticket;
1176 unsigned char computed_mac[TLS_EX_SESS_TICKET_MAC_LENGTH]; 1162 unsigned char computed_mac[TLS_EX_SESS_TICKET_MAC_LENGTH];
1177 unsigned int computed_mac_length; 1163 unsigned int computed_mac_length;
1164 #ifndef NO_PKCS11_BYPASS
1178 const SECHashObject *hashObj; 1165 const SECHashObject *hashObj;
1179 const unsigned char *aes_key; 1166 const unsigned char *aes_key;
1180 const unsigned char *mac_key; 1167 const unsigned char *mac_key;
1181 PK11SymKey *aes_key_pkcs11;
1182 PK11SymKey *mac_key_pkcs11;
1183 PRUint32 aes_key_length; 1168 PRUint32 aes_key_length;
1184 PRUint32 mac_key_length; 1169 PRUint32 mac_key_length;
1185 PRUint64 hmac_ctx_buf[MAX_MAC_CONTEXT_LLONGS]; 1170 PRUint64 hmac_ctx_buf[MAX_MAC_CONTEXT_LLONGS];
1186 HMACContext *hmac_ctx; 1171 HMACContext *hmac_ctx;
1172 PRUint64 aes_ctx_buf[MAX_CIPHER_CONTEXT_LLONGS];
1173 AESContext *aes_ctx;
1174 #endif
1175 PK11SymKey *aes_key_pkcs11;
1176 PK11SymKey *mac_key_pkcs11;
1187 PK11Context *hmac_ctx_pkcs11; 1177 PK11Context *hmac_ctx_pkcs11;
1188 CK_MECHANISM_TYPE macMech = CKM_SHA256_HMAC; 1178 CK_MECHANISM_TYPE macMech = CKM_SHA256_HMAC;
1189 PRUint64 aes_ctx_buf[MAX_CIPHER_CONTEXT_LLONGS];
1190 AESContext *aes_ctx;
1191 PK11Context *aes_ctx_pkcs11; 1179 PK11Context *aes_ctx_pkcs11;
1192 CK_MECHANISM_TYPE cipherMech = CKM_AES_CBC; 1180 CK_MECHANISM_TYPE cipherMech = CKM_AES_CBC;
1193 unsigned char * padding; 1181 unsigned char * padding;
1194 PRUint32 padding_length; 1182 PRUint32 padding_length;
1195 unsigned char *buffer; 1183 unsigned char *buffer;
1196 unsigned int buffer_len; 1184 unsigned int buffer_len;
1197 PRInt32 temp; 1185 PRInt32 temp;
1198 SECItem cert_item; 1186 SECItem cert_item;
1199 PRInt8 nameType = TLS_STE_NO_SERVER_NAME; 1187 PRInt8 nameType = TLS_STE_NO_SERVER_NAME;
1200 1188
(...skipping 10 matching lines...) Expand all
1211 } 1199 }
1212 1200
1213 extension_data.data = data->data; /* Keep a copy for future use. */ 1201 extension_data.data = data->data; /* Keep a copy for future use. */
1214 extension_data.len = data->len; 1202 extension_data.len = data->len;
1215 1203
1216 if (ssl3_ParseEncryptedSessionTicket(ss, data, &enc_session_ticket) 1204 if (ssl3_ParseEncryptedSessionTicket(ss, data, &enc_session_ticket)
1217 != SECSuccess) 1205 != SECSuccess)
1218 return SECFailure; 1206 return SECFailure;
1219 1207
1220 /* Get session ticket keys. */ 1208 /* Get session ticket keys. */
1209 #ifndef NO_PKCS11_BYPASS
1221 if (ss->opt.bypassPKCS11) { 1210 if (ss->opt.bypassPKCS11) {
1222 rv = ssl3_GetSessionTicketKeys(&aes_key, &aes_key_length, 1211 rv = ssl3_GetSessionTicketKeys(&aes_key, &aes_key_length,
1223 &mac_key, &mac_key_length); 1212 &mac_key, &mac_key_length);
1224 » } else { 1213 » } else
1214 #endif
1215 {
1225 rv = ssl3_GetSessionTicketKeysPKCS11(ss, &aes_key_pkcs11, 1216 rv = ssl3_GetSessionTicketKeysPKCS11(ss, &aes_key_pkcs11,
1226 &mac_key_pkcs11); 1217 &mac_key_pkcs11);
1227 } 1218 }
1228 if (rv != SECSuccess) { 1219 if (rv != SECSuccess) {
1229 SSL_DBG(("%d: SSL[%d]: Unable to get/generate session ticket keys.", 1220 SSL_DBG(("%d: SSL[%d]: Unable to get/generate session ticket keys.",
1230 SSL_GETPID(), ss->fd)); 1221 SSL_GETPID(), ss->fd));
1231 goto loser; 1222 goto loser;
1232 } 1223 }
1233 1224
1234 /* If the ticket sent by the client was generated under a key different 1225 /* If the ticket sent by the client was generated under a key different
1235 * from the one we have, bypass ticket processing. 1226 * from the one we have, bypass ticket processing.
1236 */ 1227 */
1237 if (PORT_Memcmp(enc_session_ticket.key_name, key_name, 1228 if (PORT_Memcmp(enc_session_ticket.key_name, key_name,
1238 SESS_TICKET_KEY_NAME_LEN) != 0) { 1229 SESS_TICKET_KEY_NAME_LEN) != 0) {
1239 SSL_DBG(("%d: SSL[%d]: Session ticket key_name sent mismatch.", 1230 SSL_DBG(("%d: SSL[%d]: Session ticket key_name sent mismatch.",
1240 SSL_GETPID(), ss->fd)); 1231 SSL_GETPID(), ss->fd));
1241 goto no_ticket; 1232 goto no_ticket;
1242 } 1233 }
1243 1234
1244 /* Verify the MAC on the ticket. MAC verification may also 1235 /* Verify the MAC on the ticket. MAC verification may also
1245 * fail if the MAC key has been recently refreshed. 1236 * fail if the MAC key has been recently refreshed.
1246 */ 1237 */
1238 #ifndef NO_PKCS11_BYPASS
1247 if (ss->opt.bypassPKCS11) { 1239 if (ss->opt.bypassPKCS11) {
1248 hmac_ctx = (HMACContext *)hmac_ctx_buf; 1240 hmac_ctx = (HMACContext *)hmac_ctx_buf;
1249 hashObj = HASH_GetRawHashObject(HASH_AlgSHA256); 1241 hashObj = HASH_GetRawHashObject(HASH_AlgSHA256);
1250 if (HMAC_Init(hmac_ctx, hashObj, mac_key, 1242 if (HMAC_Init(hmac_ctx, hashObj, mac_key,
1251 sizeof(session_ticket_mac_key), PR_FALSE) != SECSuccess) 1243 sizeof(session_ticket_mac_key), PR_FALSE) != SECSuccess)
1252 goto no_ticket; 1244 goto no_ticket;
1253 HMAC_Begin(hmac_ctx); 1245 HMAC_Begin(hmac_ctx);
1254 HMAC_Update(hmac_ctx, extension_data.data, 1246 HMAC_Update(hmac_ctx, extension_data.data,
1255 extension_data.len - TLS_EX_SESS_TICKET_MAC_LENGTH); 1247 extension_data.len - TLS_EX_SESS_TICKET_MAC_LENGTH);
1256 if (HMAC_Finish(hmac_ctx, computed_mac, &computed_mac_length, 1248 if (HMAC_Finish(hmac_ctx, computed_mac, &computed_mac_length,
1257 sizeof(computed_mac)) != SECSuccess) 1249 sizeof(computed_mac)) != SECSuccess)
1258 goto no_ticket; 1250 goto no_ticket;
1259 » } else { 1251 » } else
1252 #endif
1253 {
1260 SECItem macParam; 1254 SECItem macParam;
1261 macParam.data = NULL; 1255 macParam.data = NULL;
1262 macParam.len = 0; 1256 macParam.len = 0;
1263 hmac_ctx_pkcs11 = PK11_CreateContextBySymKey(macMech, 1257 hmac_ctx_pkcs11 = PK11_CreateContextBySymKey(macMech,
1264 CKA_SIGN, mac_key_pkcs11, &macParam); 1258 CKA_SIGN, mac_key_pkcs11, &macParam);
1265 if (!hmac_ctx_pkcs11) { 1259 if (!hmac_ctx_pkcs11) {
1266 SSL_DBG(("%d: SSL[%d]: Unable to create HMAC context: %d.", 1260 SSL_DBG(("%d: SSL[%d]: Unable to create HMAC context: %d.",
1267 SSL_GETPID(), ss->fd, PORT_GetError())); 1261 SSL_GETPID(), ss->fd, PORT_GetError()));
1268 goto no_ticket; 1262 goto no_ticket;
1269 } else { 1263 } else {
(...skipping 23 matching lines...) Expand all
1293 /* We ignore key_name for now. 1287 /* We ignore key_name for now.
1294 * This is ok as MAC verification succeeded. 1288 * This is ok as MAC verification succeeded.
1295 */ 1289 */
1296 1290
1297 /* Decrypt the ticket. */ 1291 /* Decrypt the ticket. */
1298 1292
1299 /* Plaintext is shorter than the ciphertext due to padding. */ 1293 /* Plaintext is shorter than the ciphertext due to padding. */
1300 decrypted_state = SECITEM_AllocItem(NULL, NULL, 1294 decrypted_state = SECITEM_AllocItem(NULL, NULL,
1301 enc_session_ticket.encrypted_state.len); 1295 enc_session_ticket.encrypted_state.len);
1302 1296
1297 #ifndef NO_PKCS11_BYPASS
1303 if (ss->opt.bypassPKCS11) { 1298 if (ss->opt.bypassPKCS11) {
1304 aes_ctx = (AESContext *)aes_ctx_buf; 1299 aes_ctx = (AESContext *)aes_ctx_buf;
1305 rv = AES_InitContext(aes_ctx, aes_key, 1300 rv = AES_InitContext(aes_ctx, aes_key,
1306 sizeof(session_ticket_enc_key), enc_session_ticket.iv, 1301 sizeof(session_ticket_enc_key), enc_session_ticket.iv,
1307 NSS_AES_CBC, 0,AES_BLOCK_SIZE); 1302 NSS_AES_CBC, 0,AES_BLOCK_SIZE);
1308 if (rv != SECSuccess) { 1303 if (rv != SECSuccess) {
1309 SSL_DBG(("%d: SSL[%d]: Unable to create AES context.", 1304 SSL_DBG(("%d: SSL[%d]: Unable to create AES context.",
1310 SSL_GETPID(), ss->fd)); 1305 SSL_GETPID(), ss->fd));
1311 goto no_ticket; 1306 goto no_ticket;
1312 } 1307 }
1313 1308
1314 rv = AES_Decrypt(aes_ctx, decrypted_state->data, 1309 rv = AES_Decrypt(aes_ctx, decrypted_state->data,
1315 &decrypted_state->len, decrypted_state->len, 1310 &decrypted_state->len, decrypted_state->len,
1316 enc_session_ticket.encrypted_state.data, 1311 enc_session_ticket.encrypted_state.data,
1317 enc_session_ticket.encrypted_state.len); 1312 enc_session_ticket.encrypted_state.len);
1318 if (rv != SECSuccess) 1313 if (rv != SECSuccess)
1319 goto no_ticket; 1314 goto no_ticket;
1320 » } else { 1315 » } else
1316 #endif
1317 {
1321 SECItem ivItem; 1318 SECItem ivItem;
1322 ivItem.data = enc_session_ticket.iv; 1319 ivItem.data = enc_session_ticket.iv;
1323 ivItem.len = AES_BLOCK_SIZE; 1320 ivItem.len = AES_BLOCK_SIZE;
1324 aes_ctx_pkcs11 = PK11_CreateContextBySymKey(cipherMech, 1321 aes_ctx_pkcs11 = PK11_CreateContextBySymKey(cipherMech,
1325 CKA_DECRYPT, aes_key_pkcs11, &ivItem); 1322 CKA_DECRYPT, aes_key_pkcs11, &ivItem);
1326 if (!aes_ctx_pkcs11) { 1323 if (!aes_ctx_pkcs11) {
1327 SSL_DBG(("%d: SSL[%d]: Unable to create AES context.", 1324 SSL_DBG(("%d: SSL[%d]: Unable to create AES context.",
1328 SSL_GETPID(), ss->fd)); 1325 SSL_GETPID(), ss->fd));
1329 goto no_ticket; 1326 goto no_ticket;
1330 } 1327 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 /* Copy over parameters. */ 1481 /* Copy over parameters. */
1485 sid->version = parsed_session_ticket->ssl_version; 1482 sid->version = parsed_session_ticket->ssl_version;
1486 sid->u.ssl3.cipherSuite = parsed_session_ticket->cipher_suite; 1483 sid->u.ssl3.cipherSuite = parsed_session_ticket->cipher_suite;
1487 sid->u.ssl3.compression = parsed_session_ticket->compression_method; 1484 sid->u.ssl3.compression = parsed_session_ticket->compression_method;
1488 sid->authAlgorithm = parsed_session_ticket->authAlgorithm; 1485 sid->authAlgorithm = parsed_session_ticket->authAlgorithm;
1489 sid->authKeyBits = parsed_session_ticket->authKeyBits; 1486 sid->authKeyBits = parsed_session_ticket->authKeyBits;
1490 sid->keaType = parsed_session_ticket->keaType; 1487 sid->keaType = parsed_session_ticket->keaType;
1491 sid->keaKeyBits = parsed_session_ticket->keaKeyBits; 1488 sid->keaKeyBits = parsed_session_ticket->keaKeyBits;
1492 1489
1493 /* Copy master secret. */ 1490 /* Copy master secret. */
1491 #ifndef NO_PKCS11_BYPASS
1494 if (ss->opt.bypassPKCS11 && 1492 if (ss->opt.bypassPKCS11 &&
1495 parsed_session_ticket->ms_is_wrapped) 1493 parsed_session_ticket->ms_is_wrapped)
1496 goto no_ticket; 1494 goto no_ticket;
1495 #endif
1497 if (parsed_session_ticket->ms_length > 1496 if (parsed_session_ticket->ms_length >
1498 sizeof(sid->u.ssl3.keys.wrapped_master_secret)) 1497 sizeof(sid->u.ssl3.keys.wrapped_master_secret))
1499 goto no_ticket; 1498 goto no_ticket;
1500 PORT_Memcpy(sid->u.ssl3.keys.wrapped_master_secret, 1499 PORT_Memcpy(sid->u.ssl3.keys.wrapped_master_secret,
1501 parsed_session_ticket->master_secret, 1500 parsed_session_ticket->master_secret,
1502 parsed_session_ticket->ms_length); 1501 parsed_session_ticket->ms_length);
1503 sid->u.ssl3.keys.wrapped_master_secret_len = 1502 sid->u.ssl3.keys.wrapped_master_secret_len =
1504 parsed_session_ticket->ms_length; 1503 parsed_session_ticket->ms_length;
1505 sid->u.ssl3.exchKeyType = parsed_session_ticket->exchKeyType; 1504 sid->u.ssl3.exchKeyType = parsed_session_ticket->exchKeyType;
1506 sid->u.ssl3.masterWrapMech = parsed_session_ticket->msWrapMech; 1505 sid->u.ssl3.masterWrapMech = parsed_session_ticket->msWrapMech;
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 } 1854 }
1856 1855
1857 return 9; 1856 return 9;
1858 } 1857 }
1859 1858
1860 static SECStatus 1859 static SECStatus
1861 ssl3_HandleUseSRTPXtn(sslSocket * ss, PRUint16 ex_type, SECItem *data) 1860 ssl3_HandleUseSRTPXtn(sslSocket * ss, PRUint16 ex_type, SECItem *data)
1862 { 1861 {
1863 SECStatus rv; 1862 SECStatus rv;
1864 SECItem ciphers = {siBuffer, NULL, 0}; 1863 SECItem ciphers = {siBuffer, NULL, 0};
1865 PRInt16 i; 1864 PRUint16 i;
1866 PRInt16 j; 1865 unsigned int j;
1867 PRUint16 cipher = 0; 1866 PRUint16 cipher = 0;
1868 PRBool found = PR_FALSE; 1867 PRBool found = PR_FALSE;
1869 SECItem litem; 1868 SECItem litem;
1870 1869
1871 if (!ss->sec.isServer) { 1870 if (!ss->sec.isServer) {
1872 /* Client side */ 1871 /* Client side */
1873 if (!data->data || !data->len) { 1872 if (!data->data || !data->len) {
1874 /* malformed */ 1873 /* malformed */
1875 return SECFailure; 1874 return SECFailure;
1876 } 1875 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 return SECSuccess; 1985 return SECSuccess;
1987 } 1986 }
1988 1987
1989 /* OK, we have a valid cipher and we've selected it */ 1988 /* OK, we have a valid cipher and we've selected it */
1990 ss->ssl3.dtlsSRTPCipherSuite = cipher; 1989 ss->ssl3.dtlsSRTPCipherSuite = cipher;
1991 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ssl_use_srtp_xtn; 1990 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ssl_use_srtp_xtn;
1992 1991
1993 return ssl3_RegisterServerHelloExtensionSender(ss, ssl_use_srtp_xtn, 1992 return ssl3_RegisterServerHelloExtensionSender(ss, ssl_use_srtp_xtn,
1994 ssl3_SendUseSRTPXtn); 1993 ssl3_SendUseSRTPXtn);
1995 } 1994 }
OLDNEW
« no previous file with comments | « net/third_party/nss/ssl/ssl3ecc.c ('k') | net/third_party/nss/ssl/ssl3gthr.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698