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

Side by Side Diff: net/quic/crypto/cert_compressor_test.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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
« no previous file with comments | « net/quic/crypto/cert_compressor.cc ('k') | net/quic/crypto/chacha20_poly1305_decrypter.h » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/crypto/cert_compressor.h" 5 #include "net/quic/crypto/cert_compressor.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "net/quic/quic_utils.h" 8 #include "net/quic/quic_utils.h"
9 #include "net/quic/test_tools/crypto_test_utils.h" 9 #include "net/quic/test_tools/crypto_test_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 28 matching lines...) Expand all
39 vector<string> chain2, cached_certs; 39 vector<string> chain2, cached_certs;
40 ASSERT_TRUE(CertCompressor::DecompressChain(compressed, cached_certs, nullptr, 40 ASSERT_TRUE(CertCompressor::DecompressChain(compressed, cached_certs, nullptr,
41 &chain2)); 41 &chain2));
42 EXPECT_EQ(chain.size(), chain2.size()); 42 EXPECT_EQ(chain.size(), chain2.size());
43 EXPECT_EQ(chain[0], chain2[0]); 43 EXPECT_EQ(chain[0], chain2[0]);
44 } 44 }
45 45
46 TEST(CertCompressor, Common) { 46 TEST(CertCompressor, Common) {
47 vector<string> chain; 47 vector<string> chain;
48 chain.push_back("testcert"); 48 chain.push_back("testcert");
49 static const uint64 set_hash = 42; 49 static const uint64_t set_hash = 42;
50 scoped_ptr<CommonCertSets> common_sets( 50 scoped_ptr<CommonCertSets> common_sets(
51 CryptoTestUtils::MockCommonCertSets(chain[0], set_hash, 1)); 51 CryptoTestUtils::MockCommonCertSets(chain[0], set_hash, 1));
52 const string compressed = CertCompressor::CompressChain( 52 const string compressed = CertCompressor::CompressChain(
53 chain, 53 chain,
54 StringPiece(reinterpret_cast<const char*>(&set_hash), sizeof(set_hash)), 54 StringPiece(reinterpret_cast<const char*>(&set_hash), sizeof(set_hash)),
55 StringPiece(), common_sets.get()); 55 StringPiece(), common_sets.get());
56 const string common( 56 const string common(
57 "03" /* common */ 57 "03" /* common */
58 "2A00000000000000" /* set hash 42 */ 58 "2A00000000000000" /* set hash 42 */
59 "01000000" /* index 1 */ 59 "01000000" /* index 1 */
60 "00" /* end of list */); 60 "00" /* end of list */);
61 EXPECT_EQ(common.data(), 61 EXPECT_EQ(common.data(),
62 base::HexEncode(compressed.data(), compressed.size())); 62 base::HexEncode(compressed.data(), compressed.size()));
63 63
64 vector<string> chain2, cached_certs; 64 vector<string> chain2, cached_certs;
65 ASSERT_TRUE(CertCompressor::DecompressChain(compressed, cached_certs, 65 ASSERT_TRUE(CertCompressor::DecompressChain(compressed, cached_certs,
66 common_sets.get(), &chain2)); 66 common_sets.get(), &chain2));
67 EXPECT_EQ(chain.size(), chain2.size()); 67 EXPECT_EQ(chain.size(), chain2.size());
68 EXPECT_EQ(chain[0], chain2[0]); 68 EXPECT_EQ(chain[0], chain2[0]);
69 } 69 }
70 70
71 TEST(CertCompressor, Cached) { 71 TEST(CertCompressor, Cached) {
72 vector<string> chain; 72 vector<string> chain;
73 chain.push_back("testcert"); 73 chain.push_back("testcert");
74 uint64 hash = QuicUtils::FNV1a_64_Hash(chain[0].data(), chain[0].size()); 74 uint64_t hash = QuicUtils::FNV1a_64_Hash(chain[0].data(), chain[0].size());
75 StringPiece hash_bytes(reinterpret_cast<char*>(&hash), sizeof(hash)); 75 StringPiece hash_bytes(reinterpret_cast<char*>(&hash), sizeof(hash));
76 const string compressed = 76 const string compressed =
77 CertCompressor::CompressChain(chain, StringPiece(), hash_bytes, nullptr); 77 CertCompressor::CompressChain(chain, StringPiece(), hash_bytes, nullptr);
78 78
79 EXPECT_EQ("02" /* cached */ + 79 EXPECT_EQ("02" /* cached */ +
80 base::HexEncode(hash_bytes.data(), hash_bytes.size()) + 80 base::HexEncode(hash_bytes.data(), hash_bytes.size()) +
81 "00" /* end of list */, 81 "00" /* end of list */,
82 base::HexEncode(compressed.data(), compressed.size())); 82 base::HexEncode(compressed.data(), compressed.size()));
83 83
84 vector<string> cached_certs, chain2; 84 vector<string> cached_certs, chain2;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 "a200000000000000" 136 "a200000000000000"
137 "00000000"); 137 "00000000");
138 EXPECT_FALSE(CertCompressor::DecompressChain( 138 EXPECT_FALSE(CertCompressor::DecompressChain(
139 base::HexEncode(incorrect_hash_and_index.data(), 139 base::HexEncode(incorrect_hash_and_index.data(),
140 incorrect_hash_and_index.size()), 140 incorrect_hash_and_index.size()),
141 cached_certs, nullptr, &chain)); 141 cached_certs, nullptr, &chain));
142 } 142 }
143 143
144 } // namespace test 144 } // namespace test
145 } // namespace net 145 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/cert_compressor.cc ('k') | net/quic/crypto/chacha20_poly1305_decrypter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698