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

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

Issue 8393035: Revert 97269 - Send only one byte of data in the first CBC encrypted (Closed) Base URL: svn://svn.chromium.org/chrome/branches/874_102/src/
Patch Set: Created 9 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/patches/cbcrandomiv.patch ('k') | no next file » | 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 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 2314
2315 /* Attempt to send the content of "in" in an SSL application_data record. 2315 /* Attempt to send the content of "in" in an SSL application_data record.
2316 * Returns "len" or SECFailure, never SECWouldBlock, nor SECSuccess. 2316 * Returns "len" or SECFailure, never SECWouldBlock, nor SECSuccess.
2317 */ 2317 */
2318 int 2318 int
2319 ssl3_SendApplicationData(sslSocket *ss, const unsigned char *in, 2319 ssl3_SendApplicationData(sslSocket *ss, const unsigned char *in,
2320 PRInt32 len, PRInt32 flags) 2320 PRInt32 len, PRInt32 flags)
2321 { 2321 {
2322 PRInt32 totalSent = 0; 2322 PRInt32 totalSent = 0;
2323 PRInt32 discarded = 0; 2323 PRInt32 discarded = 0;
2324 PRBool isBlockCipher;
2325 int recordIndex;
2326 2324
2327 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) ); 2325 PORT_Assert( ss->opt.noLocks || ssl_HaveXmitBufLock(ss) );
2328 if (len < 0 || !in) { 2326 if (len < 0 || !in) {
2329 PORT_SetError(PR_INVALID_ARGUMENT_ERROR); 2327 PORT_SetError(PR_INVALID_ARGUMENT_ERROR);
2330 return SECFailure; 2328 return SECFailure;
2331 } 2329 }
2332 2330
2333 if (ss->pendingBuf.len > SSL3_PENDING_HIGH_WATER && 2331 if (ss->pendingBuf.len > SSL3_PENDING_HIGH_WATER &&
2334 !ssl_SocketIsBlocking(ss)) { 2332 !ssl_SocketIsBlocking(ss)) {
2335 PORT_Assert(!ssl_SocketIsBlocking(ss)); 2333 PORT_Assert(!ssl_SocketIsBlocking(ss));
2336 PORT_SetError(PR_WOULD_BLOCK_ERROR); 2334 PORT_SetError(PR_WOULD_BLOCK_ERROR);
2337 return SECFailure; 2335 return SECFailure;
2338 } 2336 }
2339 2337
2340 if (ss->appDataBuffered && len) { 2338 if (ss->appDataBuffered && len) {
2341 PORT_Assert (in[0] == (unsigned char)(ss->appDataBuffered)); 2339 PORT_Assert (in[0] == (unsigned char)(ss->appDataBuffered));
2342 if (in[0] != (unsigned char)(ss->appDataBuffered)) { 2340 if (in[0] != (unsigned char)(ss->appDataBuffered)) {
2343 PORT_SetError(PR_INVALID_ARGUMENT_ERROR); 2341 PORT_SetError(PR_INVALID_ARGUMENT_ERROR);
2344 return SECFailure; 2342 return SECFailure;
2345 } 2343 }
2346 in++; 2344 in++;
2347 len--; 2345 len--;
2348 discarded = 1; 2346 discarded = 1;
2349 } 2347 }
2350 2348 while (len > totalSent) {
2351 ssl_GetSpecReadLock(ss);
2352 isBlockCipher = ss->ssl3.cwSpec->cipher_def->type == type_block;
2353 ssl_ReleaseSpecReadLock(ss);
2354
2355 for (recordIndex = 0; len > totalSent; recordIndex++) {
2356 PRInt32 sent, toSend; 2349 PRInt32 sent, toSend;
2357 2350
2358 if (totalSent > 0) { 2351 if (totalSent > 0) {
2359 /* 2352 /*
2360 * The thread yield is intended to give the reader thread a 2353 * The thread yield is intended to give the reader thread a
2361 * chance to get some cycles while the writer thread is in 2354 * chance to get some cycles while the writer thread is in
2362 * the middle of a large application data write. (See 2355 * the middle of a large application data write. (See
2363 * Bugzilla bug 127740, comment #1.) 2356 * Bugzilla bug 127740, comment #1.)
2364 */ 2357 */
2365 ssl_ReleaseXmitBufLock(ss); 2358 ssl_ReleaseXmitBufLock(ss);
2366 PR_Sleep(PR_INTERVAL_NO_WAIT); /* PR_Yield(); */ 2359 PR_Sleep(PR_INTERVAL_NO_WAIT); /* PR_Yield(); */
2367 ssl_GetXmitBufLock(ss); 2360 ssl_GetXmitBufLock(ss);
2368 } 2361 }
2369 toSend = PR_MIN(len - totalSent, MAX_FRAGMENT_LENGTH); 2362 toSend = PR_MIN(len - totalSent, MAX_FRAGMENT_LENGTH);
2370 if (isBlockCipher &&
2371 ss->ssl3.cwSpec->version <= SSL_LIBRARY_VERSION_3_1_TLS) {
2372 /*
2373 * We assume that block ciphers are used in CBC mode and send
2374 * only one byte in the first record. This effectively
2375 * randomizes the IV in a backward compatible way.
2376 *
2377 * We get back to the MAX_FRAGMENT_LENGTH record boundary in
2378 * the second record. So for a large amount of data, we send
2379 * 1
2380 * MAX_FRAGMENT_LENGTH - 1
2381 * MAX_FRAGMENT_LENGTH
2382 * MAX_FRAGMENT_LENGTH
2383 * ...
2384 */
2385 if (recordIndex == 0) {
2386 toSend = 1;
2387 } else if (recordIndex == 1 &&
2388 len - totalSent > MAX_FRAGMENT_LENGTH) {
2389 toSend--;
2390 }
2391 }
2392 sent = ssl3_SendRecord(ss, content_application_data, 2363 sent = ssl3_SendRecord(ss, content_application_data,
2393 in + totalSent, toSend, flags); 2364 in + totalSent, toSend, flags);
2394 if (sent < 0) { 2365 if (sent < 0) {
2395 if (totalSent > 0 && PR_GetError() == PR_WOULD_BLOCK_ERROR) { 2366 if (totalSent > 0 && PR_GetError() == PR_WOULD_BLOCK_ERROR) {
2396 PORT_Assert(ss->lastWriteBlocked); 2367 PORT_Assert(ss->lastWriteBlocked);
2397 break; 2368 break;
2398 } 2369 }
2399 return SECFailure; /* error code set by ssl3_SendRecord */ 2370 return SECFailure; /* error code set by ssl3_SendRecord */
2400 } 2371 }
2401 totalSent += sent; 2372 totalSent += sent;
(...skipping 7579 matching lines...) Expand 10 before | Expand all | Expand 10 after
9981 9952
9982 ss->ssl3.initialized = PR_FALSE; 9953 ss->ssl3.initialized = PR_FALSE;
9983 9954
9984 if (ss->ssl3.nextProto.data) { 9955 if (ss->ssl3.nextProto.data) {
9985 PORT_Free(ss->ssl3.nextProto.data); 9956 PORT_Free(ss->ssl3.nextProto.data);
9986 ss->ssl3.nextProto.data = NULL; 9957 ss->ssl3.nextProto.data = NULL;
9987 } 9958 }
9988 } 9959 }
9989 9960
9990 /* End of ssl3con.c */ 9961 /* End of ssl3con.c */
OLDNEW
« no previous file with comments | « net/third_party/nss/patches/cbcrandomiv.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698