OLD | NEW |
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 "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 return 1; | 62 return 1; |
63 } | 63 } |
64 return 0; | 64 return 0; |
65 } | 65 } |
66 | 66 |
67 // CommonCertSetsQUIC implements the CommonCertSets interface using the default | 67 // CommonCertSetsQUIC implements the CommonCertSets interface using the default |
68 // certificate sets. | 68 // certificate sets. |
69 class CommonCertSetsQUIC : public CommonCertSets { | 69 class CommonCertSetsQUIC : public CommonCertSets { |
70 public: | 70 public: |
71 // CommonCertSets interface. | 71 // CommonCertSets interface. |
72 virtual StringPiece GetCommonHashes() const OVERRIDE { | 72 virtual StringPiece GetCommonHashes() const override { |
73 return StringPiece(reinterpret_cast<const char*>(kSetHashes), | 73 return StringPiece(reinterpret_cast<const char*>(kSetHashes), |
74 sizeof(uint64) * arraysize(kSetHashes)); | 74 sizeof(uint64) * arraysize(kSetHashes)); |
75 } | 75 } |
76 | 76 |
77 virtual StringPiece GetCert(uint64 hash, uint32 index) const OVERRIDE { | 77 virtual StringPiece GetCert(uint64 hash, uint32 index) const override { |
78 for (size_t i = 0; i < arraysize(kSets); i++) { | 78 for (size_t i = 0; i < arraysize(kSets); i++) { |
79 if (kSets[i].hash == hash) { | 79 if (kSets[i].hash == hash) { |
80 if (index < kSets[i].num_certs) { | 80 if (index < kSets[i].num_certs) { |
81 return StringPiece( | 81 return StringPiece( |
82 reinterpret_cast<const char*>(kSets[i].certs[index]), | 82 reinterpret_cast<const char*>(kSets[i].certs[index]), |
83 kSets[i].lens[index]); | 83 kSets[i].lens[index]); |
84 } | 84 } |
85 break; | 85 break; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 return StringPiece(); | 89 return StringPiece(); |
90 } | 90 } |
91 | 91 |
92 virtual bool MatchCert(StringPiece cert, StringPiece common_set_hashes, | 92 virtual bool MatchCert(StringPiece cert, StringPiece common_set_hashes, |
93 uint64* out_hash, uint32* out_index) const OVERRIDE { | 93 uint64* out_hash, uint32* out_index) const override { |
94 if (common_set_hashes.size() % sizeof(uint64) != 0) { | 94 if (common_set_hashes.size() % sizeof(uint64) != 0) { |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
98 for (size_t i = 0; i < common_set_hashes.size() / sizeof(uint64); i++) { | 98 for (size_t i = 0; i < common_set_hashes.size() / sizeof(uint64); i++) { |
99 uint64 hash; | 99 uint64 hash; |
100 memcpy(&hash, common_set_hashes.data() + i * sizeof(uint64), | 100 memcpy(&hash, common_set_hashes.data() + i * sizeof(uint64), |
101 sizeof(uint64)); | 101 sizeof(uint64)); |
102 | 102 |
103 for (size_t j = 0; j < arraysize(kSets); j++) { | 103 for (size_t j = 0; j < arraysize(kSets); j++) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } // anonymous namespace | 149 } // anonymous namespace |
150 | 150 |
151 CommonCertSets::~CommonCertSets() {} | 151 CommonCertSets::~CommonCertSets() {} |
152 | 152 |
153 // static | 153 // static |
154 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { | 154 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { |
155 return CommonCertSetsQUIC::GetInstance(); | 155 return CommonCertSetsQUIC::GetInstance(); |
156 } | 156 } |
157 | 157 |
158 } // namespace net | 158 } // namespace net |
OLD | NEW |