| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return 1; | 73 return 1; |
| 74 } | 74 } |
| 75 return 0; | 75 return 0; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // CommonCertSetsQUIC implements the CommonCertSets interface using the default | 78 // CommonCertSetsQUIC implements the CommonCertSets interface using the default |
| 79 // certificate sets. | 79 // certificate sets. |
| 80 class CommonCertSetsQUIC : public CommonCertSets { | 80 class CommonCertSetsQUIC : public CommonCertSets { |
| 81 public: | 81 public: |
| 82 // CommonCertSets interface. | 82 // CommonCertSets interface. |
| 83 virtual StringPiece GetCommonHashes() const override { | 83 StringPiece GetCommonHashes() const override { |
| 84 return StringPiece(reinterpret_cast<const char*>(kSetHashes), | 84 return StringPiece(reinterpret_cast<const char*>(kSetHashes), |
| 85 sizeof(uint64) * arraysize(kSetHashes)); | 85 sizeof(uint64) * arraysize(kSetHashes)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual StringPiece GetCert(uint64 hash, uint32 index) const override { | 88 StringPiece GetCert(uint64 hash, uint32 index) const override { |
| 89 for (size_t i = 0; i < arraysize(kSets); i++) { | 89 for (size_t i = 0; i < arraysize(kSets); i++) { |
| 90 if (kSets[i].hash == hash) { | 90 if (kSets[i].hash == hash) { |
| 91 if (index < kSets[i].num_certs) { | 91 if (index < kSets[i].num_certs) { |
| 92 return StringPiece( | 92 return StringPiece( |
| 93 reinterpret_cast<const char*>(kSets[i].certs[index]), | 93 reinterpret_cast<const char*>(kSets[i].certs[index]), |
| 94 kSets[i].lens[index]); | 94 kSets[i].lens[index]); |
| 95 } | 95 } |
| 96 break; | 96 break; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 return StringPiece(); | 100 return StringPiece(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual bool MatchCert(StringPiece cert, | 103 bool MatchCert(StringPiece cert, |
| 104 StringPiece common_set_hashes, | 104 StringPiece common_set_hashes, |
| 105 uint64* out_hash, | 105 uint64* out_hash, |
| 106 uint32* out_index) const override { | 106 uint32* out_index) const override { |
| 107 if (common_set_hashes.size() % sizeof(uint64) != 0) { | 107 if (common_set_hashes.size() % sizeof(uint64) != 0) { |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 for (size_t i = 0; i < common_set_hashes.size() / sizeof(uint64); i++) { | 111 for (size_t i = 0; i < common_set_hashes.size() / sizeof(uint64); i++) { |
| 112 uint64 hash; | 112 uint64 hash; |
| 113 memcpy(&hash, common_set_hashes.data() + i * sizeof(uint64), | 113 memcpy(&hash, common_set_hashes.data() + i * sizeof(uint64), |
| 114 sizeof(uint64)); | 114 sizeof(uint64)); |
| 115 | 115 |
| 116 for (size_t j = 0; j < arraysize(kSets); j++) { | 116 for (size_t j = 0; j < arraysize(kSets); j++) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } // anonymous namespace | 162 } // anonymous namespace |
| 163 | 163 |
| 164 CommonCertSets::~CommonCertSets() {} | 164 CommonCertSets::~CommonCertSets() {} |
| 165 | 165 |
| 166 // static | 166 // static |
| 167 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { | 167 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { |
| 168 return CommonCertSetsQUIC::GetInstance(); | 168 return CommonCertSetsQUIC::GetInstance(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace net | 171 } // namespace net |
| OLD | NEW |