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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « net/quic/crypto/common_cert_set_1.c ('k') | net/quic/crypto/null_decrypter.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) 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/common_cert_set.h" 5 #include "net/quic/crypto/common_cert_set.h"
6 6
7 #include <stdint.h>
8
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 using base::StringPiece; 11 using base::StringPiece;
10 12
11 namespace net { 13 namespace net {
12 namespace test { 14 namespace test {
13 15
14 static const unsigned char kGIACertificate1[] = { 16 static const unsigned char kGIACertificate1[] = {
15 0x30, 0x82, 0x03, 0xf0, 0x30, 0x82, 0x02, 0xd8, 0xa0, 0x03, 0x02, 0x01, 17 0x30, 0x82, 0x03, 0xf0, 0x30, 0x82, 0x02, 0xd8, 0xa0, 0x03, 0x02, 0x01,
16 0x02, 0x02, 0x03, 0x02, 0x3a, 0x76, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 18 0x02, 0x02, 0x03, 0x02, 0x3a, 0x76, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 0x55, 0x13, 0x8f, 0xa4, 0x16, 0x02, 0x09, 0x7e, 0xb9, 0xaf, 0xee, 0xdb, 99 0x55, 0x13, 0x8f, 0xa4, 0x16, 0x02, 0x09, 0x7e, 0xb9, 0xaf, 0xee, 0xdb,
98 0x53, 0x64, 0xbd, 0x71, 0x2f, 0xb9, 0x39, 0xce, 0x30, 0xb7, 0xb4, 0xbc, 100 0x53, 0x64, 0xbd, 0x71, 0x2f, 0xb9, 0x39, 0xce, 0x30, 0xb7, 0xb4, 0xbc,
99 0x54, 0xe0, 0x47, 0x07, 101 0x54, 0xe0, 0x47, 0x07,
100 }; 102 };
101 103
102 TEST(CommonCertSets, FindGIA_1) { 104 TEST(CommonCertSets, FindGIA_1) {
103 StringPiece gia(reinterpret_cast<const char*>(kGIACertificate1), 105 StringPiece gia(reinterpret_cast<const char*>(kGIACertificate1),
104 sizeof(kGIACertificate1)); 106 sizeof(kGIACertificate1));
105 107
106 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); 108 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC());
107 const uint64 in_hash = GG_UINT64_C(0xff715ce4e7e9267b); 109 const uint64 in_hash = UINT64_C(0xff715ce4e7e9267b);
108 uint64 hash; 110 uint64 hash;
109 uint32 index; 111 uint32 index;
110 ASSERT_TRUE(sets->MatchCert( 112 ASSERT_TRUE(sets->MatchCert(
111 gia, 113 gia,
112 StringPiece(reinterpret_cast<const char*>(&in_hash), sizeof(in_hash)), 114 StringPiece(reinterpret_cast<const char*>(&in_hash), sizeof(in_hash)),
113 &hash, &index)); 115 &hash, &index));
114 EXPECT_EQ(in_hash, hash); 116 EXPECT_EQ(in_hash, hash);
115 117
116 StringPiece gia_copy = sets->GetCert(hash, index); 118 StringPiece gia_copy = sets->GetCert(hash, index);
117 EXPECT_FALSE(gia_copy.empty()); 119 EXPECT_FALSE(gia_copy.empty());
118 ASSERT_EQ(gia.size(), gia_copy.size()); 120 ASSERT_EQ(gia.size(), gia_copy.size());
119 EXPECT_EQ(0, memcmp(gia.data(), gia_copy.data(), gia.size())); 121 EXPECT_EQ(0, memcmp(gia.data(), gia_copy.data(), gia.size()));
120 } 122 }
121 123
122 TEST(CommonCertSets, NonMatch) { 124 TEST(CommonCertSets, NonMatch) {
123 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); 125 const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC());
124 StringPiece not_a_cert("hello"); 126 StringPiece not_a_cert("hello");
125 const uint64 in_hash = GG_UINT64_C(0xc9fef74053f99f39); 127 const uint64 in_hash = UINT64_C(0xc9fef74053f99f39);
126 uint64 hash; 128 uint64 hash;
127 uint32 index; 129 uint32 index;
128 EXPECT_FALSE(sets->MatchCert( 130 EXPECT_FALSE(sets->MatchCert(
129 not_a_cert, 131 not_a_cert,
130 StringPiece(reinterpret_cast<const char*>(&in_hash), sizeof(in_hash)), 132 StringPiece(reinterpret_cast<const char*>(&in_hash), sizeof(in_hash)),
131 &hash, &index)); 133 &hash, &index));
132 } 134 }
133 135
134 } // namespace test 136 } // namespace test
135 } // namespace net 137 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/common_cert_set_1.c ('k') | net/quic/crypto/null_decrypter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698