| OLD | NEW |
| (Empty) |
| 1 Index: mozilla/security/nss/lib/ssl/sslimpl.h | |
| 2 =================================================================== | |
| 3 RCS file: /cvsroot/mozilla/security/nss/lib/ssl/sslimpl.h,v | |
| 4 retrieving revision 1.106 | |
| 5 diff -u -p -r1.106 sslimpl.h | |
| 6 --- mozilla/security/nss/lib/ssl/sslimpl.h 14 Jun 2012 19:03:29 -0000
1.106 | |
| 7 +++ mozilla/security/nss/lib/ssl/sslimpl.h 17 Aug 2012 02:10:02 -0000 | |
| 8 @@ -251,6 +251,8 @@ struct sslSocketOpsStr { | |
| 9 #define ssl_SEND_FLAG_NO_BUFFER 0x20000000 | |
| 10 #define ssl_SEND_FLAG_USE_EPOCH 0x10000000 /* DTLS only */ | |
| 11 #define ssl_SEND_FLAG_NO_RETRANSMIT 0x08000000 /* DTLS only */ | |
| 12 +#define ssl_SEND_FLAG_CAP_RECORD_VERSION \ | |
| 13 + 0x04000000 /* TLS only */ | |
| 14 #define ssl_SEND_FLAG_MASK 0x7f000000 | |
| 15 | |
| 16 /* | |
| 17 @@ -1327,6 +1329,7 @@ extern SECStatus | |
| 18 ssl3_CompressMACEncryptRecord(ssl3CipherSpec * cwSpec, | |
| 19 PRBool isServer, | |
| 20 PRBool isDTLS, | |
| 21 + PRBool capRecordVersion, | |
| 22 SSL3ContentType type, | |
| 23 const SSL3Opaque * pIn, | |
| 24 PRUint32 contentLen, | |
| 25 Index: mozilla/security/nss/lib/ssl/ssl3con.c | |
| 26 =================================================================== | |
| 27 RCS file: /cvsroot/mozilla/security/nss/lib/ssl/ssl3con.c,v | |
| 28 retrieving revision 1.186 | |
| 29 diff -u -p -r1.186 ssl3con.c | |
| 30 --- mozilla/security/nss/lib/ssl/ssl3con.c 30 Jul 2012 00:47:36 -0000
1.186 | |
| 31 +++ mozilla/security/nss/lib/ssl/ssl3con.c 17 Aug 2012 02:10:02 -0000 | |
| 32 @@ -2060,6 +2060,7 @@ SECStatus | |
| 33 ssl3_CompressMACEncryptRecord(ssl3CipherSpec * cwSpec, | |
| 34 PRBool isServer, | |
| 35 PRBool isDTLS, | |
| 36 + PRBool capRecordVersion, | |
| 37 SSL3ContentType type, | |
| 38 const SSL3Opaque * pIn, | |
| 39 PRUint32 contentLen, | |
| 40 @@ -2219,8 +2220,13 @@ ssl3_CompressMACEncryptRecord(ssl3Cipher | |
| 41 wrBuf->buf[11] = MSB(cipherBytes); | |
| 42 wrBuf->buf[12] = LSB(cipherBytes); | |
| 43 } else { | |
| 44 - wrBuf->buf[1] = MSB(cwSpec->version); | |
| 45 - wrBuf->buf[2] = LSB(cwSpec->version); | |
| 46 + SSL3ProtocolVersion version = cwSpec->version; | |
| 47 + | |
| 48 + if (capRecordVersion) { | |
| 49 + version = PR_MIN(SSL_LIBRARY_VERSION_TLS_1_0, version); | |
| 50 + } | |
| 51 + wrBuf->buf[1] = MSB(version); | |
| 52 + wrBuf->buf[2] = LSB(version); | |
| 53 wrBuf->buf[3] = MSB(cipherBytes); | |
| 54 wrBuf->buf[4] = LSB(cipherBytes); | |
| 55 } | |
| 56 @@ -2250,7 +2256,14 @@ ssl3_CompressMACEncryptRecord(ssl3Cipher | |
| 57 * all ciphertext into the pending ciphertext buffer. | |
| 58 * ssl_SEND_FLAG_USE_EPOCH (for DTLS) | |
| 59 * Forces the use of the provided epoch | |
| 60 - * | |
| 61 + * ssl_SEND_FLAG_CAP_RECORD_VERSION | |
| 62 + * Caps the record layer version number of TLS ClientHello to { 3, 1 } | |
| 63 + * (TLS 1.0). Some TLS 1.0 servers (which seem to use F5 BIG-IP) ignore | |
| 64 + * ClientHello.client_version and use the record layer version number | |
| 65 + * (TLSPlaintext.version) instead when negotiating protocol versions. In | |
| 66 + * addition, if the record layer version number of ClientHello is { 3, 2 } | |
| 67 + * (TLS 1.1) or higher, these servers reset the TCP connections. Set this | |
| 68 + * flag to work around such servers. | |
| 69 */ | |
| 70 PRInt32 | |
| 71 ssl3_SendRecord( sslSocket * ss, | |
| 72 @@ -2263,6 +2276,7 @@ ssl3_SendRecord( sslSocket * ss | |
| 73 sslBuffer * wrBuf = &ss->sec.writeBuf; | |
| 74 SECStatus rv; | |
| 75 PRInt32 totalSent = 0; | |
| 76 + PRBool capRecordVersion; | |
| 77 | |
| 78 SSL_TRC(3, ("%d: SSL3[%d] SendRecord type: %s nIn=%d", | |
| 79 SSL_GETPID(), ss->fd, ssl3_DecodeContentType(type), | |
| 80 @@ -2271,6 +2285,17 @@ ssl3_SendRecord( sslSocket * ss | |
| 81 | |
| 82 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) ); | |
| 83 | |
| 84 + capRecordVersion = ((flags & ssl_SEND_FLAG_CAP_RECORD_VERSION) != 0); | |
| 85 + | |
| 86 + if (capRecordVersion) { | |
| 87 + /* ssl_SEND_FLAG_CAP_RECORD_VERSION can only be used with the | |
| 88 + * TLS initial ClientHello. */ | |
| 89 + PORT_Assert(!IS_DTLS(ss)); | |
| 90 + PORT_Assert(!ss->firstHsDone); | |
| 91 + PORT_Assert(type == content_handshake); | |
| 92 + PORT_Assert(ss->ssl3.hs.ws == wait_server_hello); | |
| 93 + } | |
| 94 + | |
| 95 if (ss->ssl3.initialized == PR_FALSE) { | |
| 96 /* This can happen on a server if the very first incoming record | |
| 97 ** looks like a defective ssl3 record (e.g. too long), and we're | |
| 98 @@ -2327,7 +2352,8 @@ ssl3_SendRecord( sslSocket * ss | |
| 99 | |
| 100 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, | |
| 101 ss->sec.isServer, IS_DTLS(ss), | |
| 102 - type, pIn, 1, wrBuf); | |
| 103 + capRecordVersion, type, pIn, | |
| 104 + 1, wrBuf); | |
| 105 if (rv != SECSuccess) | |
| 106 goto spec_locked_loser; | |
| 107 | |
| 108 @@ -2340,7 +2366,8 @@ ssl3_SendRecord( sslSocket * ss | |
| 109 | |
| 110 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, | |
| 111 ss->sec.isServer, IS_DTLS(ss), | |
| 112 - type, pIn + 1, contentLen - 1, | |
| 113 + capRecordVersion, type, | |
| 114 + pIn + 1, contentLen - 1, | |
| 115 &secondRecord); | |
| 116 if (rv == SECSuccess) { | |
| 117 PRINT_BUF(50, (ss, "send (encrypted) record data [2/2]:", | |
| 118 @@ -2352,6 +2379,7 @@ ssl3_SendRecord( sslSocket * ss | |
| 119 rv = ssl3_CompressMACEncryptRecord(ss->ssl3.cwSpec, | |
| 120 ss->sec.isServer, | |
| 121 IS_DTLS(ss), | |
| 122 + capRecordVersion, | |
| 123 type, pIn, | |
| 124 contentLen, wrBuf); | |
| 125 } else { | |
| 126 @@ -2563,6 +2591,8 @@ ssl3_FlushHandshake(sslSocket *ss, PRInt | |
| 127 static SECStatus | |
| 128 ssl3_FlushHandshakeMessages(sslSocket *ss, PRInt32 flags) | |
| 129 { | |
| 130 + static const PRInt32 allowedFlags = ssl_SEND_FLAG_FORCE_INTO_BUFFER | | |
| 131 + ssl_SEND_FLAG_CAP_RECORD_VERSION; | |
| 132 PRInt32 rv = SECSuccess; | |
| 133 | |
| 134 PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); | |
| 135 @@ -2571,9 +2601,9 @@ ssl3_FlushHandshakeMessages(sslSocket *s | |
| 136 if (!ss->sec.ci.sendBuf.buf || !ss->sec.ci.sendBuf.len) | |
| 137 return rv; | |
| 138 | |
| 139 - /* only this flag is allowed */ | |
| 140 - PORT_Assert(!(flags & ~ssl_SEND_FLAG_FORCE_INTO_BUFFER)); | |
| 141 - if ((flags & ~ssl_SEND_FLAG_FORCE_INTO_BUFFER) != 0) { | |
| 142 + /* only these flags are allowed */ | |
| 143 + PORT_Assert(!(flags & ~allowedFlags)); | |
| 144 + if ((flags & ~allowedFlags) != 0) { | |
| 145 PORT_SetError(SEC_ERROR_INVALID_ARGS); | |
| 146 rv = SECFailure; | |
| 147 } else { | |
| 148 @@ -4000,8 +4030,10 @@ ssl3_SendClientHello(sslSocket *ss, PRBo | |
| 149 int num_suites; | |
| 150 int actual_count = 0; | |
| 151 PRBool isTLS = PR_FALSE; | |
| 152 + PRBool requestingResume = PR_FALSE; | |
| 153 PRInt32 total_exten_len = 0; | |
| 154 unsigned numCompressionMethods; | |
| 155 + PRInt32 flags; | |
| 156 | |
| 157 SSL_TRC(3, ("%d: SSL3[%d]: send client_hello handshake", SSL_GETPID(), | |
| 158 ss->fd)); | |
| 159 @@ -4090,6 +4122,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo | |
| 160 } | |
| 161 | |
| 162 if (sid) { | |
| 163 + requestingResume = PR_TRUE; | |
| 164 SSL_AtomicIncrementLong(& ssl3stats.sch_sid_cache_hits ); | |
| 165 | |
| 166 /* Are we attempting a stateless session resume? */ | |
| 167 @@ -4325,7 +4358,11 @@ ssl3_SendClientHello(sslSocket *ss, PRBo | |
| 168 ssl_renegotiation_info_xtn; | |
| 169 } | |
| 170 | |
| 171 - rv = ssl3_FlushHandshake(ss, 0); | |
| 172 + flags = 0; | |
| 173 + if (!ss->firstHsDone && !requestingResume && !IS_DTLS(ss)) { | |
| 174 + flags |= ssl_SEND_FLAG_CAP_RECORD_VERSION; | |
| 175 + } | |
| 176 + rv = ssl3_FlushHandshake(ss, flags); | |
| 177 if (rv != SECSuccess) { | |
| 178 return rv; /* error code set by ssl3_FlushHandshake */ | |
| 179 } | |
| 180 Index: mozilla/security/nss/lib/ssl/dtlscon.c | |
| 181 =================================================================== | |
| 182 RCS file: /cvsroot/mozilla/security/nss/lib/ssl/dtlscon.c,v | |
| 183 retrieving revision 1.3 | |
| 184 diff -u -p -r1.3 dtlscon.c | |
| 185 --- mozilla/security/nss/lib/ssl/dtlscon.c 4 Jul 2012 15:21:47 -0000
1.3 | |
| 186 +++ mozilla/security/nss/lib/ssl/dtlscon.c 17 Aug 2012 02:10:02 -0000 | |
| 187 @@ -802,7 +802,8 @@ dtls_CompressMACEncryptRecord(sslSocket | |
| 188 | |
| 189 if (cwSpec) { | |
| 190 rv = ssl3_CompressMACEncryptRecord(cwSpec, ss->sec.isServer, PR_TRUE, | |
| 191 - type, pIn, contentLen, wrBuf); | |
| 192 + PR_FALSE, type, pIn, contentLen, | |
| 193 + wrBuf); | |
| 194 } else { | |
| 195 PR_NOT_REACHED("Couldn't find a cipher spec matching epoch"); | |
| 196 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); | |
| OLD | NEW |