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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 years, 7 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/crypto/common_cert_set.h ('k') | net/quic/crypto/common_cert_set_1_50.inc » ('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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/quic/quic_utils.h" 9 #include "net/quic/quic_utils.h"
10 10
11 using base::StringPiece; 11 using base::StringPiece;
12 12
13 namespace net { 13 namespace net {
14 14
15 namespace common_cert_set_0 { 15 namespace common_cert_set_0 {
16 #include "net/quic/crypto/common_cert_set_0.c" 16 #include "net/quic/crypto/common_cert_set_0.c"
17 } 17 }
18 18
19
20 struct CertSet { 19 struct CertSet {
20 // num_certs contains the number of certificates in this set.
21 size_t num_certs; 21 size_t num_certs;
22 // certs is an array of |num_certs| pointers to the DER encoded certificates.
22 const unsigned char* const* certs; 23 const unsigned char* const* certs;
24 // lens is an array of |num_certs| integers describing the length, in bytes,
25 // of each certificate.
23 const size_t* lens; 26 const size_t* lens;
27 // hash contains the 64-bit, FNV-1a hash of this set.
24 uint64 hash; 28 uint64 hash;
25 }; 29 };
26 30
27 static const CertSet kSets[] = { 31 static const CertSet kSets[] = {
28 { 32 {
29 common_cert_set_0::kNumCerts, 33 common_cert_set_0::kNumCerts,
30 common_cert_set_0::kCerts, 34 common_cert_set_0::kCerts,
31 common_cert_set_0::kLens, 35 common_cert_set_0::kLens,
32 common_cert_set_0::kHash, 36 common_cert_set_0::kHash,
33 }, 37 },
34 }; 38 };
35 39
36 static const uint64 kSetHashes[] = { 40 static const uint64 kSetHashes[] = {
37 common_cert_set_0::kHash, 41 common_cert_set_0::kHash,
38 }; 42 };
39 43
40 CommonCertSet::~CommonCertSet() { 44 CommonCertSets::~CommonCertSets() {
41 } 45 }
42 46
43 CommonCertSetQUIC::CommonCertSetQUIC() { 47 CommonCertSetsQUIC::CommonCertSetsQUIC() {
44 } 48 }
45 49
46 StringPiece CommonCertSetQUIC::GetCommonHashes() { 50 StringPiece CommonCertSetsQUIC::GetCommonHashes() const {
47 return StringPiece(reinterpret_cast<const char*>(kSetHashes), 51 return StringPiece(reinterpret_cast<const char*>(kSetHashes),
48 sizeof(uint64) * arraysize(kSetHashes)); 52 sizeof(uint64) * arraysize(kSetHashes));
49 } 53 }
50 54
51 StringPiece CommonCertSetQUIC::GetCert(uint64 hash, uint32 index) { 55 StringPiece CommonCertSetsQUIC::GetCert(uint64 hash, uint32 index) const {
52 for (size_t i = 0; i < arraysize(kSets); i++) { 56 for (size_t i = 0; i < arraysize(kSets); i++) {
53 if (kSets[i].hash == hash) { 57 if (kSets[i].hash == hash) {
54 if (index >= kSets[i].num_certs) { 58 if (index >= kSets[i].num_certs) {
55 return StringPiece(); 59 return StringPiece();
56 } 60 }
57 return StringPiece(reinterpret_cast<const char*>(kSets[i].certs[index]), 61 return StringPiece(reinterpret_cast<const char*>(kSets[i].certs[index]),
58 kSets[i].lens[index]); 62 kSets[i].lens[index]);
59 } 63 }
60 } 64 }
61 65
(...skipping 13 matching lines...) Expand all
75 } 79 }
76 80
77 if (a.size() < b_len) { 81 if (a.size() < b_len) {
78 return -1; 82 return -1;
79 } else if (a.size() > b_len) { 83 } else if (a.size() > b_len) {
80 return 1; 84 return 1;
81 } 85 }
82 return 0; 86 return 0;
83 } 87 }
84 88
85 bool CommonCertSetQUIC::MatchCert(StringPiece cert, 89 bool CommonCertSetsQUIC::MatchCert(StringPiece cert,
86 StringPiece common_set_hashes, 90 StringPiece common_set_hashes,
87 uint64* out_hash, 91 uint64* out_hash,
88 uint32* out_index) { 92 uint32* out_index) const {
89 if (common_set_hashes.size() % sizeof(uint64) != 0) { 93 if (common_set_hashes.size() % sizeof(uint64) != 0) {
90 return false; 94 return false;
91 } 95 }
92 96
93 for (size_t i = 0; i < common_set_hashes.size() / sizeof(uint64); i++) { 97 for (size_t i = 0; i < common_set_hashes.size() / sizeof(uint64); i++) {
94 uint64 hash; 98 uint64 hash;
95 memcpy(&hash, common_set_hashes.data() + i*sizeof(uint64), sizeof(uint64)); 99 memcpy(&hash, common_set_hashes.data() + i*sizeof(uint64), sizeof(uint64));
96 100
97 for (size_t j = 0; j < arraysize(kSets); j++) { 101 for (size_t j = 0; j < arraysize(kSets); j++) {
98 if (kSets[j].hash != hash) { 102 if (kSets[j].hash != hash) {
(...skipping 27 matching lines...) Expand all
126 return true; 130 return true;
127 } 131 }
128 } 132 }
129 } 133 }
130 } 134 }
131 135
132 return false; 136 return false;
133 } 137 }
134 138
135 } // namespace net 139 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/common_cert_set.h ('k') | net/quic/crypto/common_cert_set_1_50.inc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698