| 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/core/crypto/common_cert_set.h" | 5 #include "net/quic/core/crypto/common_cert_set.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "net/quic/core/quic_utils.h" | 12 #include "net/quic/core/quic_utils.h" |
| 13 | 13 |
| 14 using base::StringPiece; | 14 using base::StringPiece; |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace common_cert_set_1 { | 18 namespace common_cert_set_1 { |
| 19 #include "net/quic/core/crypto/common_cert_set_1.c" | 19 #include "net/quic/core/crypto/common_cert_set_1.c" |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace common_cert_set_2 { | 22 namespace common_cert_set_2 { |
| 23 #include "net/quic/core/crypto/common_cert_set_2.c" | 23 #include "net/quic/core/crypto/common_cert_set_2.c" |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace common_cert_set_3 { |
| 27 #include "net/quic/core/crypto/common_cert_set_3.c" |
| 28 } |
| 29 |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| 28 struct CertSet { | 32 struct CertSet { |
| 29 // num_certs contains the number of certificates in this set. | 33 // num_certs contains the number of certificates in this set. |
| 30 size_t num_certs; | 34 size_t num_certs; |
| 31 // certs is an array of |num_certs| pointers to the DER encoded certificates. | 35 // certs is an array of |num_certs| pointers to the DER encoded certificates. |
| 32 const unsigned char* const* certs; | 36 const unsigned char* const* certs; |
| 33 // lens is an array of |num_certs| integers describing the length, in bytes, | 37 // lens is an array of |num_certs| integers describing the length, in bytes, |
| 34 // of each certificate. | 38 // of each certificate. |
| 35 const size_t* lens; | 39 const size_t* lens; |
| 36 // hash contains the 64-bit, FNV-1a hash of this set. | 40 // hash contains the 64-bit, FNV-1a hash of this set. |
| 37 uint64_t hash; | 41 uint64_t hash; |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 const CertSet kSets[] = { | 44 const CertSet kSets[] = { |
| 41 { | 45 { |
| 42 common_cert_set_1::kNumCerts, common_cert_set_1::kCerts, | 46 common_cert_set_1::kNumCerts, common_cert_set_1::kCerts, |
| 43 common_cert_set_1::kLens, common_cert_set_1::kHash, | 47 common_cert_set_1::kLens, common_cert_set_1::kHash, |
| 44 }, | 48 }, |
| 45 { | 49 { |
| 46 common_cert_set_2::kNumCerts, common_cert_set_2::kCerts, | 50 common_cert_set_2::kNumCerts, common_cert_set_2::kCerts, |
| 47 common_cert_set_2::kLens, common_cert_set_2::kHash, | 51 common_cert_set_2::kLens, common_cert_set_2::kHash, |
| 48 }, | 52 }, |
| 53 { |
| 54 common_cert_set_3::kNumCerts, common_cert_set_3::kCerts, |
| 55 common_cert_set_3::kLens, common_cert_set_3::kHash, |
| 56 }, |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 const uint64_t kSetHashes[] = { | 59 const uint64_t kSetHashes[] = { |
| 52 common_cert_set_1::kHash, common_cert_set_2::kHash, | 60 common_cert_set_1::kHash, common_cert_set_2::kHash, |
| 61 common_cert_set_3::kHash, |
| 53 }; | 62 }; |
| 54 | 63 |
| 55 // Compare returns a value less than, equal to or greater than zero if |a| is | 64 // Compare returns a value less than, equal to or greater than zero if |a| is |
| 56 // lexicographically less than, equal to or greater than |b|, respectively. | 65 // lexicographically less than, equal to or greater than |b|, respectively. |
| 57 int Compare(StringPiece a, const unsigned char* b, size_t b_len) { | 66 int Compare(StringPiece a, const unsigned char* b, size_t b_len) { |
| 58 size_t len = a.size(); | 67 size_t len = a.size(); |
| 59 if (len > b_len) { | 68 if (len > b_len) { |
| 60 len = b_len; | 69 len = b_len; |
| 61 } | 70 } |
| 62 int n = memcmp(a.data(), b, len); | 71 int n = memcmp(a.data(), b, len); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } // anonymous namespace | 168 } // anonymous namespace |
| 160 | 169 |
| 161 CommonCertSets::~CommonCertSets() {} | 170 CommonCertSets::~CommonCertSets() {} |
| 162 | 171 |
| 163 // static | 172 // static |
| 164 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { | 173 const CommonCertSets* CommonCertSets::GetInstanceQUIC() { |
| 165 return CommonCertSetsQUIC::GetInstance(); | 174 return CommonCertSetsQUIC::GetInstance(); |
| 166 } | 175 } |
| 167 | 176 |
| 168 } // namespace net | 177 } // namespace net |
| OLD | NEW |