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

Side by Side Diff: net/quic/test_tools/crypto_test_utils.cc

Issue 17302002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/quic/reliable_quic_stream.cc ('k') | net/quic/test_tools/crypto_test_utils_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/test_tools/crypto_test_utils.h" 5 #include "net/quic/test_tools/crypto_test_utils.h"
6 6
7 #include "net/quic/crypto/common_cert_set.h" 7 #include "net/quic/crypto/common_cert_set.h"
8 #include "net/quic/crypto/crypto_handshake.h" 8 #include "net/quic/crypto/crypto_handshake.h"
9 #include "net/quic/crypto/crypto_server_config.h" 9 #include "net/quic/crypto/crypto_server_config.h"
10 #include "net/quic/crypto/quic_decrypter.h" 10 #include "net/quic/crypto/quic_decrypter.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 va_list ap) { 437 va_list ap) {
438 CryptoHandshakeMessage msg; 438 CryptoHandshakeMessage msg;
439 msg.set_tag(ParseTag(message_tag)); 439 msg.set_tag(ParseTag(message_tag));
440 440
441 for (;;) { 441 for (;;) {
442 const char* tagstr = va_arg(ap, const char*); 442 const char* tagstr = va_arg(ap, const char*);
443 if (tagstr == NULL) { 443 if (tagstr == NULL) {
444 break; 444 break;
445 } 445 }
446 446
447 if (tagstr[0] == '$') {
448 // Special value.
449 const char* const special = tagstr + 1;
450 if (strcmp(special, "padding") == 0) {
451 const int min_bytes = va_arg(ap, int);
452 msg.set_minimum_size(min_bytes);
453 } else {
454 CHECK(false) << "Unknown special value: " << special;
455 }
456
457 continue;
458 }
459
447 const QuicTag tag = ParseTag(tagstr); 460 const QuicTag tag = ParseTag(tagstr);
448 const char* valuestr = va_arg(ap, const char*); 461 const char* valuestr = va_arg(ap, const char*);
449 462
450 size_t len = strlen(valuestr); 463 size_t len = strlen(valuestr);
451 if (len > 0 && valuestr[0] == '#') { 464 if (len > 0 && valuestr[0] == '#') {
452 valuestr++; 465 valuestr++;
453 len--; 466 len--;
454 467
455 CHECK(len % 2 == 0); 468 CHECK(len % 2 == 0);
456 scoped_ptr<uint8[]> buf(new uint8[len/2]); 469 scoped_ptr<uint8[]> buf(new uint8[len/2]);
457 470
458 for (size_t i = 0; i < len/2; i++) { 471 for (size_t i = 0; i < len/2; i++) {
459 uint8 v = 0; 472 uint8 v = 0;
460 CHECK(HexChar(valuestr[i*2], &v)); 473 CHECK(HexChar(valuestr[i*2], &v));
461 buf[i] = v << 4; 474 buf[i] = v << 4;
462 CHECK(HexChar(valuestr[i*2 + 1], &v)); 475 CHECK(HexChar(valuestr[i*2 + 1], &v));
463 buf[i] |= v; 476 buf[i] |= v;
464 } 477 }
465 478
466 msg.SetStringPiece( 479 msg.SetStringPiece(
467 tag, StringPiece(reinterpret_cast<char*>(buf.get()), len/2)); 480 tag, StringPiece(reinterpret_cast<char*>(buf.get()), len/2));
468 continue; 481 continue;
469 } 482 }
470 483
471 msg.SetStringPiece(tag, valuestr); 484 msg.SetStringPiece(tag, valuestr);
472 } 485 }
473 486
474 return msg; 487 // The CryptoHandshakeMessage needs to be serialized and parsed to ensure
488 // that any padding is included.
489 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg));
490 scoped_ptr<CryptoHandshakeMessage> parsed(
491 CryptoFramer::ParseMessage(bytes->AsStringPiece()));
492 CHECK(parsed.get());
493
494 return *parsed;
475 } 495 }
476 496
477 } // namespace test 497 } // namespace test
478 } // namespace net 498 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream.cc ('k') | net/quic/test_tools/crypto_test_utils_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698