summaryrefslogtreecommitdiffstats
path: root/net/quic/test_tools/crypto_test_utils.cc
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 20:55:04 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 20:55:04 +0000
commitc244c5a193c87604027741ec38b456ff9a446f8e (patch)
tree61c50a1031d9315cdafde41c1884c70f69639471 /net/quic/test_tools/crypto_test_utils.cc
parent9c9b2ae80da65e2d2e0d98df1827723b307d382d (diff)
downloadchromium_src-c244c5a193c87604027741ec38b456ff9a446f8e.zip
chromium_src-c244c5a193c87604027741ec38b456ff9a446f8e.tar.gz
chromium_src-c244c5a193c87604027741ec38b456ff9a446f8e.tar.bz2
Land Recent QUIC changes
Implement header compression/decompression in ReliableQuicStream. Merge internal change: 44867738 QUIC: deflake proof_test. The current proof_test removes a byte from the start of the signature in order to make it invalid. However, the signature is a big-endian number and, ~1% of the time, the first byte will be zero - thus removing it doesn't change the number. This change adds a non-zero byte to the start of the signature instead. Merge internal change: 44803399 Replace calls to scoped_ptr(NULL) with calls to scoped_ptr(). Merge internal change: 44799980 Add a blank line in order to get the dependencies correct for rebuild. Merge internal change: 44796024 Fix "large integer implicitly truncated to unsigned type" Merge internal change: 44793986 QUIC: compress certificates. This change causes server certificates to be compressed using three tricks: 1) The client can advertise sets of common certificates that the server can then simply reference. This change contains "common certificate set 0", which is the set of the intermediates used twice or more in the Alexa top 5000. It's temporary because it's missing GIAG2 which we'll want to include soon. 2) The client can send 64-bit, FNV-1a hashes of certificates that it already has and the server can reference them by hash. 3) Otherwise, certifciates are gzip compressed with a dictionary that includes any certificates compressed using the previous two methods and a 1500 byte lump of common substrings. (Again, taken from the Alexa top 5000) POKE=1 Merge internal change: 44792710 R=mnaganov@chromium.org, rch@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=198736 Review URL: https://codereview.chromium.org/14651009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic/test_tools/crypto_test_utils.cc')
-rw-r--r--net/quic/test_tools/crypto_test_utils.cc64
1 files changed, 63 insertions, 1 deletions
diff --git a/net/quic/test_tools/crypto_test_utils.cc b/net/quic/test_tools/crypto_test_utils.cc
index 4fec83d..99af86f 100644
--- a/net/quic/test_tools/crypto_test_utils.cc
+++ b/net/quic/test_tools/crypto_test_utils.cc
@@ -4,7 +4,7 @@
#include "net/quic/test_tools/crypto_test_utils.h"
-#include "base/strings/string_piece.h"
+#include "net/quic/crypto/common_cert_set.h"
#include "net/quic/crypto/crypto_handshake.h"
#include "net/quic/crypto/crypto_server_config.h"
#include "net/quic/crypto/quic_decrypter.h"
@@ -215,6 +215,68 @@ string CryptoTestUtils::GetValueForTag(const CryptoHandshakeMessage& message,
return it->second;
}
+class MockCommonCertSet : public CommonCertSet {
+ public:
+ MockCommonCertSet(StringPiece cert, uint64 hash, uint32 index)
+ : cert_(cert.as_string()),
+ hash_(hash),
+ index_(index) {
+ }
+
+ virtual StringPiece GetCommonHashes() OVERRIDE {
+ CHECK(false) << "not implemented";
+ return StringPiece();
+ }
+
+ virtual StringPiece GetCert(uint64 hash, uint32 index) OVERRIDE {
+ if (hash == hash_ && index == index_) {
+ return cert_;
+ }
+ return StringPiece();
+ }
+
+ virtual bool MatchCert(StringPiece cert,
+ StringPiece common_set_hashes,
+ uint64* out_hash,
+ uint32* out_index) OVERRIDE {
+ if (cert != cert_) {
+ return false;
+ }
+
+ if (common_set_hashes.size() % sizeof(uint64) != 0) {
+ return false;
+ }
+ bool client_has_set = false;
+ for (size_t i = 0; i < common_set_hashes.size(); i += sizeof(uint64)) {
+ uint64 hash;
+ memcpy(&hash, common_set_hashes.data() + i, sizeof(hash));
+ if (hash == hash_) {
+ client_has_set = true;
+ break;
+ }
+ }
+
+ if (!client_has_set) {
+ return false;
+ }
+
+ *out_hash = hash_;
+ *out_index = index_;
+ return true;
+ }
+
+ private:
+ const string cert_;
+ const uint64 hash_;
+ const uint32 index_;
+};
+
+CommonCertSet* CryptoTestUtils::MockCommonCertSet(StringPiece cert,
+ uint64 hash,
+ uint32 index) {
+ return new class MockCommonCertSet(cert, hash, index);
+}
+
void CryptoTestUtils::CompareClientAndServerKeys(
QuicCryptoClientStream* client,
QuicCryptoServerStream* server) {