| Index: net/third_party/nss/patches/signedcertificatetimestamps.patch
|
| diff --git a/net/third_party/nss/patches/signedcertificatetimestamps.patch b/net/third_party/nss/patches/signedcertificatetimestamps.patch
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1524958124f6b966ce4aff66207973de56bd494d
|
| --- /dev/null
|
| +++ b/net/third_party/nss/patches/signedcertificatetimestamps.patch
|
| @@ -0,0 +1,377 @@
|
| +diff --git a/net/third_party/nss/ssl/ssl.h b/net/third_party/nss/ssl/ssl.h
|
| +index 47468a0..dac483a 100644
|
| +--- a/net/third_party/nss/ssl/ssl.h
|
| ++++ b/net/third_party/nss/ssl/ssl.h
|
| +@@ -166,6 +166,8 @@ SSL_IMPORT PRFileDesc *DTLS_ImportFD(PRFileDesc *model, PRFileDesc *fd);
|
| + */
|
| + #define SSL_CBC_RANDOM_IV 23
|
| + #define SSL_ENABLE_OCSP_STAPLING 24 /* Request OCSP stapling (client) */
|
| ++/* Request Signed Certificate Timestamps via TLS extension (client) */
|
| ++#define SSL_ENABLE_SIGNED_CERT_TIMESTAMPS 25
|
| +
|
| + #ifdef SSL_DEPRECATED_FUNCTION
|
| + /* Old deprecated function names */
|
| +@@ -469,6 +471,21 @@ SSL_IMPORT CERTCertList *SSL_PeerCertificateChain(PRFileDesc *fd);
|
| + */
|
| + SSL_IMPORT const SECItemArray * SSL_PeerStapledOCSPResponses(PRFileDesc *fd);
|
| +
|
| ++/* SSL_PeerSignedCertTimestamps returns the signed_certificate_timestamp
|
| ++ * extension data provided by the TLS server. The return value is a pointer
|
| ++ * to an internal SECItem that contains the returned response; it is only valid
|
| ++ * until the callback function that calls SSL_PeerSignedCertTimestamps returns.
|
| ++ *
|
| ++ * If no Signed Certificate Timestamps were given by the server then the result
|
| ++ * will be empty. If there was an error, then the result will be NULL.
|
| ++ *
|
| ++ * You must set the SSL_ENABLE_SIGNED_CERT_TIMESTAMPS option to enable Signed
|
| ++ * Certificate Timestamps to be provided by a server.
|
| ++ *
|
| ++ * libssl does not do any parsing or validation of the response itself.
|
| ++ */
|
| ++SSL_IMPORT const SECItem * SSL_PeerSignedCertTimestamps(PRFileDesc *fd);
|
| ++
|
| + /* SSL_SetStapledOCSPResponses stores an array of one or multiple OCSP responses
|
| + * in the fd's data, which may be sent as part of a server side cert_status
|
| + * handshake message. Parameter |responses| is for the server certificate of
|
| +diff --git a/net/third_party/nss/ssl/ssl3con.c b/net/third_party/nss/ssl/ssl3con.c
|
| +index 7b93a63..ceb31bc 100644
|
| +--- a/net/third_party/nss/ssl/ssl3con.c
|
| ++++ b/net/third_party/nss/ssl/ssl3con.c
|
| +@@ -6612,6 +6612,18 @@ ssl3_HandleServerHello(sslSocket *ss, SSL3Opaque *b, PRUint32 length)
|
| + sid->u.ssl3.sessionIDLength = sidBytes.len;
|
| + PORT_Memcpy(sid->u.ssl3.sessionID, sidBytes.data, sidBytes.len);
|
| +
|
| ++ /* Copy Signed Certificate Timestamps, if any. */
|
| ++ if (ss->xtnData.signedCertTimestamps.data) {
|
| ++ rv = SECITEM_CopyItem(NULL, &sid->u.ssl3.signedCertTimestamps,
|
| ++ &ss->xtnData.signedCertTimestamps);
|
| ++ if (rv != SECSuccess)
|
| ++ goto loser;
|
| ++ }
|
| ++
|
| ++ /* Clean up the temporary pointer to the handshake buffer. */
|
| ++ ss->xtnData.signedCertTimestamps.data = NULL;
|
| ++ ss->xtnData.signedCertTimestamps.len = 0;
|
| ++
|
| + ss->ssl3.hs.isResuming = PR_FALSE;
|
| + ss->ssl3.hs.ws = wait_server_cert;
|
| +
|
| +@@ -6641,6 +6653,9 @@ alert_loser:
|
| + (void)SSL3_SendAlert(ss, alert_fatal, desc);
|
| +
|
| + loser:
|
| ++ /* Clean up the temporary pointer to the handshake buffer. */
|
| ++ ss->xtnData.signedCertTimestamps.data = NULL;
|
| ++ ss->xtnData.signedCertTimestamps.len = 0;
|
| + errCode = ssl_MapLowLevelError(errCode);
|
| + return SECFailure;
|
| + }
|
| +diff --git a/net/third_party/nss/ssl/ssl3ext.c b/net/third_party/nss/ssl/ssl3ext.c
|
| +index 0415770..4b51451 100644
|
| +--- a/net/third_party/nss/ssl/ssl3ext.c
|
| ++++ b/net/third_party/nss/ssl/ssl3ext.c
|
| +@@ -81,6 +81,12 @@ static PRInt32 ssl3_ClientSendSigAlgsXtn(sslSocket *ss, PRBool append,
|
| + PRUint32 maxBytes);
|
| + static SECStatus ssl3_ServerHandleSigAlgsXtn(sslSocket *ss, PRUint16 ex_type,
|
| + SECItem *data);
|
| ++static PRInt32 ssl3_ClientSendSignedCertTimestampXtn(sslSocket *ss,
|
| ++ PRBool append,
|
| ++ PRUint32 maxBytes);
|
| ++static SECStatus ssl3_ClientHandleSignedCertTimestampXtn(sslSocket *ss,
|
| ++ PRUint16 ex_type,
|
| ++ SECItem *data);
|
| +
|
| + /*
|
| + * Write bytes. Using this function means the SECItem structure
|
| +@@ -259,6 +265,8 @@ static const ssl3HelloExtensionHandler serverHelloHandlersTLS[] = {
|
| + { ssl_use_srtp_xtn, &ssl3_HandleUseSRTPXtn },
|
| + { ssl_channel_id_xtn, &ssl3_ClientHandleChannelIDXtn },
|
| + { ssl_cert_status_xtn, &ssl3_ClientHandleStatusRequestXtn },
|
| ++ { ssl_signed_certificate_timestamp_xtn,
|
| ++ &ssl3_ClientHandleSignedCertTimestampXtn },
|
| + { -1, NULL }
|
| + };
|
| +
|
| +@@ -287,7 +295,9 @@ ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = {
|
| + { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn },
|
| + { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn },
|
| + { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn },
|
| +- { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn }
|
| ++ { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn },
|
| ++ { ssl_signed_certificate_timestamp_xtn,
|
| ++ &ssl3_ClientSendSignedCertTimestampXtn },
|
| + /* any extra entries will appear as { 0, NULL } */
|
| + };
|
| +
|
| +@@ -2297,3 +2307,60 @@ ssl3_ClientSendSigAlgsXtn(sslSocket * ss, PRBool append, PRUint32 maxBytes)
|
| + loser:
|
| + return -1;
|
| + }
|
| ++
|
| ++/* ssl3_ClientSendSignedCertTimestampXtn sends the signed_certificate_timestamp
|
| ++ * extension for TLS ClientHellos. */
|
| ++static PRInt32
|
| ++ssl3_ClientSendSignedCertTimestampXtn(sslSocket *ss, PRBool append,
|
| ++ PRUint32 maxBytes)
|
| ++{
|
| ++ /* Only send the extension if processing is enabled. */
|
| ++ if (!ss->opt.enableSignedCertTimestamps)
|
| ++ return 0;
|
| ++
|
| ++ PRInt32 extension_length = 2 /* extension_type */ +
|
| ++ 2 /* length(extension_data) */;
|
| ++
|
| ++ if (append && maxBytes >= extension_length) {
|
| ++ SECStatus rv;
|
| ++ /* extension_type */
|
| ++ rv = ssl3_AppendHandshakeNumber(ss,
|
| ++ ssl_signed_certificate_timestamp_xtn,
|
| ++ 2);
|
| ++ if (rv != SECSuccess)
|
| ++ goto loser;
|
| ++ /* zero length */
|
| ++ rv = ssl3_AppendHandshakeNumber(ss, 0, 2);
|
| ++ if (rv != SECSuccess)
|
| ++ goto loser;
|
| ++ ss->xtnData.advertised[ss->xtnData.numAdvertised++] =
|
| ++ ssl_signed_certificate_timestamp_xtn;
|
| ++ } else if (maxBytes < extension_length) {
|
| ++ PORT_Assert(0);
|
| ++ return 0;
|
| ++ }
|
| ++
|
| ++ return extension_length;
|
| ++loser:
|
| ++ return -1;
|
| ++}
|
| ++
|
| ++static SECStatus
|
| ++ssl3_ClientHandleSignedCertTimestampXtn(sslSocket *ss, PRUint16 ex_type,
|
| ++ SECItem *data)
|
| ++{
|
| ++ /* We do not yet know whether we'll be reusing a session or creating
|
| ++ * a new one, so we keep a pointer to the data in the TLSExtensionData
|
| ++ * structure. This pointer is only valid in the scope of
|
| ++ * ssl3_HandleServerHello, and, if not resuming a session, a copy of the
|
| ++ * data is made once a new session has been set up.
|
| ++ * All parsing is currently left to the application and we accept
|
| ++ * everything, including empty data.
|
| ++ */
|
| ++ SECItem *scts = &ss->xtnData.signedCertTimestamps;
|
| ++ PORT_Assert(!scts->data && !scts->len);
|
| ++ *scts = *data;
|
| ++ /* Keep track of negotiated extensions. */
|
| ++ ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type;
|
| ++ return SECSuccess;
|
| ++}
|
| +diff --git a/net/third_party/nss/ssl/sslimpl.h b/net/third_party/nss/ssl/sslimpl.h
|
| +index 614eed1..c17cc23 100644
|
| +--- a/net/third_party/nss/ssl/sslimpl.h
|
| ++++ b/net/third_party/nss/ssl/sslimpl.h
|
| +@@ -305,29 +305,30 @@ typedef struct sslOptionsStr {
|
| + * list of supported protocols. */
|
| + SECItem nextProtoNego;
|
| +
|
| +- unsigned int useSecurity : 1; /* 1 */
|
| +- unsigned int useSocks : 1; /* 2 */
|
| +- unsigned int requestCertificate : 1; /* 3 */
|
| +- unsigned int requireCertificate : 2; /* 4-5 */
|
| +- unsigned int handshakeAsClient : 1; /* 6 */
|
| +- unsigned int handshakeAsServer : 1; /* 7 */
|
| +- unsigned int enableSSL2 : 1; /* 8 */
|
| +- unsigned int unusedBit9 : 1; /* 9 */
|
| +- unsigned int unusedBit10 : 1; /* 10 */
|
| +- unsigned int noCache : 1; /* 11 */
|
| +- unsigned int fdx : 1; /* 12 */
|
| +- unsigned int v2CompatibleHello : 1; /* 13 */
|
| +- unsigned int detectRollBack : 1; /* 14 */
|
| +- unsigned int noStepDown : 1; /* 15 */
|
| +- unsigned int bypassPKCS11 : 1; /* 16 */
|
| +- unsigned int noLocks : 1; /* 17 */
|
| +- unsigned int enableSessionTickets : 1; /* 18 */
|
| +- unsigned int enableDeflate : 1; /* 19 */
|
| +- unsigned int enableRenegotiation : 2; /* 20-21 */
|
| +- unsigned int requireSafeNegotiation : 1; /* 22 */
|
| +- unsigned int enableFalseStart : 1; /* 23 */
|
| +- unsigned int cbcRandomIV : 1; /* 24 */
|
| +- unsigned int enableOCSPStapling : 1; /* 25 */
|
| ++ unsigned int useSecurity : 1; /* 1 */
|
| ++ unsigned int useSocks : 1; /* 2 */
|
| ++ unsigned int requestCertificate : 1; /* 3 */
|
| ++ unsigned int requireCertificate : 2; /* 4-5 */
|
| ++ unsigned int handshakeAsClient : 1; /* 6 */
|
| ++ unsigned int handshakeAsServer : 1; /* 7 */
|
| ++ unsigned int enableSSL2 : 1; /* 8 */
|
| ++ unsigned int unusedBit9 : 1; /* 9 */
|
| ++ unsigned int unusedBit10 : 1; /* 10 */
|
| ++ unsigned int noCache : 1; /* 11 */
|
| ++ unsigned int fdx : 1; /* 12 */
|
| ++ unsigned int v2CompatibleHello : 1; /* 13 */
|
| ++ unsigned int detectRollBack : 1; /* 14 */
|
| ++ unsigned int noStepDown : 1; /* 15 */
|
| ++ unsigned int bypassPKCS11 : 1; /* 16 */
|
| ++ unsigned int noLocks : 1; /* 17 */
|
| ++ unsigned int enableSessionTickets : 1; /* 18 */
|
| ++ unsigned int enableDeflate : 1; /* 19 */
|
| ++ unsigned int enableRenegotiation : 2; /* 20-21 */
|
| ++ unsigned int requireSafeNegotiation : 1; /* 22 */
|
| ++ unsigned int enableFalseStart : 1; /* 23 */
|
| ++ unsigned int cbcRandomIV : 1; /* 24 */
|
| ++ unsigned int enableOCSPStapling : 1; /* 25 */
|
| ++ unsigned int enableSignedCertTimestamps : 1; /* 26 */
|
| + } sslOptions;
|
| +
|
| + typedef enum { sslHandshakingUndetermined = 0,
|
| +@@ -698,6 +699,10 @@ struct sslSessionIDStr {
|
| + */
|
| + NewSessionTicket sessionTicket;
|
| + SECItem srvName;
|
| ++ /* Signed certificate timestamps received in a TLS extension.
|
| ++ ** (used only in client).
|
| ++ */
|
| ++ SECItem signedCertTimestamps;
|
| + } ssl3;
|
| + } u;
|
| + };
|
| +@@ -789,6 +794,15 @@ struct TLSExtensionDataStr {
|
| + * is beyond ssl3_HandleClientHello function. */
|
| + SECItem *sniNameArr;
|
| + PRUint32 sniNameArrSize;
|
| ++ /* Signed Certificate Timestamps extracted from the TLS extension.
|
| ++ * (client only).
|
| ++ * This container holds a temporary pointer to the extension data,
|
| ++ * until a session is setup that can hold a permanent copy of the data.
|
| ++ * The data pointed to by this structure is neither explicitly allocated
|
| ++ * nor copied: the pointer points to the handshake message buffer and is
|
| ++ * only valid in the scope of ssl3_HandleServerHello.
|
| ++ */
|
| ++ SECItem signedCertTimestamps;
|
| + };
|
| +
|
| + typedef SECStatus (*sslRestartTarget)(sslSocket *);
|
| +diff --git a/net/third_party/nss/ssl/sslnonce.c b/net/third_party/nss/ssl/sslnonce.c
|
| +index a6f7349..6d330f0 100644
|
| +--- a/net/third_party/nss/ssl/sslnonce.c
|
| ++++ b/net/third_party/nss/ssl/sslnonce.c
|
| +@@ -142,13 +142,19 @@ ssl_DestroySID(sslSessionID *sid)
|
| + if ( sid->localCert ) {
|
| + CERT_DestroyCertificate(sid->localCert);
|
| + }
|
| +- if (sid->u.ssl3.sessionTicket.ticket.data) {
|
| +- SECITEM_FreeItem(&sid->u.ssl3.sessionTicket.ticket, PR_FALSE);
|
| +- }
|
| +- if (sid->u.ssl3.srvName.data) {
|
| +- SECITEM_FreeItem(&sid->u.ssl3.srvName, PR_FALSE);
|
| ++
|
| ++ if (sid->version >= SSL_LIBRARY_VERSION_3_0) {
|
| ++ if (sid->u.ssl3.sessionTicket.ticket.data) {
|
| ++ SECITEM_FreeItem(&sid->u.ssl3.sessionTicket.ticket, PR_FALSE);
|
| ++ }
|
| ++ if (sid->u.ssl3.srvName.data) {
|
| ++ SECITEM_FreeItem(&sid->u.ssl3.srvName, PR_FALSE);
|
| ++ }
|
| ++ if (sid->u.ssl3.signedCertTimestamps.data) {
|
| ++ SECITEM_FreeItem(&sid->u.ssl3.signedCertTimestamps, PR_FALSE);
|
| ++ }
|
| + }
|
| +-
|
| ++
|
| + PORT_ZFree(sid, sizeof(sslSessionID));
|
| + }
|
| +
|
| +diff --git a/net/third_party/nss/ssl/sslsock.c b/net/third_party/nss/ssl/sslsock.c
|
| +index 072fad5..8072f23 100644
|
| +--- a/net/third_party/nss/ssl/sslsock.c
|
| ++++ b/net/third_party/nss/ssl/sslsock.c
|
| +@@ -173,7 +173,8 @@ static sslOptions ssl_defaults = {
|
| + PR_FALSE, /* requireSafeNegotiation */
|
| + PR_FALSE, /* enableFalseStart */
|
| + PR_TRUE, /* cbcRandomIV */
|
| +- PR_FALSE /* enableOCSPStapling */
|
| ++ PR_FALSE, /* enableOCSPStapling */
|
| ++ PR_FALSE /* enableSignedCertTimestamps */
|
| + };
|
| +
|
| + /*
|
| +@@ -863,6 +864,10 @@ SSL_OptionSet(PRFileDesc *fd, PRInt32 which, PRBool on)
|
| + ss->opt.enableOCSPStapling = on;
|
| + break;
|
| +
|
| ++ case SSL_ENABLE_SIGNED_CERT_TIMESTAMPS:
|
| ++ ss->opt.enableSignedCertTimestamps = on;
|
| ++ break;
|
| ++
|
| + default:
|
| + PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
| + rv = SECFailure;
|
| +@@ -933,6 +938,9 @@ SSL_OptionGet(PRFileDesc *fd, PRInt32 which, PRBool *pOn)
|
| + case SSL_ENABLE_FALSE_START: on = ss->opt.enableFalseStart; break;
|
| + case SSL_CBC_RANDOM_IV: on = ss->opt.cbcRandomIV; break;
|
| + case SSL_ENABLE_OCSP_STAPLING: on = ss->opt.enableOCSPStapling; break;
|
| ++ case SSL_ENABLE_SIGNED_CERT_TIMESTAMPS:
|
| ++ on = ss->opt.enableSignedCertTimestamps;
|
| ++ break;
|
| +
|
| + default:
|
| + PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
| +@@ -994,6 +1002,9 @@ SSL_OptionGetDefault(PRInt32 which, PRBool *pOn)
|
| + case SSL_ENABLE_OCSP_STAPLING:
|
| + on = ssl_defaults.enableOCSPStapling;
|
| + break;
|
| ++ case SSL_ENABLE_SIGNED_CERT_TIMESTAMPS:
|
| ++ ssl_defaults.enableSignedCertTimestamps = on;
|
| ++ break;
|
| +
|
| + default:
|
| + PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
| +@@ -1991,6 +2002,28 @@ SSL_PeerStapledOCSPResponses(PRFileDesc *fd)
|
| + return &ss->sec.ci.sid->peerCertStatus;
|
| + }
|
| +
|
| ++const SECItem *
|
| ++SSL_PeerSignedCertTimestamps(PRFileDesc *fd)
|
| ++{
|
| ++ sslSocket *ss = ssl_FindSocket(fd);
|
| ++
|
| ++ if (!ss) {
|
| ++ SSL_DBG(("%d: SSL[%d]: bad socket in SSL_PeerSignedCertTimestamps",
|
| ++ SSL_GETPID(), fd));
|
| ++ return NULL;
|
| ++ }
|
| ++
|
| ++ if (!ss->sec.ci.sid) {
|
| ++ PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
|
| ++ return NULL;
|
| ++ }
|
| ++
|
| ++ if (ss->version < SSL_LIBRARY_VERSION_3_0) {
|
| ++ return NULL;
|
| ++ }
|
| ++ return &ss->sec.ci.sid->u.ssl3.signedCertTimestamps;
|
| ++}
|
| ++
|
| + SECStatus
|
| + SSL_HandshakeResumedSession(PRFileDesc *fd, PRBool *handshake_resumed) {
|
| + sslSocket *ss = ssl_FindSocket(fd);
|
| +@@ -3131,4 +3164,3 @@ loser:
|
| + }
|
| + return ss;
|
| + }
|
| +-
|
| +diff --git a/net/third_party/nss/ssl/sslt.h b/net/third_party/nss/ssl/sslt.h
|
| +index a8007d8..ef77f21 100644
|
| +--- a/net/third_party/nss/ssl/sslt.h
|
| ++++ b/net/third_party/nss/ssl/sslt.h
|
| +@@ -205,9 +205,10 @@ typedef enum {
|
| + ssl_session_ticket_xtn = 35,
|
| + ssl_next_proto_nego_xtn = 13172,
|
| + ssl_channel_id_xtn = 30031,
|
| +- ssl_renegotiation_info_xtn = 0xff01 /* experimental number */
|
| ++ ssl_renegotiation_info_xtn = 0xff01, /* experimental number */
|
| ++ ssl_signed_certificate_timestamp_xtn = 18 /* RFC 6962 */
|
| + } SSLExtensionType;
|
| +
|
| +-#define SSL_MAX_EXTENSIONS 11
|
| ++#define SSL_MAX_EXTENSIONS 12
|
| +
|
| + #endif /* __sslt_h_ */
|
|
|