summaryrefslogtreecommitdiffstats
path: root/net/quic/crypto/crypto_server_test.cc
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-27 03:40:44 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-27 03:40:44 +0000
commit2cfc6bb8891f4eaac2146c97fe562ca698a9883c (patch)
tree064ab3652329edc1a33845aa58c0aef2f8322a7b /net/quic/crypto/crypto_server_test.cc
parenta9f5730af67a9838ea3e68efa5beb54f861f02cb (diff)
downloadchromium_src-2cfc6bb8891f4eaac2146c97fe562ca698a9883c.zip
chromium_src-2cfc6bb8891f4eaac2146c97fe562ca698a9883c.tar.gz
chromium_src-2cfc6bb8891f4eaac2146c97fe562ca698a9883c.tar.bz2
Land Recent QUIC changes.
Rename ambiquious ConnectionClose method to OnConnectionClosed. Merge internal change: 54774694 Change TCP cubic's max packet size used to calculate the initial and subsequent congestion window in bytes to the default of 1460 from QUIC's artificially low 1200. Merge internal change: 54772582 QUIC: make the SCID a hash of the rest of the server config. We need to ensure that the SCID changes whenever the rest of the server config does. For example, cl/54004815 changed the server config, but not the SCID. This could lead to bad 0-RTT handshakes where the server believes the handshake is good, but will derive different keys than the client. The easiest change to ensure that the SCID is changed is to make it a hash of the rest of the message. Merge internal change: 54659325 EndToEndTest to fix TSAN. Merge internal change: 54090381 Don't add a zero-length public key to kPUBS if P-256 support is disabled. kKEXS and kPUBS should have the same number of elements. Merge internal change: 54004815 Make the QuicConnectionHelper no longer owned by the QuicConnection. Instead a single helper is owned by the Dispatcher or Client, and shared among each Connection. Merge internal change: 53974968 R=rch@chromium.org Review URL: https://codereview.chromium.org/45733002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic/crypto/crypto_server_test.cc')
-rw-r--r--net/quic/crypto/crypto_server_test.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/net/quic/crypto/crypto_server_test.cc b/net/quic/crypto/crypto_server_test.cc
index 348b31a..258afd5 100644
--- a/net/quic/crypto/crypto_server_test.cc
+++ b/net/quic/crypto/crypto_server_test.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/strings/string_number_conversions.h"
+#include "crypto/secure_hash.h"
#include "net/quic/crypto/crypto_server_config.h"
#include "net/quic/crypto/crypto_utils.h"
#include "net/quic/crypto/quic_random.h"
@@ -258,6 +259,58 @@ TEST(CryptoServerConfigGenerationTest, Determinism) {
ASSERT_EQ(scfg_a->DebugString(), scfg_b->DebugString());
}
+TEST(CryptoServerConfigGenerationTest, SCIDVaries) {
+ // This test ensures that the server config ID varies for different server
+ // configs.
+
+ MockRandom rand_a, rand_b;
+ const QuicCryptoServerConfig::ConfigOptions options;
+ MockClock clock;
+
+ QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a);
+ rand_b.ChangeValue();
+ QuicCryptoServerConfig b(QuicCryptoServerConfig::TESTING, &rand_b);
+ scoped_ptr<CryptoHandshakeMessage> scfg_a(
+ a.AddDefaultConfig(&rand_a, &clock, options));
+ scoped_ptr<CryptoHandshakeMessage> scfg_b(
+ b.AddDefaultConfig(&rand_b, &clock, options));
+
+ StringPiece scid_a, scid_b;
+ EXPECT_TRUE(scfg_a->GetStringPiece(kSCID, &scid_a));
+ EXPECT_TRUE(scfg_b->GetStringPiece(kSCID, &scid_b));
+
+ EXPECT_NE(scid_a, scid_b);
+}
+
+
+TEST(CryptoServerConfigGenerationTest, SCIDIsHashOfServerConfig) {
+ MockRandom rand_a;
+ const QuicCryptoServerConfig::ConfigOptions options;
+ MockClock clock;
+
+ QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a);
+ scoped_ptr<CryptoHandshakeMessage> scfg(
+ a.AddDefaultConfig(&rand_a, &clock, options));
+
+ StringPiece scid;
+ EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid));
+ // Need to take a copy of |scid| has we're about to call |Erase|.
+ const string scid_str(scid.as_string());
+
+ scfg->Erase(kSCID);
+ scfg->MarkDirty();
+ const QuicData& serialized(scfg->GetSerialized());
+
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(serialized.data(), serialized.length());
+ uint8 digest[16];
+ hash->Finish(digest, sizeof(digest));
+
+ ASSERT_EQ(scid.size(), sizeof(digest));
+ EXPECT_TRUE(0 == memcmp(digest, scid_str.data(), sizeof(digest)));
+}
+
class CryptoServerTestNoConfig : public CryptoServerTest {
public:
virtual void SetUp() {