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

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

Issue 7327029: Add client-side support for the origin bound certificate TLS extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
« no previous file with comments | « net/third_party/nss/ssl/ssl.h ('k') | net/third_party/nss/ssl/sslimpl.h » ('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 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * 6 *
7 * The contents of this file are subject to the Mozilla Public License Version 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 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 9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/ 10 * http://www.mozilla.org/MPL/
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 /* These two tables are used by the client, to handle server hello 242 /* These two tables are used by the client, to handle server hello
243 * extensions. */ 243 * extensions. */
244 static const ssl3HelloExtensionHandler serverHelloHandlersTLS[] = { 244 static const ssl3HelloExtensionHandler serverHelloHandlersTLS[] = {
245 { ssl_server_name_xtn, &ssl3_HandleServerNameXtn }, 245 { ssl_server_name_xtn, &ssl3_HandleServerNameXtn },
246 /* TODO: add a handler for ssl_ec_point_formats_xtn */ 246 /* TODO: add a handler for ssl_ec_point_formats_xtn */
247 { ssl_session_ticket_xtn, &ssl3_ClientHandleSessionTicketXtn }, 247 { ssl_session_ticket_xtn, &ssl3_ClientHandleSessionTicketXtn },
248 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn }, 248 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn },
249 { ssl_next_proto_neg_xtn, &ssl3_ClientHandleNextProtoNegoXtn }, 249 { ssl_next_proto_neg_xtn, &ssl3_ClientHandleNextProtoNegoXtn },
250 { ssl_cached_info_xtn, &ssl3_ClientHandleCachedInfoXtn }, 250 { ssl_cached_info_xtn, &ssl3_ClientHandleCachedInfoXtn },
251 { ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn }, 251 { ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn },
252 { ssl_ob_cert_xtn, &ssl3_ClientHandleOBCertXtn },
252 { -1, NULL } 253 { -1, NULL }
253 }; 254 };
254 255
255 static const ssl3HelloExtensionHandler serverHelloHandlersSSL3[] = { 256 static const ssl3HelloExtensionHandler serverHelloHandlersSSL3[] = {
256 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn }, 257 { ssl_renegotiation_info_xtn, &ssl3_HandleRenegotiationInfoXtn },
257 { -1, NULL } 258 { -1, NULL }
258 }; 259 };
259 260
260 /* Tables of functions to format TLS hello extensions, one function per 261 /* Tables of functions to format TLS hello extensions, one function per
261 * extension. 262 * extension.
262 * These static tables are for the formatting of client hello extensions. 263 * These static tables are for the formatting of client hello extensions.
263 * The server's table of hello senders is dynamic, in the socket struct, 264 * The server's table of hello senders is dynamic, in the socket struct,
264 * and sender functions are registered there. 265 * and sender functions are registered there.
265 */ 266 */
266 static const 267 static const
267 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = { 268 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = {
268 { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, 269 { ssl_server_name_xtn, &ssl3_SendServerNameXtn },
269 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, 270 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn },
270 #ifdef NSS_ENABLE_ECC 271 #ifdef NSS_ENABLE_ECC
271 { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, 272 { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn },
272 { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, 273 { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn },
273 #endif 274 #endif
274 { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, 275 { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn },
275 { ssl_next_proto_neg_xtn, &ssl3_ClientSendNextProtoNegoXtn }, 276 { ssl_next_proto_neg_xtn, &ssl3_ClientSendNextProtoNegoXtn },
276 { ssl_cached_info_xtn, &ssl3_ClientSendCachedInfoXtn }, 277 { ssl_cached_info_xtn, &ssl3_ClientSendCachedInfoXtn },
277 { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn } 278 { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn },
279 { ssl_ob_cert_xtn, &ssl3_SendOBCertXtn }
278 /* any extra entries will appear as { 0, NULL } */ 280 /* any extra entries will appear as { 0, NULL } */
279 }; 281 };
280 282
281 static const 283 static const
282 ssl3HelloExtensionSender clientHelloSendersSSL3[SSL_MAX_EXTENSIONS] = { 284 ssl3HelloExtensionSender clientHelloSendersSSL3[SSL_MAX_EXTENSIONS] = {
283 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn } 285 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }
284 /* any extra entries will appear as { 0, NULL } */ 286 /* any extra entries will appear as { 0, NULL } */
285 }; 287 };
286 288
287 static PRBool 289 static PRBool
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 ss->peerRequestedProtection = 1; 1862 ss->peerRequestedProtection = 1;
1861 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type; 1863 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type;
1862 if (ss->sec.isServer) { 1864 if (ss->sec.isServer) {
1863 /* prepare to send back the appropriate response */ 1865 /* prepare to send back the appropriate response */
1864 rv = ssl3_RegisterServerHelloExtensionSender(ss, ex_type, 1866 rv = ssl3_RegisterServerHelloExtensionSender(ss, ex_type,
1865 ssl3_SendRenegotiationInfoXtn); 1867 ssl3_SendRenegotiationInfoXtn);
1866 } 1868 }
1867 return rv; 1869 return rv;
1868 } 1870 }
1869 1871
1872 /* This sender is used by both the client and server. */
1873 PRInt32
1874 ssl3_SendOBCertXtn(sslSocket * ss, PRBool append,
1875 PRUint32 maxBytes)
1876 {
1877 SECStatus rv;
1878 PRUint32 extension_length;
1879
1880 if (!ss)
1881 return 0;
1882
1883 if (!ss->opt.enableOBCerts)
1884 return 0;
1885
1886 /* extension length = extension_type (2-bytes) +
1887 * length(extension_data) (2-bytes) +
1888 */
1889
1890 extension_length = 4;
1891
1892 if (append && maxBytes >= extension_length) {
1893 /* extension_type */
1894 rv = ssl3_AppendHandshakeNumber(ss, ssl_ob_cert_xtn, 2);
1895 if (rv != SECSuccess) return -1;
1896 /* length of extension_data */
1897 rv = ssl3_AppendHandshakeNumber(ss, extension_length - 4, 2);
1898 if (rv != SECSuccess) return -1;
1899
1900 if (!ss->sec.isServer) {
1901 TLSExtensionData *xtnData = &ss->xtnData;
1902 xtnData->advertised[xtnData->numAdvertised++] = ssl_ob_cert_xtn;
1903 }
1904 }
1905
1906 return extension_length;
1907 }
1908
1909 SECStatus
1910 ssl3_ServerHandleOBCertXtn(sslSocket *ss, PRUint16 ex_type,
1911 SECItem *data)
1912 {
1913 SECStatus rv;
1914
1915 /* Ignore the OBCert extension if it is disabled. */
1916 if (!ss->opt.enableOBCerts)
1917 return SECSuccess;
1918
1919 /* The echoed extension must be empty. */
1920 if (data->len != 0)
1921 return SECFailure;
1922
1923 /* Keep track of negotiated extensions. */
1924 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type;
1925
1926 rv = ssl3_RegisterServerHelloExtensionSender(ss, ex_type,
1927 ssl3_SendOBCertXtn);
1928
1929 return SECSuccess;
1930 }
1931
1932 SECStatus
1933 ssl3_ClientHandleOBCertXtn(sslSocket *ss, PRUint16 ex_type,
1934 SECItem *data)
1935 {
1936 /* If we didn't request this extension, then the server may not echo it. */
1937 if (!ss->opt.enableOBCerts)
1938 return SECFailure;
1939
1940 /* The echoed extension must be empty. */
1941 if (data->len != 0)
1942 return SECFailure;
1943
1944 /* Keep track of negotiated extensions. */
1945 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type;
1946
1947 return SECSuccess;
1948 }
OLDNEW
« no previous file with comments | « net/third_party/nss/ssl/ssl.h ('k') | net/third_party/nss/ssl/sslimpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698