OLD | NEW |
1 diff -pu a/nss/lib/ssl/ssl3con.c b/nss/lib/ssl/ssl3con.c | 1 diff -pu a/nss/lib/ssl/ssl3con.c b/nss/lib/ssl/ssl3con.c |
2 --- a/nss/lib/ssl/ssl3con.c» 2013-07-31 14:17:20.669282120 -0700 | 2 --- a/nss/lib/ssl/ssl3con.c» 2014-01-03 19:41:44.744240754 -0800 |
3 +++ b/nss/lib/ssl/ssl3con.c» 2013-07-31 14:28:56.549496061 -0700 | 3 +++ b/nss/lib/ssl/ssl3con.c» 2014-01-03 19:41:52.234363230 -0800 |
4 @@ -9912,8 +9912,10 @@ ssl3_SendNextProto(sslSocket *ss) | 4 @@ -10458,8 +10458,10 @@ ssl3_SendNextProto(sslSocket *ss) |
5 int padding_len; | 5 int padding_len; |
6 static const unsigned char padding[32] = {0}; | 6 static const unsigned char padding[32] = {0}; |
7 | 7 |
8 - if (ss->ssl3.nextProto.len == 0) | 8 - if (ss->ssl3.nextProto.len == 0) |
9 + if (ss->ssl3.nextProto.len == 0 || | 9 + if (ss->ssl3.nextProto.len == 0 || |
10 + ss->ssl3.nextProtoState == SSL_NEXT_PROTO_SELECTED) { | 10 + ss->ssl3.nextProtoState == SSL_NEXT_PROTO_SELECTED) { |
11 return SECSuccess; | 11 return SECSuccess; |
12 + } | 12 + } |
13 | 13 |
14 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss)); | 14 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss)); |
15 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); | 15 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); |
16 diff -pu a/nss/lib/ssl/ssl3ext.c b/nss/lib/ssl/ssl3ext.c | 16 diff -pu a/nss/lib/ssl/ssl3ext.c b/nss/lib/ssl/ssl3ext.c |
17 --- a/nss/lib/ssl/ssl3ext.c» 2013-07-31 14:10:00.342814862 -0700 | 17 --- a/nss/lib/ssl/ssl3ext.c» 2014-01-03 19:39:28.442012014 -0800 |
18 +++ b/nss/lib/ssl/ssl3ext.c» 2013-07-31 14:28:56.549496061 -0700 | 18 +++ b/nss/lib/ssl/ssl3ext.c» 2014-01-03 19:41:52.234363230 -0800 |
19 @@ -53,8 +53,12 @@ static SECStatus ssl3_HandleRenegotiationInfoXtn(sslSocket *s
s, | 19 @@ -52,8 +52,12 @@ static SECStatus ssl3_HandleRenegotiatio |
20 PRUint16 ex_type, SECItem *data); | 20 PRUint16 ex_type, SECItem *data); |
21 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, | 21 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, |
22 PRUint16 ex_type, SECItem *data); | 22 PRUint16 ex_type, SECItem *data); |
23 +static SECStatus ssl3_ClientHandleAppProtoXtn(sslSocket *ss, | 23 +static SECStatus ssl3_ClientHandleAppProtoXtn(sslSocket *ss, |
24 + PRUint16 ex_type, SECItem *data); | 24 + PRUint16 ex_type, SECItem *data); |
25 static SECStatus ssl3_ServerHandleNextProtoNegoXtn(sslSocket *ss, | 25 static SECStatus ssl3_ServerHandleNextProtoNegoXtn(sslSocket *ss, |
26 PRUint16 ex_type, SECItem *data); | 26 PRUint16 ex_type, SECItem *data); |
27 +static PRInt32 ssl3_ClientSendAppProtoXtn(sslSocket *ss, PRBool append, | 27 +static PRInt32 ssl3_ClientSendAppProtoXtn(sslSocket *ss, PRBool append, |
28 + PRUint32 maxBytes); | 28 + PRUint32 maxBytes); |
29 static PRInt32 ssl3_ClientSendNextProtoNegoXtn(sslSocket *ss, PRBool append, | 29 static PRInt32 ssl3_ClientSendNextProtoNegoXtn(sslSocket *ss, PRBool append, |
30 PRUint32 maxBytes); | 30 PRUint32 maxBytes); |
31 static PRInt32 ssl3_SendUseSRTPXtn(sslSocket *ss, PRBool append, | 31 static PRInt32 ssl3_SendUseSRTPXtn(sslSocket *ss, PRBool append, |
32 @@ -252,6 +256,7 @@ static const ssl3HelloExtensionHandler serverHelloHandlersTL
S[] = { | 32 @@ -251,6 +255,7 @@ static const ssl3HelloExtensionHandler s |
33 { ssl_session_ticket_xtn, &ssl3_ClientHandleSessionTicketXtn }, | 33 { ssl_session_ticket_xtn, &ssl3_ClientHandleSessionTicketXtn }, |
34 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn }, | 34 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn }, |
35 { ssl_next_proto_nego_xtn, &ssl3_ClientHandleNextProtoNegoXtn }, | 35 { ssl_next_proto_nego_xtn, &ssl3_ClientHandleNextProtoNegoXtn }, |
36 + { ssl_app_layer_protocol_xtn, &ssl3_ClientHandleAppProtoXtn }, | 36 + { ssl_app_layer_protocol_xtn, &ssl3_ClientHandleAppProtoXtn }, |
37 { ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn }, | 37 { ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn }, |
38 { ssl_channel_id_xtn, &ssl3_ClientHandleChannelIDXtn }, | 38 { ssl_channel_id_xtn, &ssl3_ClientHandleChannelIDXtn }, |
39 { ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn }, | 39 { ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn }, |
40 @@ -271,18 +276,19 @@ static const ssl3HelloExtensionHandler serverHelloHandlers
SSL3[] = { | 40 @@ -270,18 +275,19 @@ static const ssl3HelloExtensionHandler s |
41 */ | 41 */ |
42 static const | 42 static const |
43 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = { | 43 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = { |
44 - { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, | 44 - { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, |
45 - { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, | 45 - { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, |
46 + { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, | 46 + { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, |
47 + { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, | 47 + { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, |
48 #ifdef NSS_ENABLE_ECC | 48 #ifdef NSS_ENABLE_ECC |
49 - { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, | 49 - { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, |
50 - { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, | 50 - { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, |
51 + { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, | 51 + { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, |
52 + { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, | 52 + { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, |
53 #endif | 53 #endif |
54 - { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, | 54 - { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, |
55 - { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn }, | 55 - { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn }, |
56 - { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }, | 56 - { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }, |
57 - { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn }, | 57 - { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn }, |
58 - { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }, | 58 - { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }, |
59 - { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn } | 59 - { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn } |
60 + { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, | 60 + { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, |
61 + { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn }, | 61 + { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn }, |
62 + { ssl_app_layer_protocol_xtn, &ssl3_ClientSendAppProtoXtn }, | 62 + { ssl_app_layer_protocol_xtn, &ssl3_ClientSendAppProtoXtn }, |
63 + { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }, | 63 + { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }, |
64 + { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn }, | 64 + { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn }, |
65 + { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }, | 65 + { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }, |
66 + { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn } | 66 + { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn } |
67 /* any extra entries will appear as { 0, NULL } */ | 67 /* any extra entries will appear as { 0, NULL } */ |
68 }; | 68 }; |
69 | 69 |
70 @@ -606,6 +612,11 @@ ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, PRUint16 e
x_type, | 70 @@ -614,6 +620,11 @@ ssl3_ClientHandleNextProtoNegoXtn(sslSoc |
71 | 71 |
72 PORT_Assert(!ss->firstHsDone); | 72 PORT_Assert(!ss->firstHsDone); |
73 | 73 |
74 + if (ssl3_ExtensionNegotiated(ss, ssl_app_layer_protocol_xtn)) { | 74 + if (ssl3_ExtensionNegotiated(ss, ssl_app_layer_protocol_xtn)) { |
75 + PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); | 75 + PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); |
76 + return SECFailure; | 76 + return SECFailure; |
77 + } | 77 + } |
78 + | 78 + |
79 rv = ssl3_ValidateNextProtoNego(data->data, data->len); | 79 rv = ssl3_ValidateNextProtoNego(data->data, data->len); |
80 if (rv != SECSuccess) | 80 if (rv != SECSuccess) |
81 return rv; | 81 return rv; |
82 @@ -639,6 +650,44 @@ ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, PRUint16 e
x_type, | 82 @@ -647,6 +658,44 @@ ssl3_ClientHandleNextProtoNegoXtn(sslSoc |
83 return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &result); | 83 return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &result); |
84 } | 84 } |
85 | 85 |
86 +static SECStatus | 86 +static SECStatus |
87 +ssl3_ClientHandleAppProtoXtn(sslSocket *ss, PRUint16 ex_type, SECItem *data) | 87 +ssl3_ClientHandleAppProtoXtn(sslSocket *ss, PRUint16 ex_type, SECItem *data) |
88 +{ | 88 +{ |
89 + const unsigned char* d = data->data; | 89 + const unsigned char* d = data->data; |
90 + PRUint16 name_list_len; | 90 + PRUint16 name_list_len; |
91 + SECItem protocol_name; | 91 + SECItem protocol_name; |
92 + | 92 + |
(...skipping 24 matching lines...) Expand all Loading... |
117 + | 117 + |
118 + SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); | 118 + SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); |
119 + ss->ssl3.nextProtoState = SSL_NEXT_PROTO_SELECTED; | 119 + ss->ssl3.nextProtoState = SSL_NEXT_PROTO_SELECTED; |
120 + ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type; | 120 + ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type; |
121 + return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &protocol_name); | 121 + return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &protocol_name); |
122 +} | 122 +} |
123 + | 123 + |
124 static PRInt32 | 124 static PRInt32 |
125 ssl3_ClientSendNextProtoNegoXtn(sslSocket * ss, PRBool append, | 125 ssl3_ClientSendNextProtoNegoXtn(sslSocket * ss, PRBool append, |
126 PRUint32 maxBytes) | 126 PRUint32 maxBytes) |
127 @@ -672,6 +721,70 @@ loser: | 127 @@ -680,6 +729,70 @@ loser: |
128 return -1; | 128 return -1; |
129 } | 129 } |
130 | 130 |
131 +static PRInt32 | 131 +static PRInt32 |
132 +ssl3_ClientSendAppProtoXtn(sslSocket * ss, PRBool append, PRUint32 maxBytes) | 132 +ssl3_ClientSendAppProtoXtn(sslSocket * ss, PRBool append, PRUint32 maxBytes) |
133 +{ | 133 +{ |
134 + PRInt32 extension_length; | 134 + PRInt32 extension_length; |
135 + unsigned char *alpn_protos = NULL; | 135 + unsigned char *alpn_protos = NULL; |
136 + | 136 + |
137 + /* Renegotiations do not send this extension. */ | 137 + /* Renegotiations do not send this extension. */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 +loser: | 189 +loser: |
190 + if (alpn_protos) | 190 + if (alpn_protos) |
191 + PORT_Free(alpn_protos); | 191 + PORT_Free(alpn_protos); |
192 + return -1; | 192 + return -1; |
193 +} | 193 +} |
194 + | 194 + |
195 static SECStatus | 195 static SECStatus |
196 ssl3_ClientHandleChannelIDXtn(sslSocket *ss, PRUint16 ex_type, | 196 ssl3_ClientHandleChannelIDXtn(sslSocket *ss, PRUint16 ex_type, |
197 SECItem *data) | 197 SECItem *data) |
198 diff -pu a/nss/lib/ssl/ssl.h b/nss/lib/ssl/ssl.h | 198 diff -pu a/nss/lib/ssl/ssl.h b/nss/lib/ssl/ssl.h |
199 --- a/nss/lib/ssl/ssl.h»2013-07-31 14:10:35.113325316 -0700 | 199 --- a/nss/lib/ssl/ssl.h»2014-01-03 19:40:03.522585625 -0800 |
200 +++ b/nss/lib/ssl/ssl.h»2013-07-31 14:28:56.589496647 -0700 | 200 +++ b/nss/lib/ssl/ssl.h»2014-01-03 19:41:52.234363230 -0800 |
201 @@ -203,6 +203,16 @@ SSL_IMPORT SECStatus SSL_SetNextProtoCal | 201 @@ -206,6 +206,16 @@ SSL_IMPORT SECStatus SSL_SetNextProtoCal |
202 * protocol in server-preference order. If no matching protocol is found it | 202 * protocol in server-preference order. If no matching protocol is found it |
203 * selects the first supported protocol. | 203 * selects the first supported protocol. |
204 * | 204 * |
205 + * Using this function also allows the client to transparently support ALPN. | 205 + * Using this function also allows the client to transparently support ALPN. |
206 + * The same set of protocols will be advertised via ALPN and, if the server | 206 + * The same set of protocols will be advertised via ALPN and, if the server |
207 + * uses ALPN to select a protocol, SSL_GetNextProto will return | 207 + * uses ALPN to select a protocol, SSL_GetNextProto will return |
208 + * SSL_NEXT_PROTO_SELECTED as the state. | 208 + * SSL_NEXT_PROTO_SELECTED as the state. |
209 + * | 209 + * |
210 + * Since NPN uses the first protocol as the fallback protocol, when sending an | 210 + * Since NPN uses the first protocol as the fallback protocol, when sending an |
211 + * ALPN extension, the first protocol is moved to the end of the list. This | 211 + * ALPN extension, the first protocol is moved to the end of the list. This |
212 + * indicates that the fallback protocol is the least preferred. The other | 212 + * indicates that the fallback protocol is the least preferred. The other |
213 + * protocols should be in preference order. | 213 + * protocols should be in preference order. |
214 + * | 214 + * |
215 * The supported protocols are specified in |data| in wire-format (8-bit | 215 * The supported protocols are specified in |data| in wire-format (8-bit |
216 * length-prefixed). For example: "\010http/1.1\006spdy/2". */ | 216 * length-prefixed). For example: "\010http/1.1\006spdy/2". */ |
217 SSL_IMPORT SECStatus SSL_SetNextProtoNego(PRFileDesc *fd, | 217 SSL_IMPORT SECStatus SSL_SetNextProtoNego(PRFileDesc *fd, |
218 @@ -212,7 +217,8 @@ SSL_IMPORT SECStatus SSL_SetNextProtoNeg | 218 @@ -215,7 +225,8 @@ SSL_IMPORT SECStatus SSL_SetNextProtoNeg |
219 typedef enum SSLNextProtoState { | 219 typedef enum SSLNextProtoState { |
220 SSL_NEXT_PROTO_NO_SUPPORT = 0, /* No peer support */ | 220 SSL_NEXT_PROTO_NO_SUPPORT = 0, /* No peer support */ |
221 SSL_NEXT_PROTO_NEGOTIATED = 1, /* Mutual agreement */ | 221 SSL_NEXT_PROTO_NEGOTIATED = 1, /* Mutual agreement */ |
222 - SSL_NEXT_PROTO_NO_OVERLAP = 2 /* No protocol overlap found */ | 222 - SSL_NEXT_PROTO_NO_OVERLAP = 2 /* No protocol overlap found */ |
223 + SSL_NEXT_PROTO_NO_OVERLAP = 2, /* No protocol overlap found */ | 223 + SSL_NEXT_PROTO_NO_OVERLAP = 2, /* No protocol overlap found */ |
224 + SSL_NEXT_PROTO_SELECTED = 3 /* Server selected proto (ALPN) */ | 224 + SSL_NEXT_PROTO_SELECTED = 3 /* Server selected proto (ALPN) */ |
225 } SSLNextProtoState; | 225 } SSLNextProtoState; |
226 | 226 |
227 /* SSL_GetNextProto can be used in the HandshakeCallback or any time after | 227 /* SSL_GetNextProto can be used in the HandshakeCallback or any time after |
228 diff -pu a/nss/lib/ssl/sslt.h b/nss/lib/ssl/sslt.h | 228 diff -pu a/nss/lib/ssl/sslt.h b/nss/lib/ssl/sslt.h |
229 --- a/nss/lib/ssl/sslt.h» 2013-07-31 14:13:43.806096237 -0700 | 229 --- a/nss/lib/ssl/sslt.h» 2014-01-03 19:41:26.443941511 -0800 |
230 +++ b/nss/lib/ssl/sslt.h» 2013-07-31 14:28:56.609496941 -0700 | 230 +++ b/nss/lib/ssl/sslt.h» 2014-01-03 19:41:52.234363230 -0800 |
231 @@ -195,12 +195,13 @@ typedef enum { | 231 @@ -200,12 +200,13 @@ typedef enum { |
232 #endif | 232 #endif |
233 ssl_signature_algorithms_xtn = 13, | 233 ssl_signature_algorithms_xtn = 13, |
234 ssl_use_srtp_xtn = 14, | 234 ssl_use_srtp_xtn = 14, |
235 + ssl_app_layer_protocol_xtn = 16, | 235 + ssl_app_layer_protocol_xtn = 16, |
236 ssl_session_ticket_xtn = 35, | 236 ssl_session_ticket_xtn = 35, |
237 ssl_next_proto_nego_xtn = 13172, | 237 ssl_next_proto_nego_xtn = 13172, |
238 ssl_channel_id_xtn = 30031, | 238 ssl_channel_id_xtn = 30032, |
239 ssl_renegotiation_info_xtn = 0xff01 /* experimental number */ | 239 ssl_renegotiation_info_xtn = 0xff01 /* experimental number */ |
240 } SSLExtensionType; | 240 } SSLExtensionType; |
241 | 241 |
242 -#define SSL_MAX_EXTENSIONS 10 | 242 -#define SSL_MAX_EXTENSIONS 10 |
243 +#define SSL_MAX_EXTENSIONS 11 | 243 +#define SSL_MAX_EXTENSIONS 11 |
244 | 244 |
245 #endif /* __sslt_h_ */ | 245 #endif /* __sslt_h_ */ |
OLD | NEW |